Commit Graph

11608 Commits

Author SHA1 Message Date
Daniel P. Berrange
ad39fd83a8 Define a wire protocol for talking to the virtlockd daemon
The virtlockd daemon will be responsible for managing locks
on virtual machines. Communication will be via the standard
RPC infrastructure. This provides the XDR protocol definition

* src/locking/lock_protocol.x: Wire protocol for virtlockd
* src/Makefile.am: Include lock_protocol.[ch] in virtlockd

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:26:57 +00:00
Daniel P. Berrange
c57e3d8994 Introduce basic infrastructure for virtlockd daemon
The virtlockd daemon will maintain locks on behalf of libvirtd.
There are two reasons for it to be separate

 - Avoid risk of other libvirtd threads accidentally
   releasing fcntl() locks by opening + closing a file
   that is locked
 - Ensure locks can be preserved across libvirtd restarts.
   virtlockd will need to be able to re-exec itself while
   maintaining locks. This is simpler to achieve if its
   sole job is maintaining locks

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:26:57 +00:00
Daniel P. Berrange
f199f75e9b Refactor creation of lock manager plugins
Refactor virLockManagerPluginNew() so that the caller does
not need to pass in the config file path itself - just the
config directory and driver name.

Fix QEMU to actually pass in a config file when creating the
default lock manager plugin, rather than NULL.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:26:57 +00:00
Daniel P. Berrange
41ac222e52 Fix error reporting when fetching SCSI/LVM keys
The current  virStorageFileGet{LVM,SCSI}Key methods return
the key as the return value. Unfortunately it is desirable
for "NULL" to be a valid return value, as well as an error
indicator. Thus the returned key must instead be provided
as an out-parameter.

When we invoke lvs or scsi_id to extract ID for block devices,
we don't want virCommandWait logging errors messages. Thus we
must explicitly check 'status != 0', rather than letting
virCommandWait do it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:26:57 +00:00
Jim Fehlig
f6b5ed5ef0 Support network boot for HVM guests in libxl
The libxl driver ignored boot devices in the domain config,
preventing PXE booting HVM domains.  This patch accounts for
user-specified boot devices when building the libxl domain
configuration.
2012-12-13 08:05:12 -07:00
Daniel P. Berrange
32bef82a2d Fix probing of QED file format
The QED file format is non-versioned, so although the magic
value matched, libvirt rejected it due to lack of a version
number to compare against. We need to distinguish this case
by allowing a value of '-2' to indicate a non-versioned file
where only the magic is required to match

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:01:38 +00:00
Daniel P. Berrange
24643c780b Add lots of debugging to storage file probing code
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:01:25 +00:00
Daniel P. Berrange
dfba37048a Log warning if storage magic matches, but version does not
To help us detect when new storage file versions come into
existance log a warning if the storage file magic matches,
but the version does not

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-13 15:00:12 +00:00
Daniel P. Berrange
f6bd0a8899 Fix memory leak in QEMU QMP capabilities initialization
The qemuCapsInitQMP method never frees the QEMU 'package'
version string.
2012-12-13 14:45:53 +00:00
Daniel P. Berrange
cc5c7f9865 Change virCgroupGetAppRoot stub on non-Linux to avoid unused param warning
Fully stub out the virCgroupGetAppRoot method as done with other
methods in the file, rather than just the body. This lets us
annotate the unused parameter to avoid a warning
2012-12-13 13:11:44 +00:00
Eric Blake
7339bc4ced network: match xml warning message
I noticed that /var/lib/libvirt/dnsmasq/*.conf used the wrong word;
it was intended to match the wording in src/util/xml.c.

* src/network/bridge_driver.c (networkDnsmasqConfContents): Fix typo.
* tests/networkxml2confdata/*.conf: Update accordingly.
2012-12-12 15:12:58 -07:00
Roman Bogorodskiy
9a2f36ec04 Qemu FreeBSD: fix compilation
* Autotools changes:
  - Don't assume Qemu is Linux-only
  - Check Linux headers only on Linux
  - Disable firewalld on FreeBSD
* Initctl:
  Initctl seem to present only on Linux, so stub it on other platforms
* Raw I/O: Linux-only as well
* Headers cleanup
2012-12-12 11:59:53 -07:00
Roman Bogorodskiy
b467e9323c Drop mntent.h include.
It's no longer used and also causes build fail on FreeBSD.
2012-12-12 11:07:24 -07:00
Viktor Mihajlovski
f1f9a7ac7e Fix make check with different object directory
make check fails in check-symsorting if configure is not run in
the source directory. Prefixing symfile names with $(srcdir)
fixes this.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2012-12-12 16:15:25 +00:00
Peter Krempa
ed0bfd04f8 qemu: Improve error reporting from qemuDomainManagedSaveRemove
Report an error if unlink of the managedsave file fails.
2012-12-12 14:34:12 +01:00
Peter Krempa
a02579141e qemu: Small code cleanups in the managedsave functions
Save a few lines moving assignments into conditions and fix braces
position.
2012-12-12 14:34:12 +01:00
Peter Krempa
2745177b34 qemu: Refactor managed save functions to use domain lookup helpers 2012-12-12 14:34:12 +01:00
Peter Krempa
7fc06b0480 qemu: Add a new domain lookup helper and improve the docs
This patch adds a new domain lookup helper qemuDomObjFromDomainDriver
that lookups the domain and leaves the driver locked. The driver is
returned as the second argument of that function. If the lookup fails
the driver is unlocked to help avoid cleanup codepaths.

This patch also improves docs for the helpers.
2012-12-12 14:34:12 +01:00
Peter Krempa
ab8d323319 util: Fix warning message in previous patch
I didn't notice the extra "does" in the previous patch. Remove it.
2012-12-12 14:19:03 +01:00
Peter Krempa
96460a1987 util: rework error reporting in virGet(User|Group)IDByName
This patch gets rid of the undeterministic error reporting code done on
return values of get(pw|gr)nam_r. With this patch, if the group record
is not returned by the corresponding function this error is not
considered fatal even if errno != 0. The error is logged in such case.
2012-12-12 14:06:59 +01:00
Daniel P. Berrange
9cdd9ea20e Refactor virDomainHostdevFind method
Move the code for matching hostdev instances out of virDomainHostdevFind
and into virDomainHostdevMatch method, which in turn calls out to other
helper methods depending on the type of hostdev.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-12 12:27:53 +00:00
Daniel P. Berrange
50897ffbb6 Slightly refactor hostdev parsing / formating
Rename virDomainHostdevPartsParse to virDomainHostdevDefParseSubsys
to reflect the fact that it only deals with hostdevs uing the
traditional mode=subsystem, and not mode=capabilities

Rename virDomainHostSourceFormat to virDomainHostdevDefFormatSubsys
for the same reason.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-12 12:26:53 +00:00
Daniel P. Berrange
3f0010a673 Remove bogus const return values in storage file APIs
virStorageFileGetLVMKey and virStorageFileGetSCSIKey
both return heap allocated strings, so the return value
should not be marked const.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-12 10:50:55 +00:00
Daniel P. Berrange
64212ed20e Add missing export of virStorageFileGetLVMKey & virStorageFileGetSCSIKey 2012-12-12 10:50:11 +00:00
Daniel P. Berrange
a8c8685eaa Fix sorting of libvirt_private.syms and add syntax check rule
Add check-symsorting.pl to perform case-insensitive alphabetical
sorting of groups of symbols. Fix all violations it reports

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-12 10:45:37 +00:00
Cole Robinson
7b97030ad4 uml: Report error if inotify fails on driver startup 2012-12-11 20:03:08 -05:00
Cole Robinson
d13155c20c tools: Only install guests init script if --with-init=script=redhat
Most of this deals with moving the libvirt-guests.sh script which
does all the work to /usr/libexec, so it can be shared by both
systemd and traditional init. Previously systemd depended on
the script being in /etc/init.d

Required to fix https://bugzilla.redhat.com/show_bug.cgi?id=789747
2012-12-11 19:54:37 -05:00
Serge Hallyn
a4e44e674e add vnc unix sockets to apparmor policy
When using vnc gaphics over a unix socket, virt-aa-helper needs to provide
access for the qemu domain to access the sockfile.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 14:32:39 -07:00
Serge Hallyn
88bd1a644b add security hook for permitting hugetlbfs access
When a qemu domain is backed by huge pages, apparmor needs to grant the domain
rw access to files under the hugetlbfs mount point.  Add a hook, called in
qemu_process.c, which ends up adding the read-write access through
virt-aa-helper.  Qemu will be creating a randomly named file under the
mountpoint and unlinking it as soon as it has mmap()d it, therefore we
cannot predict the full pathname, but for the same reason it is generally
safe to provide access to $path/**.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 14:27:20 -07:00
Eric Blake
cdf1a372c6 maint: mention when HACKING is rebuilt during make
I noticed that on Fedora 18, xlstproc decides to regenerate
HACKING with additional whitespace.  I haven't figured out why
that is happening (although fixing it would probably be a task
for xlstproc), but in the process of investigating, I noticed
that 'make HACKING' was completely silent, for no good reason.

* Makefile.am (gen-ChangeLog, gen-AUTHORS, NEWS)
($(top_srcdir)/HACKING): Mention which files we are generating.
2012-12-11 13:35:33 -07:00
Jiri Denemark
748f6dd0c3 docs: Document offline migration 2012-12-11 20:46:31 +01:00
Peter Krempa
08379dbd45 qemu: reuse qemuMigrationIsAllowed when doing save and managedsave
Save and managedsave both use migration to file. This patch reuses
qemuMigrationIsAllowed to check if the migration could happen before
trying.
2012-12-11 19:48:37 +01:00
Peter Krempa
98e92ba83b qemu: snapshot: Report better error message if migration isn't allowed
Qemu doesn't support migration on guests with host devices. This patch
adds a check to ensure migration is safe before actually doing so.
2012-12-11 19:48:37 +01:00
Peter Krempa
e5d3ab5e21 qemu: Make qemuMigrationIsAllowed more reusable
This patch exports qemuMigrationIsAllowed and adds a new parameter to it
to denote if it's a remote migration or a local migration. Local
migrations are used in snapshots and saving of the machine state and
have fewer restrictions. This patch also adjusts callers of the function
and tweaks some error messages to be more universal.
2012-12-11 19:48:37 +01:00
Ján Tomko
6543a459ef qemu: assume seccomp sandbox is supported since qemu 1.2
Currently there is no way to detect it via QMP and requesting "-sandbox
off" works correctly even if it was compiled out, so this will work
unless someone both requests the sandbox in qemu.conf and builds QEMU
without the support for it.
2012-12-11 18:52:29 +01:00
Michal Privoznik
c2fbb3c656 domain: Keep assigned class_id in domstatus XML
Interfaces keeps a class_id, which is an ID from which bridge
part of QoS settings is derived. We need to store class_id
in domain status file, so we can later pass it to
virNetDevBandwidthUnplug.
2012-12-11 18:42:54 +01:00
Michal Privoznik
ae757743dc network: Create real network status files
Currently, we are only keeping a inactive XML configuration
in status dir. This is no longer enough as we need to keep
this class_id attribute so we don't overwrite old entries
when the daemon restarts. However, since there has already
been release which has just <network/> as root element,
and we want to keep things compatible, detect that loaded
status file is older one, and don't scream about it.
2012-12-11 18:42:54 +01:00
Michal Privoznik
07d1b6b5b1 bandwidth: Create network bandwidth (un)plug functions
Network should be notified if we plug in or unplug an
interface, so it can perform some action, e.g. set/unset
network part of QoS. However, we are doing this in very
early stage, so iface->ifname isn't filled in yet. So
whenever we want to report an error, we must use a different
identifier, e.g. the MAC address.
2012-12-11 18:41:47 +01:00
Michal Privoznik
b697411ca0 bandwidth: Create rate update function
This will be used whenever a NIC with guaranteed throughput is to
be plugged into a bridge. It will adjust the average throughput of
non guaranteed NICs (classid 1:2) to meet new requirements.
2012-12-11 18:36:55 +01:00
Michal Privoznik
7cdbacb472 bandwidth: Create (un)plug functions
These set bridge part of QoS when bringing domain's interface up.
Long story short, if there's a 'floor' set, a new QoS class is created.
ClassID MUST be unique within the bridge and should be kept for
unplug phase.
2012-12-11 18:36:55 +01:00
Michal Privoznik
67159f1c60 bandwidth: Create hierarchical shaping classes
These classes can borrow unused bandwidth. Basically,
only egress qdsics can have classes, therefore we can
do this kind of traffic shaping only on host's outgoing,
that is domain's incoming traffic.
2012-12-11 18:36:55 +01:00
Michal Privoznik
ec6474b245 bandwidth: add new 'floor' attribute
This is however supported only on domain interfaces with
type='network'. Moreover, target network needs to have at least
inbound QoS set. This is required by hierarchical traffic shaping.

From now on, the required attribute for <inbound/> is either 'average'
(old) or 'floor' (new). This new attribute can be used just for
interfaces type of network (<interface type='network'/>) currently.
2012-12-11 18:35:12 +01:00
Michal Privoznik
7e5040bd20 bandwidth: Attach sfq to leaf node
Stochastic Fairness Queuing (SFQ) is queuing discipline
(qdisc) which doesn't really shape any traffic but 'just'
re-arrange packets in sending buffer so no stream starve.
The goal is to ensure fairness. There is basically only one
configuration parameter (perturb) which is set to advised
value of 10.
2012-12-11 18:16:52 +01:00
Dmitry Guryanov
ad9d8dbcae parallels: handle network adapters of type 'routed'
Network adapters of type 'routed' is a special case. Other adapters
have 'network' parameter in prlctl's output instead.

Routed network adapters should be connected to 'routed' network
from libvirt's view.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:50:38 +08:00
Dmitry Guryanov
84f0a0b8f2 parallels: add routed pseudo network
Historically if traffic from the adapter is routed to LAN without
NAT, it isn't connected to any virtual networks, but has a 'type'
instead. Sinse libvirt has special virtual network type for such case,
let's add pseudo network 'routed' to fit libvirt's API well.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:50:38 +08:00
Dmitry Guryanov
56494d2b57 parallels: parse virtual network properties
Fill bridge name and mac for bridged network and
DHCP server parameter for host-only network.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:50:38 +08:00
Dmitry Guryanov
6034ce3130 parallels: add network driver
Parallels Cloud Server uses virtual networks model for network
configuration. It uses own tools for virtual network management.
So add network driver, which will be responsible for listing
virtual networks and performing different operations on them
(in consequent patched).

This patch only allows listing virtual network names, without
any parameters like DHCP server settings.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:46:16 +08:00
Dmitry Guryanov
68c6d3dc31 parallels: move parallelsParseError to parallels_utils.h
This macro will be used in another file in the next
patch, so move it to common header file.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:46:16 +08:00
Dmitry Guryanov
880fcf6ab2 parallels: add support of network interfaces to parallelsDomainDefineXML
Allow changing network interfaces in domain configuration.

ifname is used as iterface identifier: if there is interface
with some ifname in old config and there are no interfaces with
such name in the new config - issue prlctl command to delete
the network interface. And vice versa - if interface with
some ifname exists only in new config - issue prlctl command
to create it.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:46:16 +08:00
Dmitry Guryanov
8ce9e2abc3 parallels: parse information about network interfaces
Parse network interfaces info from prlctl output.

Parallels Cloud Server uses virtual networks model for
network configuration: You can add network adapter to
VM and connect it to some predefined virtual network.

Fill type, mac, network name and linkstate fields of
virDomainNetDef structure.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-12-11 22:05:15 +08:00