]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agolxc: Don't shadow global symbol "link"
Peter Krempa [Fri, 14 Feb 2014 12:46:35 +0000 (13:46 +0100)]
lxc: Don't shadow global symbol "link"

Yet another variable name frowned upon by older compilers. Introduced in
commit b73c029d.

11 years agoSupport IPv6 in port allocator
Ján Tomko [Fri, 18 Oct 2013 11:52:03 +0000 (13:52 +0200)]
Support IPv6 in port allocator

Also try to bind on IPv6 to check if the port is occupied.

Change the mocked bind in the test to return EADDRINUSE
for some ports only for the IPv4/IPv6 socket if we're testing
on a host with IPv6 compiled in.

Also mock socket() to make it fail with EAFNOTSUPPORTED
if LIBVIRT_TEST_IPV4ONLY is set in the environment, to
simulate a host without IPv6 support in the kernel. The
tests are repeated again with this variable set.

https://bugzilla.redhat.com/show_bug.cgi?id=1025407

11 years agoSplit out bind() from virPortAllocatorAcquire
Ján Tomko [Thu, 31 Oct 2013 14:14:15 +0000 (15:14 +0100)]
Split out bind() from virPortAllocatorAcquire

11 years agostorage: gluster: Don't leak private data when storage file init fails
Peter Krempa [Fri, 14 Feb 2014 12:08:39 +0000 (13:08 +0100)]
storage: gluster: Don't leak private data when storage file init fails

In a44b7b87bcc6681e2939f65a3552fc96f68bc7b6 I've introduced a function
that initializes a storage file wrapper object on gluster based volumes.

The initialization function leaks the private data pointer in case of
failure. This patch fixes it.

Reported by John Ferlan.

11 years agostorage: Fix build with older compilers afeter gluster snapshot series
Peter Krempa [Fri, 14 Feb 2014 10:46:37 +0000 (11:46 +0100)]
storage: Fix build with older compilers afeter gluster snapshot series

In commit e32268184b4fd1611ed5ffd3c758b8f6a34152e6 I accidentally added
twice a typedef for virStorageFileBackend when I moved it between files
across patch iterations. The double declaration breaks build on older
compilers in RHEL5 and FreeBSD.

Remove the spurious definition.

11 years agoqemu: snapshot: Add support for external active snapshots on gluster
Peter Krempa [Mon, 25 Nov 2013 17:56:24 +0000 (18:56 +0100)]
qemu: snapshot: Add support for external active snapshots on gluster

Add support for gluster backed images as sources for snapshots in the
qemu driver. This will also simplify adding further network backed
volumes as sources for snapshot in case qemu will support them.

11 years agoqemu: snapshot: Use new APIs to detect presence of existing storage files
Peter Krempa [Tue, 11 Feb 2014 16:18:35 +0000 (17:18 +0100)]
qemu: snapshot: Use new APIs to detect presence of existing storage files

Use the new storage driver based "stat" api to detect exiting files just
as we did with local files.

11 years agoqemu: Switch snapshot deletion to the new API functions
Peter Krempa [Fri, 31 Jan 2014 13:26:32 +0000 (14:26 +0100)]
qemu: Switch snapshot deletion to the new API functions

Use the new storage driver APIs to delete snapshot backing files in case
of failure instead of directly relying on "unlink". This will help us in
the future when we will be adding network based storage without local
representation in the host.

11 years agostorage: Add storage file backends for gluster
Peter Krempa [Mon, 3 Feb 2014 16:18:24 +0000 (17:18 +0100)]
storage: Add storage file backends for gluster

Implement storage backend functions to deal with gluster volumes and
implement the "stat" and "unlink" backend APIs.

11 years agostorage: add file functions for local and block files
Peter Krempa [Mon, 3 Feb 2014 15:41:49 +0000 (16:41 +0100)]
storage: add file functions for local and block files

Implement the "stat" and "unlink" function for "file" volumes and "stat"
for "block" volumes using the regular system calls.

11 years agostorage: Add file storage APIs in the default storage driver
Peter Krempa [Mon, 3 Feb 2014 15:12:57 +0000 (16:12 +0100)]
storage: Add file storage APIs in the default storage driver

Add APIs that will allow to use the storage driver to assist in
operations on files even for remote filesystems without native
representation as files in the host.

11 years agoconf: Move qemuSnapshotDiskGetActualType to virDomainSnapshotDiskGetActualType
Peter Krempa [Thu, 13 Feb 2014 09:41:01 +0000 (10:41 +0100)]
conf: Move qemuSnapshotDiskGetActualType to virDomainSnapshotDiskGetActualType

All the data for getting the actual type is present in the snapshot
config. There is no need to have this function private to the qemu
driver and it will be re-used later in other parts of libvirt

11 years agoconf: Move qemuDiskGetActualType to virDomainDiskGetActualType
Peter Krempa [Thu, 13 Feb 2014 09:41:01 +0000 (10:41 +0100)]
conf: Move qemuDiskGetActualType to virDomainDiskGetActualType

All the data for getting the actual type is present in the domain
config. There is no need to have this function private to the qemu
driver and it will be re-used later in other parts of libvirt

11 years agospec: add missing dep of libvirt-daemon-config-nwfilter
Eric Blake [Wed, 12 Feb 2014 21:33:16 +0000 (14:33 -0700)]
spec: add missing dep of libvirt-daemon-config-nwfilter

Similar to cf76c4b, if modules are used, then nwfilter configuration
requires the nwfilter driver module.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRevert "spec: require libvirt-wireshark from libvirt metapackage"
Eric Blake [Thu, 13 Feb 2014 13:34:14 +0000 (06:34 -0700)]
Revert "spec: require libvirt-wireshark from libvirt metapackage"

This reverts commit 8d6c3659b8c9b861b00a19b26079d11d56dce680.

After further list discussion, it was decided that pulling in
wireshark as a dependency is a bit too much for the base 'libvirt'
package.  Remember also that 'libvirt-devel' is also not pulled in
by the base 'libvirt' - the metapackage exists for full
functionality of libvirtd, rather than to pull in all subpackages.

11 years agolxc from native: removed now remaining useless line
Cédric Bosdonnat [Thu, 13 Feb 2014 12:45:44 +0000 (13:45 +0100)]
lxc from native: removed now remaining useless line

11 years agoFix stream related spelling mistakes
Philipp Hahn [Thu, 13 Feb 2014 08:41:54 +0000 (09:41 +0100)]
Fix stream related spelling mistakes

Remove double "is".
Consistent spelling of all-uppercase I/O.

Signed-off-by: Philipp Hahn <hahn@univention.de>
11 years agospec: require libvirt-wireshark from libvirt metapackage
Eric Blake [Wed, 12 Feb 2014 20:27:38 +0000 (13:27 -0700)]
spec: require libvirt-wireshark from libvirt metapackage

In general, the 'libvirt' metapackage should pull in all subpackages.
Fix this for the wireshark subpackage created in commit f9ada9f.

* libvirt.spec.in (Requires): Add dependency.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: add missing dep of libvirt-daemon-config-network
Thierry Parmentelat [Tue, 11 Feb 2014 10:35:20 +0000 (11:35 +0100)]
spec: add missing dep of libvirt-daemon-config-network

When building modules, libvirt-daemon-config-network requires
libvirt-daemon-driver-network to ensure the 'default' network
is setup properly

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: require libvirt-daemon-driver-interface only when built
Thierry Parmentelat [Mon, 10 Feb 2014 09:54:30 +0000 (10:54 +0100)]
spec: require libvirt-daemon-driver-interface only when built

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC from native: convert blkio throttle config
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:17 +0000 (15:10 +0100)]
LXC from native: convert blkio throttle config

11 years agoLXC: added some doc on domxml-from-native with mention of limitations
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:16 +0000 (15:10 +0100)]
LXC: added some doc on domxml-from-native with mention of limitations

11 years agoLXC from native: map vlan network type
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:15 +0000 (15:10 +0100)]
LXC from native: map vlan network type

The problem with VLAN is that the user still has to manually create the
vlan interface on the host. Then the generated configuration will use
it as a nerwork hostdev device. So the generated configurations of the
following two fragments are equivalent (see rhbz#1059637).

lxc.network.type = phys
lxc.network.link = eth0.5

lxc.network.type = vlan
lxc.network.link = eth0
lxc.network.vlan.id = 5

11 years agoLXC from native: map block filesystems
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:14 +0000 (15:10 +0100)]
LXC from native: map block filesystems

11 years agoLXC from native: map lxc.arch to /domain/os/type@arch
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:13 +0000 (15:10 +0100)]
LXC from native: map lxc.arch to /domain/os/type@arch

11 years agoLXC from native: add lxc.cgroup.blkio.* mapping
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:12 +0000 (15:10 +0100)]
LXC from native: add lxc.cgroup.blkio.* mapping

11 years agoLXC from native: map lxc.cgroup.cpuset.*
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:11 +0000 (15:10 +0100)]
LXC from native: map lxc.cgroup.cpuset.*

11 years agoLXC from native: map lxc.cgroup.cpu.*
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:10 +0000 (15:10 +0100)]
LXC from native: map lxc.cgroup.cpu.*

11 years agoLXC from native: migrate memory tuning
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:09 +0000 (15:10 +0100)]
LXC from native: migrate memory tuning

11 years agoLXC from native: convert lxc.id_map into <idmap>
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:08 +0000 (15:10 +0100)]
LXC from native: convert lxc.id_map into <idmap>

11 years agoLXC from native: convert macvlan network configuration
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:07 +0000 (15:10 +0100)]
LXC from native: convert macvlan network configuration

11 years agoLXC from native: convert lxc.tty to console devices
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:06 +0000 (15:10 +0100)]
LXC from native: convert lxc.tty to console devices

11 years agoLXC from native: convert phys network types to net hostdev devices
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:05 +0000 (15:10 +0100)]
LXC from native: convert phys network types to net hostdev devices

11 years agoLXC from native: migrate veth network configuration
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:04 +0000 (15:10 +0100)]
LXC from native: migrate veth network configuration

Some of the LXC configuration properties aren't migrated since they
would only cause problems in libvirt-lxc:
  * lxc.network.ipv[46]: LXC driver doesn't setup IP address of guests,
    see rhbz#1059624
  * lxc.network.name, see rhbz#1059630

11 years agoLXC from native: implement no network conversion
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:03 +0000 (15:10 +0100)]
LXC from native: implement no network conversion

If no network configuration is provided, LXC only provides the loopback
interface. To match this, we need to use the privnet feature. LXC will
also define a 'none' network type in its 1.0.0 version that fits
libvirt LXC driver's default.

11 years agoLXC from native: migrate fstab and lxc.mount.entry
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:02 +0000 (15:10 +0100)]
LXC from native: migrate fstab and lxc.mount.entry

Tmpfs relative size and default 50% size values aren't supported as
we have no idea of the available memory at the conversion time.

11 years agoLXC from native: import rootfs
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:01 +0000 (15:10 +0100)]
LXC from native: import rootfs

LXC rootfs can be either a directory or a block device or an image
file. The first two types have been implemented, but the image file is
still to be done since LXC auto-guesses the file format at mount time
and the LXC driver doesn't support the 'auto' format.

11 years agoLXC driver: started implementing connectDomainXMLFromNative
Cédric Bosdonnat [Wed, 5 Feb 2014 14:10:00 +0000 (15:10 +0100)]
LXC driver: started implementing connectDomainXMLFromNative

This function aims at converting LXC configuration into a libvirt
domain XML description to help users migrate from LXC to libvirt.

Here is an example of how the lxc configuration works:
virsh -c lxc:/// domxml-from-native lxc-tools /var/lib/lxc/migrate_test/config

It is possible that some parts couldn't be properly mapped into a
domain XML fragment, so users should carefully review the result
before creating the domain.

fstab files in lxc.mount lines will need to be merged into the
configuration file as lxc.mount.entry.

As we can't know the amount of memory of the host, we have to set a
default value for max_balloon that users will probably want to adjust.

11 years agoImprove virConf parse to handle LXC config format
Cédric Bosdonnat [Wed, 5 Feb 2014 14:09:59 +0000 (15:09 +0100)]
Improve virConf parse to handle LXC config format

virConf now honours a VIR_CONF_FLAG_LXC_FORMAT flag to handle LXC
configuration files. The differences are that property names can
contain '.' character and values are all strings without any bounding
quotes.

Provide a new virConfWalk function calling a handler on all non-comment
values. This function will be used by the LXC conversion code to loop
over LXC configuration lines.

11 years agoevent: pass reason for PM events
Eric Blake [Wed, 29 Jan 2014 00:41:34 +0000 (17:41 -0700)]
event: pass reason for PM events

Commit 57ddcc23 (v0.9.11) introduced the pmwakeup event, with
an optional 'reason' field reserved for possible future expansion.
But it failed to wire the field through RPC, so even if we do
add a reason in the future, we will be unable to get it back
to the user.

Worse, commit 7ba5defb (v1.0.0) repeated the same mistake with
the pmsuspend_disk event.

As long as we are adding new RPC calls, we might as well fix
the events to actually match the signature so that we don't have
to add yet another RPC in the future if we do decide to start
using the reason field.

* src/remote/remote_protocol.x
(remote_domain_event_callback_pmwakeup_msg)
(remote_domain_event_callback_pmsuspend_msg)
(remote_domain_event_callback_pmsuspend_disk_msg): Add reason
field.
* daemon/remote.c (remoteRelayDomainEventPMWakeup)
(remoteRelayDomainEventPMSuspend)
(remoteRelayDomainEventPMSuspendDisk): Pass reason to client.
* src/conf/domain_event.h (virDomainEventPMWakeupNewFromDom)
(virDomainEventPMSuspendNewFromDom)
(virDomainEventPMSuspendDiskNewFromDom): Require additional
parameter.
* src/conf/domain_event.c (virDomainEventPMClass): New class.
(virDomainEventPMDispose): New function.
(virDomainEventPMWakeupNew*, virDomainEventPMSuspendNew*)
(virDomainEventPMSuspendDiskNew*)
(virDomainEventDispatchDefaultFunc): Use new class.
* src/remote/remote_driver.c (remoteDomainBuildEvent*PM*): Pass
reason through.
* src/remote_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: convert remaining domain events to new style
Eric Blake [Thu, 9 Jan 2014 18:22:53 +0000 (11:22 -0700)]
event: convert remaining domain events to new style

Following the patterns established by lifecycle events, this
creates all the new RPC calls needed to pass callback IDs
for every domain event, and changes the limits in client and
server codes to use modern style when possible.

I've tested all combinations: both 'old client and new server'
and 'new client and old server' continue to work with the old
RPCs, and 'new client and new server' benefit from server-side
filtering with the new RPCs.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_EVENT_*): Add
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_* counterparts.
* daemon/remote.c (remoteRelayDomainEvent*): Send callbackID via
newer RPC when used with new-style registration.
(remoteDispatchConnectDomainEventCallbackRegisterAny): Extend to
cover all domain events.
* src/remote/remote_driver.c (remoteDomainBuildEvent*): Add new
Callback and Helper functions.
(remoteEvents): Match order of RPC numbers, register new handlers.
(remoteConnectDomainEventRegisterAny)
(remoteConnectDomainEventDeregisterAny): Extend to cover all
domain events.
* src/remote_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: client RPC protocol tweaks for domain lifecycle events
Eric Blake [Wed, 8 Jan 2014 14:57:25 +0000 (07:57 -0700)]
event: client RPC protocol tweaks for domain lifecycle events

The counterpart to the server RPC additions; here, a single
function can serve both old and new calls, while incoming
events must be serviced by two different functions.  Again,
some wise choices in our XDR made it easier to share code
managing similar events.

While this only supports lifecycle events, it covers the
harder part of how Register and RegisterAny interact; the
remaining 15 events will be a mechanical change in a later
patch.  For Register, we now have a callbackID locally for
more efficient cleanup if the RPC fails; we also prefer to
use the newer RPC where we know it is supported (the older
RPC must be used if we don't know if RegisterAny is
supported).

* src/remote/remote_driver.c (remoteEvents): Register new RPC
event handler.
(remoteDomainBuildEventLifecycle): Move guts...
(remoteDomainBuildEventLifecycleHelper): ...here.
(remoteDomainBuildEventCallbackLifecycle): New function.
(remoteConnectDomainEventRegister)
(remoteConnectDomainEventDeregister)
(remoteConnectDomainEventRegisterAny)
(remoteConnectDomainEventDeregisterAny): Use new RPC when supported.

11 years agoevent: prepare client to track domain callbackID
Eric Blake [Wed, 8 Jan 2014 04:00:54 +0000 (21:00 -0700)]
event: prepare client to track domain callbackID

We want to convert over to server-side events, even for older
APIs.  To do that, the client side of the remote driver wants
to distinguish between legacy virConnectDomainEventRegister and
normal virConnectDomainEventRegisterAny, while knowing the
client callbackID and the server's serverID for both types of
registration.  The client also needs to probe whether the
server supports server-side filtering.  However, for ease of
review, we don't actually use the new RPCs until a later patch.

* src/conf/object_event_private.h (virObjectEventStateCallbackID):
Add parameter.
* src/conf/object_event.c (virObjectEventCallbackListAddID)
(virObjectEventStateRegisterID): Separate legacy from callbackID.
(virObjectEventStateCallbackID): Pass through parameter.
(virObjectEventCallbackLookup): Let legacy and global domain
lifecycle events share a common remoteID.
* src/conf/network_event.c (virNetworkEventStateRegisterID):
Update caller.
* src/conf/domain_event.c (virDomainEventStateRegister)
(virDomainEventStateRegisterID, virDomainEventStateDeregister):
Likewise.
(virDomainEventStateRegisterClient)
(virDomainEventStateCallbackID): Implement new functions.
* src/conf/domain_event.h (virDomainEventStateRegisterClient)
(virDomainEventStateCallbackID): New prototypes.
* src/remote/remote_driver.c (private_data): Add field.
(doRemoteOpen): Probe server feature.
(remoteConnectDomainEventRegister)
(remoteConnectDomainEventRegisterAny): Use new function.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: server RPC protocol tweaks for domain lifecycle events
Eric Blake [Wed, 8 Jan 2014 20:59:35 +0000 (13:59 -0700)]
event: server RPC protocol tweaks for domain lifecycle events

This patch adds some new RPC call numbers, but for ease of review,
they sit idle until a later patch adds the client counterpart to
drive the new RPCs.  Also for ease of review, I limited this patch
to just the lifecycle event; although converting the remaining
15 domain events will be quite mechanical.  On the server side,
we have to have a function per RPC call, largely with duplicated
bodies (the key difference being that we store in our callback
opaque pointer whether events should be fired with old or new
style); meanwhile, a single function can drive multiple RPC
messages.  With a strategic choice of XDR struct layout, we can
make the event generation code for both styles fairly compact.

I debated about adding a tri-state witness variable per
connection (values 'unknown', 'legacy', 'modern').  It would start
as 'unknown', move to 'legacy' if any RPC call is made to a legacy
event call, and move to 'modern' if the feature probe is made;
then the event code could issue an error if the witness state is
incorrect (a legacy RPC call while in 'modern', a modern RPC call
while in 'unknown' or 'legacy', and a feature probe while in
'legacy' or 'modern').  But while it might prevent odd behavior
caused by protocol fuzzing, I don't see that it would prevent
any security holes, so I considered it bloat.

Note that sticking @acl markers on the new RPCs generates unused
functions in access/viraccessapicheck.c, because there is no new
API call that needs to use the new checks; however, having a
consistent .x file is worth the dead code.

* src/libvirt_internal.h (VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK):
New feature.
* src/remote/remote_protocol.x
(REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_REGISTER_ANY)
(REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_DEREGISTER_ANY)
(REMOTE_PROC_DOMAIN_EVENT_CALLBACK_LIFECYCLE): New RPCs.
* daemon/remote.c (daemonClientCallback): Add field.
(remoteDispatchConnectDomainEventCallbackRegisterAny)
(remoteDispatchConnectDomainEventCallbackDeregisterAny): New
functions.
(remoteDispatchConnectDomainEventRegisterAny)
(remoteDispatchConnectDomainEventDeregisterAny): Mark legacy use.
(remoteRelayDomainEventLifecycle): Change message based on legacy
or new use.
(remoteDispatchConnectSupportsFeature): Advertise new feature.
* src/remote_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: dynamically manage server-side RPC domain events
Eric Blake [Mon, 6 Jan 2014 00:23:55 +0000 (17:23 -0700)]
event: dynamically manage server-side RPC domain events

This patch continues the earlier conversion made for network
events, with a goal of introducing server-side event filtering
in a later patch.  Actual behavior is unchanged without
further RPC changes.

* daemon/libvirtd.h (daemonClientPrivate): Alter the tracking of
domain events.
* daemon/remote.c (remoteClientInitHook, remoteClientFreeFunc)
(remoteRelayDomainEvent*)
(remoteDispatchConnectDomainEventRegister)
(remoteDispatchConnectDomainEventRegisterAny): Track domain
callbacks dynamically.

11 years agostorage: handle NULL return from virGetStorageVol
Michael Chapman [Wed, 12 Feb 2014 11:05:51 +0000 (22:05 +1100)]
storage: handle NULL return from virGetStorageVol

virGetStorageVol can return NULL on out-of-memory. If it does, cleanly
abort the volume clone operation.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
11 years agoRevert "storage: disk: Separate creating of the volume from building"
Ján Tomko [Wed, 12 Feb 2014 13:54:05 +0000 (14:54 +0100)]
Revert "storage: disk: Separate creating of the volume from building"

This reverts commit 67ccf91bf29488783bd1fda46b362450f71a2078.
We only generate the volume key after we've built it, but the storage
driver expects it to be filled after createVol finishes.
Squash the volume building back with creating to fulfill this
expectation.

11 years agoRevert "storage: lvm: Separate creating of the volume from building"
Ján Tomko [Wed, 12 Feb 2014 13:23:30 +0000 (14:23 +0100)]
Revert "storage: lvm: Separate creating of the volume from building"

This reverts commit af1fb38f55d4fb87e0fcaee1e973fa9c6713b1e6.
With it, creating new logical volumes fails:
https://www.redhat.com/archives/libvir-list/2014-February/msg00658.html

In the storage driver, we expect CreateVol to fill out the volume key,
but the LVM backend fills the key with the uuid reported by lvs after the
logical volume is created.

11 years agoFix leaks in vircapstest
Ján Tomko [Wed, 12 Feb 2014 09:29:18 +0000 (10:29 +0100)]
Fix leaks in vircapstest

Coverity complains about cell_cpus being leaked on error
and valgrind shows 'caps' is leaked on success.

Introduced in eb64e87.

11 years agoFixed build with clang.
Cédric Bosdonnat [Wed, 12 Feb 2014 10:36:06 +0000 (11:36 +0100)]
Fixed build with clang.

Two unused global variables, and DBUS_TYPE_INVALID used as a const
char*.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAppArmor: Fix the place where the template should be installed
Cédric Bosdonnat [Wed, 12 Feb 2014 09:41:17 +0000 (10:41 +0100)]
AppArmor: Fix the place where the template should be installed

The security driver expects /etc/apparmor.d/libvirt/TEMPLATE but we
installed it to /etc/apparmor.d/libvirtd/TEMPLATE. Move the template to
the expected place since that code was here long before.

11 years agoqemu: Implement a stub cpuArchDriver.baseline() handler for aarch64
Oleg Strikov [Tue, 11 Feb 2014 15:51:41 +0000 (19:51 +0400)]
qemu: Implement a stub cpuArchDriver.baseline() handler for aarch64

Openstack Nova calls virConnectBaselineCPU() during initialization
of the instance to get a full list of CPU features.
This patch adds a stub to aarch64-specific code to handle
this request (no actual work is done). That's enough to have
this stub with limited functionality because qemu/kvm backend
supports only 'host-passthrough' cpu mode on aarch64.

Signed-off-by: Oleg Strikov <oleg.strikov@canonical.com>
11 years agolibxl: fix libxlDoDomainSave documentation
Jim Fehlig [Fri, 7 Feb 2014 01:02:06 +0000 (18:02 -0700)]
libxl: fix libxlDoDomainSave documentation

Update the function's comment, which was missed when removing use of
the driver lock everywhere.

11 years agolibxl: register for domain events immediately after creation
Jim Fehlig [Thu, 6 Feb 2014 21:36:49 +0000 (14:36 -0700)]
libxl: register for domain events immediately after creation

A small fix for the possiblitiy of jumping to an error path before
registering for domain events, preventing receiving important ones
like shutdown and death.

11 years agolibxl: rename libxlCreateDomEvents to libxlDomEventsRegister
Jim Fehlig [Thu, 6 Feb 2014 21:29:19 +0000 (14:29 -0700)]
libxl: rename libxlCreateDomEvents to libxlDomEventsRegister

libxlDomEventsRegister better reflects its purpose: register for
domain events from libxl.

11 years agoRename 'index' in virCapabilitiesGetCpusForNode
Ján Tomko [Tue, 11 Feb 2014 15:35:33 +0000 (16:35 +0100)]
Rename 'index' in virCapabilitiesGetCpusForNode

This shadows the index function on some systems (RHEL-6.4, FreeBSD 9):
../../src/conf/capabilities.c: In function 'virCapabilitiesGetCpusForNode':
../../src/conf/capabilities.c:1005: warning: declaration of'index'
      shadows a global declaration [-Wshadow]
/usr/include/strings.h:57: warning: shadowed declaration is here [-Wshadow]

11 years agovircapstest: Introduce virCapabilitiesGetCpusForNodemask test
Pradipta Kr. Banerjee [Tue, 11 Feb 2014 14:36:21 +0000 (14:36 +0000)]
vircapstest: Introduce virCapabilitiesGetCpusForNodemask test

This test creates a Fake NUMA topology with non-sequential cell ids
to check if libvirt properly handles the same

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
11 years agoHandle non-sequential NUMA node numbers
Pradipta Kr. Banerjee [Tue, 11 Feb 2014 14:32:50 +0000 (14:32 +0000)]
Handle non-sequential NUMA node numbers

On some platforms like IBM PowerNV the NUMA node numbers can be
non-sequential. For eg. numactl --hardware o/p from such a machine looks
as given below

node distances:
   node   0   1  16  17
     0:  10  40  40  40
     1:  40  10  40  40
    16:  40  40  10  40
    17:  40  40  40  10

The NUMA nodes are 0,1,16,17

Libvirt uses sequential index as NUMA node numbers and this can
result in crash or incorrect results.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
11 years agostorage: gluster: Set volume metadata in a separate function
Peter Krempa [Wed, 29 Jan 2014 12:17:12 +0000 (13:17 +0100)]
storage: gluster: Set volume metadata in a separate function

Extract the metadata setting code into a separate function for future
use.

11 years agoqemu: introduce spiceport chardev backend
Martin Kletzander [Thu, 30 Jan 2014 11:19:12 +0000 (12:19 +0100)]
qemu: introduce spiceport chardev backend

Add a new backend for any character device.  This backend uses channel
in spice connection.  This channel is similar to spicevmc, but
all-purpose in contrast to spicevmc.

Apart from spicevmc, spiceport-backed chardev will not be formatted
into the command-line if there is no spice to use (with test for that
as well).  For this I moved the def->graphics counting to the start
of the function so its results can be used in rest of the code even in
the future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoqemu: remove pointless condition
Martin Kletzander [Mon, 10 Feb 2014 10:45:28 +0000 (11:45 +0100)]
qemu: remove pointless condition

This patch is here just to ease the code review and make related
changes look more sensible.  Apart from removing the condition this is
merely a whitespace (indentation) change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoqemu: rework '-serial none'
Martin Kletzander [Mon, 10 Feb 2014 10:33:19 +0000 (11:33 +0100)]
qemu: rework '-serial none'

Limiting ourselves to qemu without QEMU_CAPS_DEVICE capability, we
used '-serial none' only if there was no serial device defined in the
domain XML.  This means that if we want to have a possibility of the
device being defined in XML, but not used in the command-line
(e.g. when it's pointless), we'll fail to attach '-serial none' to the
command-line (when skipping the device's command-line building and the
device being the only one).

Since there is no such device, this patch doesn't actually do
anything, but enables easier future additions in this manner.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoconf: introduce spiceport chardev backend
Martin Kletzander [Mon, 10 Feb 2014 10:18:16 +0000 (11:18 +0100)]
conf: introduce spiceport chardev backend

Add a new character device backend called 'spiceport' that uses
spice's channel for communications and apart from spicevmc can be used
as a backend for any character device from libvirt's point of view.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agorbd: Use rbd_create3 to create RBD format 2 images by default
Wido den Hollander [Tue, 11 Feb 2014 12:10:22 +0000 (12:10 +0000)]
rbd: Use rbd_create3 to create RBD format 2 images by default

This new RBD format supports snapshotting and cloning. By having
libvirt create images in format 2 end-users of the created images
can benefit from the new RBD format.

Older versions of libvirt can work with this new RBD format as long
as librbd supports format 2. RBD format is supported by librbd since
version 0.56 (Ceph Bobtail).

Signed-off-by: Wido den Hollander <wido@widodh.nl>
11 years agoLibvirt lose sheepdogs volumes on pool refresh or restart.
Joel SIMOES [Tue, 11 Feb 2014 11:25:33 +0000 (11:25 +0000)]
Libvirt lose sheepdogs volumes on pool refresh or restart.
When restarting sheepdog pool, all volumes are missing.
This patch add automatically all volume from the added pool.

Adding last Daniel P. Berrange's syntaxes correction.
Adding vol on separeted function 'inspired' from parallels_storage :
parallelsAddDiskVolume

11 years agobuild: correctly check for SOICGIFVLAN GET_VLAN_VID_CMD command
Laine Stump [Mon, 10 Feb 2014 14:08:26 +0000 (16:08 +0200)]
build: correctly check for SOICGIFVLAN GET_VLAN_VID_CMD command

In order to make a client-only build successful on RHEL4 (yes, you
read that correctly!), commit 3ed2e54 modified src/util/virnetdev.c so
that the functional version of virNetDevGetVLanID() was only compiled
if GET_VLAN_VID_CMD was defined. However, it is *never* defined, but
is only an enum value, so the proper version was no longer compiled
even on platforms that support it. This resulted in the vlan tag not
being properly set for guest traffic on VEPA mode guest macvtap
interfaces that were bound to a vlan interface (that's the only place
that libvirt currently uses virNetDevGetVLanID)

Since there is no way to compile conditionally based on the presence
of an enum value, this patch modifies configure.ac to check for said
enum value with AC_CHECK_DECLS(), which #defines
HAVE_DECL_GET_VLAN_VID_CMD to 1 if it's successful compiling a test
program that uses GET_VLAN_VID_CMD (and still #defines it, but to 0,
if it's not successful).  We can then make the compilation of
virNetDevGetVLanID() conditional on the value of
HAVE_DECL_GET_VLAN_VID_CMD.

11 years agodocs: grammar fixes in formatdomain
Chen Hanxiao [Mon, 10 Feb 2014 02:37:35 +0000 (10:37 +0800)]
docs: grammar fixes in formatdomain

Some grammar fixes.

s/namespace,set/namespace, set
s/container being allowed/container are allowed
s/the <code>uid/The <code>uid

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agomaint: fix line numbers in check-aclrules reports
Yuri Myasoedov [Sun, 9 Feb 2014 20:10:35 +0000 (00:10 +0400)]
maint: fix line numbers in check-aclrules reports

Reset line numbering on each input file in check-aclrules.pl. Otherwise
it reports wrong line numbers in its error messages.

Signed-off-by: Yuri Myasoedov <ymyasoedov@yandex.ru>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirNetworkLoadState: Disallow mangled 'floor' element
Michal Privoznik [Mon, 10 Feb 2014 18:26:16 +0000 (19:26 +0100)]
virNetworkLoadState: Disallow mangled 'floor' element

In the network status XML we may have the <floor/> element with the
'sum' attribute. The attribute represents sum of all 'floor'-s of
computed over each interface connected to the network (this is needed to
guarantee certain bandwidth for certain domain). The sum is therefore a
number. However, if the number was mangled (e.g. by an user's
interference to network status file), we've just ignored it without
refusing to parse such file. This was all due to 'goto error' missing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: Use correct permissions when determining the image chain
Peter Krempa [Fri, 7 Feb 2014 17:42:27 +0000 (18:42 +0100)]
qemu: Use correct permissions when determining the image chain

The code took into account only the global permissions. The domains now
support per-vm DAC labels and per-image DAC labels. Use the most
specific label available.

11 years agonetworkStartNetwork: Be more verbose
Michal Privoznik [Fri, 31 Jan 2014 14:36:13 +0000 (15:36 +0100)]
networkStartNetwork: Be more verbose

The lack of debug printings might be frustrating in the future.
Moreover, this function doesn't follow the usual pattern we have in the
rest of the code:

  int ret = -1;
  /* do some work */
  ret = 0;
cleanup:
  /* some cleanup work */
  return ret;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: hyperv: Add support for timer enlightenments
Peter Krempa [Tue, 21 Jan 2014 17:50:12 +0000 (18:50 +0100)]
qemu: hyperv: Add support for timer enlightenments

Add a new <timer> for the HyperV reference time counter enlightenment
and the iTSC reference page for Windows guests.

This feature provides a paravirtual approach to track timer events for
the guest (similar to kvmclock) with the option to use real hardware
clock on systems with a iTSC with compensation across various hosts.

11 years agoconf: Enforce supported options for certain timers
Peter Krempa [Wed, 5 Feb 2014 09:10:14 +0000 (10:10 +0100)]
conf: Enforce supported options for certain timers

According to the documentation various timer options are only supported
by certain timer types. Add a post parse check to verify that the user
didn't specify invalid options.

Also fix the qemu command line parsing function to set correct default
values for the kvmclock timer so that it passes the new check.

11 years agoschema: Fix guest timer specification schema according to the docs
Peter Krempa [Tue, 4 Feb 2014 18:02:04 +0000 (19:02 +0100)]
schema: Fix guest timer specification schema according to the docs

According to the documentation describing various tunables for domain
timers not all the fields are supported by all the driver types. Express
these in the RNG:

- rtc, platform: Only these support the "track" attribute.
- tsc: only one to support "frequency" and "mode" attributes
- hpet, pit: tickpolicy/catchup attribute/element
- kvmclock: no extra attributes are supported

Additionally the attributes of the <catchup> element for
tickpolicy='catchup' are optional according to the parsing code. Express
this in the XML and fix a spurious space added while formatting the
<catchup> element and add tests for it.

11 years agoapparmor: Improve profiles
Felix Geyer [Sun, 26 Jan 2014 21:47:35 +0000 (22:47 +0100)]
apparmor: Improve profiles

Tested on Debian unstable.
The profile updates are partly taken from the Ubuntu trusty libvirt package.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
11 years agovirpci: Resolve coverity issues
John Ferlan [Thu, 6 Feb 2014 17:30:57 +0000 (12:30 -0500)]
virpci: Resolve coverity issues

Coverity complains about "USE_AFTER_FREE" due to how virPCIDeviceSetStubDriver
"could" return either -1, 0, or 1 from the VIR_STRDUP() and then possibly makes
a call to virPCIDeviceDetach().

The only way this could happen is if NULL were passed as the "driver" name
and virStrdup() returned 0.  Since the calling functions check < 0 on the
initial function call, the 0 possibility causes Coverity to complain.

To fix this - enforce that the second parameter is not NULL using
ATTRIBUTE_NONNULL(2) for the function prototype, then in virPCIDeviceDetach
add an sa_assert(dev->stubDriver). This will result in Coverity not complaining
any more.

11 years agoAdd glusterfs to VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE
Christophe Fergeau [Thu, 6 Feb 2014 15:12:14 +0000 (16:12 +0100)]
Add glusterfs to VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE

If it's not present in this list, we won't be able to get only
glusterfs pools when using virConnectListAllStoragePools.

11 years agobuild-sys: Removed unused variable from configure.ac
Christophe Fergeau [Thu, 6 Feb 2014 15:09:20 +0000 (16:09 +0100)]
build-sys: Removed unused variable from configure.ac

LIBGLUSTER_LIBS is emptied before gluster is enabled/disabled, but nothing
else sets/uses this variable, so it can be removed.

11 years agoqemu: keep pre-migration domain state after failed migration
Martin Kletzander [Thu, 6 Feb 2014 13:30:59 +0000 (14:30 +0100)]
qemu: keep pre-migration domain state after failed migration

Couple of codepaths shared the same code which can be moved out to a
function and on one of such places, qemuMigrationConfirmPhase(), the
domain was resumed even if it wasn't running before the migration
started.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1057407

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agolibxl: remove unneeded locking of driver when restoring
Jim Fehlig [Wed, 5 Feb 2014 19:50:52 +0000 (12:50 -0700)]
libxl: remove unneeded locking of driver when restoring

libxlDomainRestoreFlags acquires the driver lock while reading the
domain config from the save file and adding it to
libxlDriverPrivatePtr->domains.  But virDomainObjList provides
self-locking APIs, so remove the needless driver locking.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: improve subprocess handling
Jim Fehlig [Thu, 16 Jan 2014 23:16:37 +0000 (23:16 +0000)]
libxl: improve subprocess handling

If available, let libxl handle reaping any children it creates by
specifying libxl_sigchld_owner_libxl_always_selective_reap.  This
feature was added to improve subprocess handling in libxl when used
in an application that does not install a SIGCHLD handler like
libvirt

http://lists.xen.org/archives/html/xen-devel/2014-01/msg01555.html

Prior to this patch, it is possible to hit asserts in libxl when
reaping subprocesses, particularly during simultaneous operations
on multiple domains.  With this patch, and the corresponding changes
to libxl, I no longer see the asserts.  Note that the libxl changes
will be included in Xen 4.4.0.  Previous Xen versions will be
susceptible to hitting the asserts even with this patch applied to
the libvirt libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: handle domain shutdown events in a thread
Jim Fehlig [Sat, 1 Feb 2014 06:06:35 +0000 (23:06 -0700)]
libxl: handle domain shutdown events in a thread

Handling the domain shutdown event within the event handler seems
a bit unfair to libxl's event machinery.  Domain "shutdown" could
take considerable time.  E.g. if the shutdown reason is reboot,
the domain must be reaped and then started again.

Spawn a shutdown handler thread to do this work, allowing libxl's
event machinery to go about its business.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: remove list of timer registrations from libxlDomainObjPrivate
Jim Fehlig [Sat, 1 Feb 2014 01:09:53 +0000 (18:09 -0700)]
libxl: remove list of timer registrations from libxlDomainObjPrivate

Due to some misunderstanding of requirements libxl places on timer
handling, I introduced the half-brained idea of maintaining a list
of timeouts that the driver could force to expire before freeing a
libxlDomainObjPrivate (and hence libxl_ctx).  But testing all
the latest versions of Xen supported by the libxl driver (4.2.3,
4.3.1, 4.4.0 RC3), I see that libxl will handle this just fine and
there is no need to force expiration behind libxl's back.  Indeed it
may be harmful to do so.

This patch removes the timer list, allowing libxl to handle cleanup
of its timer registrations.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: fix leaking libxlDomainObjPrivate
Jim Fehlig [Fri, 31 Jan 2014 23:57:09 +0000 (16:57 -0700)]
libxl: fix leaking libxlDomainObjPrivate

When libxl registers an FD with the libxl driver, the refcnt of the
associated libxlDomainObjPrivate object is incremented. The refcnt
is decremented when libxl deregisters the FD.  But some FDs are only
deregistered when their libxl ctx is freed, which unfortunately is
done in the libxlDomainObjPrivate dispose function.  With references
held by the FDs, libxlDomainObjPrivate is never disposed.

I added the ref/unref in FD registration/deregistration when adding
the same in timer registration/deregistration.  For timers, this
is a simple approach to ensuring the libxlDomainObjPrivate is not
disposed prior to their expirtation, which libxl guarantees will
occur.  It is not needed for FDs, and only causes
libxlDomainObjPrivate to leak.

This patch removes the reference on libxlDomainObjPrivate for FD
registrations, but retains them for timer registrations.  Tested on
the latest releases of Xen supported by the libxl driver:  4.2.3,
4.3.1, and 4.4.0 RC3.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agoqemu_driver: Introduce <filesystem/> support in device attach/detach
Matthieu Coudron [Thu, 6 Feb 2014 14:30:07 +0000 (15:30 +0100)]
qemu_driver: Introduce <filesystem/> support in device attach/detach

This commit allows to attach/detach a <filesystem> device in qemu. For
this purpose I'm introducing two new functions: virDomainFSInsert() and
virDomainFSRemove() and adding necessary code in the qemu driver.  It
compares filesystems based on their "destination" folder. So if two
filesystems share the same destination, they are considered equal and
the qemu driver would reject the insertion.

Signed-off-by: Matthieu Coudron <mattator@gmail.com>
11 years agovirDomainHostdev{Insert,Delete}: Replace VIR_REALLOC_N by VIR_{APPEND,DELETE}_ELEMENT
Matthieu Coudron [Thu, 6 Feb 2014 14:29:08 +0000 (15:29 +0100)]
virDomainHostdev{Insert,Delete}: Replace VIR_REALLOC_N by VIR_{APPEND,DELETE}_ELEMENT

With this change the code gets shorter and more readable.

Signed-off-by: Matthieu Coudron <mattator@gmail.com>
11 years agoqemuxml2argvtest: Set timezone
Michal Privoznik [Thu, 6 Feb 2014 13:24:02 +0000 (14:24 +0100)]
qemuxml2argvtest: Set timezone

With my recent work on the test, both time() and localtime() are used.
While mocking the former one, we get predictable result for UTC. But
since the latter function uses timezone to get local time, the result of
localtime() is not so predictive. Therefore, we must set the TZ variable
at the beginning of the test. To be able to catch some things that work
just by a blind chance, I'm choosing a virtual timezone that (hopefully)
no libvirt developer resides in.

11 years agoqemuxml2argvmock: Mock time() on non-linux platforms too
Michal Privoznik [Thu, 6 Feb 2014 12:54:53 +0000 (13:54 +0100)]
qemuxml2argvmock: Mock time() on non-linux platforms too

The qemuxml2argvtest is run on more platforms than linux. For instance
FreeBSD. On these platforms we are, however, not mocking time() which
results in current time being fetched from system and hence tests number
32 and 33 failing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirsh: only report filled values in nodecpustats
Ján Tomko [Tue, 4 Feb 2014 09:06:54 +0000 (10:06 +0100)]
virsh: only report filled values in nodecpustats

Rewrite the function to use an array instead of a struct,
translating the field names to int via an enum.

11 years agoBSD: implement nodeGetCPUStats
Roman Bogorodskiy [Tue, 28 Jan 2014 17:49:24 +0000 (21:49 +0400)]
BSD: implement nodeGetCPUStats

Implementation obtains CPU usage information using
kern.cp_time and kern.cp_times sysctl(8)s and reports
CPU utilization.

11 years agoqemu: Fix crash in virDomainMemoryStats with old qemu
Jiri Denemark [Wed, 5 Feb 2014 10:15:31 +0000 (11:15 +0100)]
qemu: Fix crash in virDomainMemoryStats with old qemu

If virDomainMemoryStats was run on a domain with virtio balloon driver
running on an old qemu which supports QMP but does not support qom-list
QMP command, libvirtd would crash. The reason is we did not check if
qemuMonitorJSONGetObjectListPaths failed and moreover we even stored its
result in an unsigned integer type.

11 years agoqemu: blockjob: Print correct file name in error message
Peter Krempa [Wed, 5 Feb 2014 17:40:39 +0000 (18:40 +0100)]
qemu: blockjob: Print correct file name in error message

When attempting a blockcommit from the top layer, the base argument
passed is NULL. This will be dereferenced when attempting a commit with
an empty image chain. Output the real volume path instead:

virsh blockcommit --verbose --path vda --domain DOMNAME --wait
error: invalid argument: top '/path/somefile' in chain for 'vda' has no backing file

instead of:

error: invalid argument: top '(null)' in chain for 'vda' has no backing file

11 years agomaint: Change the text of the NULLSTR() macro to "<null>"
Peter Krempa [Wed, 5 Feb 2014 17:39:23 +0000 (18:39 +0100)]
maint: Change the text of the NULLSTR() macro to "<null>"

Eric Blake suggested to change this message to be different from the
glibc's NULL deref protection message in printf to be able to
differentiate errors.

11 years agoqemuxml2argvtest: Test localtime clock basis
Michal Privoznik [Wed, 5 Feb 2014 14:18:46 +0000 (15:18 +0100)]
qemuxml2argvtest: Test localtime clock basis

When trying to introduce a test for previous patch, I've
noticed that the command line is constructed using current
time. This won't work in our test suite (unless you guys
wants to set a specific time prior to each test run :) ).
Therefore we need to mock calls to time(2) to return the
same value every time it's called.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemuBuildClockArgStr: Allow localtime clock basis
Michal Privoznik [Wed, 5 Feb 2014 14:30:11 +0000 (15:30 +0100)]
qemuBuildClockArgStr: Allow localtime clock basis

https://bugzilla.redhat.com/show_bug.cgi?id=1046192

Commit b8bf79a, which adds clock='variable', forgets to check
localtime basis in qemuBuildClockArgStr(). So that localtime
basis could not be used.

Reported-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoGenerate a valid imagelabel even for type 'none'
Ján Tomko [Wed, 5 Feb 2014 17:34:51 +0000 (18:34 +0100)]
Generate a valid imagelabel even for type 'none'

Commit 2ce63c1 added imagelabel generation when relabeling is turned
off. But we weren't filling out the sensitivity for type 'none' labels,
resulting in an invalid label:

$ virsh managedsave domain
error: unable to set security context 'system_u:object_r:svirt_image_t'
on fd 28: Invalid argument

11 years agomaint: fix grammar in conf file
Eric Blake [Wed, 5 Feb 2014 17:04:35 +0000 (10:04 -0700)]
maint: fix grammar in conf file

Noticed a misuse of 'to' while testing my event regression under
polkit ACLs, and decided to review the entire conf files for
other legibility bugs.

* daemon/libvirtd.conf: Use correct grammar.
* src/qemu/qemu.conf: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: move event filtering to daemon (regression fix)
Eric Blake [Tue, 28 Jan 2014 21:50:02 +0000 (14:50 -0700)]
event: move event filtering to daemon (regression fix)

https://bugzilla.redhat.com/show_bug.cgi?id=1058839

Commit f9f56340 for CVE-2014-0028 almost had the right idea - we
need to check the ACL rules to filter which events to send.  But
it overlooked one thing: the event dispatch queue is running in
the main loop thread, and therefore does not normally have a
current virIdentityPtr.  But filter checks can be based on current
identity, so when libvirtd.conf contains access_drivers=["polkit"],
we ended up rejecting access for EVERY event due to failure to
look up the current identity, even if it should have been allowed.

Furthermore, even for events that are triggered by API calls, it
is important to remember that the point of events is that they can
be copied across multiple connections, which may have separate
identities and permissions.  So even if events were dispatched
from a context where we have an identity, we must change to the
correct identity of the connection that will be receiving the
event, rather than basing a decision on the context that triggered
the event, when deciding whether to filter an event to a
particular connection.

If there were an easy way to get from virConnectPtr to the
appropriate virIdentityPtr, then object_event.c could adjust the
identity prior to checking whether to dispatch an event.  But
setting up that back-reference is a bit invasive.  Instead, it
is easier to delay the filtering check until lower down the
stack, at the point where we have direct access to the RPC
client object that owns an identity.  As such, this patch ends
up reverting a large portion of the framework of commit f9f56340.
We also have to teach 'make check' to special-case the fact that
the event registration filtering is done at the point of dispatch,
rather than the point of registration.  Note that even though we
don't actually use virConnectDomainEventRegisterCheckACL (because
the RegisterAny variant is sufficient), we still generate the
function for the purposes of documenting that the filtering
takes place.

Also note that I did not entirely delete the notion of a filter
from object_event.c; I still plan on using that for my upcoming
patch series for qemu monitor events in libvirt-qemu.so.  In
other words, while this patch changes ACL filtering to live in
remote.c and therefore we have no current client of the filtering
in object_event.c, the notion of filtering in object_event.c is
still useful down the road.

* src/check-aclrules.pl: Exempt event registration from having to
pass checkACL filter down call stack.
* daemon/remote.c (remoteRelayDomainEventCheckACL)
(remoteRelayNetworkEventCheckACL): New functions.
(remoteRelay*Event*): Use new functions.
* src/conf/domain_event.h (virDomainEventStateRegister)
(virDomainEventStateRegisterID): Drop unused parameter.
* src/conf/network_event.h (virNetworkEventStateRegisterID):
Likewise.
* src/conf/domain_event.c (virDomainEventFilter): Delete unused
function.
* src/conf/network_event.c (virNetworkEventFilter): Likewise.
* src/libxl/libxl_driver.c: Adjust caller.
* src/lxc/lxc_driver.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_driver.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agorpm: create libvirt-wireshark sub-package
Eric Blake [Tue, 4 Feb 2014 19:37:15 +0000 (12:37 -0700)]
rpm: create libvirt-wireshark sub-package

On Fedora 20, with wireshark-devel installed, 'make rpm' failed
due to installed but unpackaged files related to wireshark.  As
F20 is already released without wireshark, I chose to add a new
sub-package that is enabled only for F21 and later.  Furthermore,
all existing wireshark plugins belong to the wireshark package,
so I got to invent behavior of how the first third-party wireshark
module will behave.

* libvirt.spec.in (with_wireshark): Add new conditional.
* configure.ac (ws-plugindir): Improve wording.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agonetwork: disallow <bandwidth>/<mac> for bridged/macvtap/hostdev networks
Laine Stump [Fri, 24 Jan 2014 11:58:05 +0000 (13:58 +0200)]
network: disallow <bandwidth>/<mac> for bridged/macvtap/hostdev networks

https://bugzilla.redhat.com/show_bug.cgi?id=1057321

pointed out that we weren't honoring the <bandwidth> element in
libvirt networks using <forward mode='bridge'/>. In fact, these
networks are just a method of giving a libvirt network name to an
existing Linux host bridge on the system, and libvirt doesn't have
enough information to know where to set such limits. We are working on
a method of supporting network bandwidths for some specific cases of
<forward mode='bridge'/>, but currently libvirt doesn't support it. So
the proper thing to do now is just log an error when someone tries to
put a <bandwidth> element in that type of network. (It's unclear if we
will be able to do proper bandwidth limiting for macvtap networks, and
most definitely we will not be able to support it for hostdev
networks).

While looking through the network XML documentation and comparing it
to the networkValidate function, I noticed that we also ignore the
presence of a mac address in the config in the same cases, rather than
failing so that the user will understand that their desired action has
not been taken.

This patch updates networkValidate() (which is called any time a
persistent network is defined, or a transient network created) to log
an error and fail if it finds either a <bandwidth> or <mac> element
and the network forward mode is anything except 'route'. 'nat', or
nothing. (Yes, neither of those elements is acceptable for any macvtap
mode, nor for a hostdev network).

NB: This does *not* cause failure to start any existing network that
contains one of those elements, so someone might have erroneously
defined such a network in the past, and that network will continue to
function unmodified. I considered it too disruptive to suddenly break
working configs on the next reboot after a libvirt upgrade.