]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoqemu: snapshot: Break out redefine preparation to shared function
Cole Robinson [Wed, 21 Aug 2013 20:39:02 +0000 (16:39 -0400)]
qemu: snapshot: Break out redefine preparation to shared function

11 years agotest: Implement snapshot create/delete/revert APIs
Cole Robinson [Wed, 7 Aug 2013 17:40:46 +0000 (13:40 -0400)]
test: Implement snapshot create/delete/revert APIs

Again stolen from qemu_driver.c, but dropping all the unneeded bits.
This aims to copy all the current qemu validation checks since that's
the most commonly used real driver, but some of the checks are
completely artificial in the test driver.

This only supports creation of internal snapshots for initial
simplicity.

11 years agotest: Allow specifying domainsnapshot XML
Cole Robinson [Wed, 7 Aug 2013 14:57:55 +0000 (10:57 -0400)]
test: Allow specifying domainsnapshot XML

The user can pass it as a <test:domainsnapshot> subelement of a <domain>.

11 years agoqemu: snapshots: Simplify REDEFINE flag check
Cole Robinson [Wed, 21 Aug 2013 20:10:37 +0000 (16:10 -0400)]
qemu: snapshots: Simplify REDEFINE flag check

Makes things more readable IMO

11 years agoqemu: check actual netdev type rather than config netdev type during init
Laine Stump [Thu, 3 Oct 2013 10:02:35 +0000 (13:02 +0300)]
qemu: check actual netdev type rather than config netdev type during init

This resolves:

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

Note that a similar problem was reported in:

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

but the fix only worked for <interface type='hostdev'>, *not* for
<interface type='network'> where the network itself was a pool of
hostdevs.

The symptom in both cases was this error message:

   internal error: Unable to determine device index for network device

In both cases the cause was lack of proper handling for netdevs
(<interface>) of type='hostdev' when scanning the netdev list looking
for alias names in qemuAssignDeviceNetAlias() - those that aren't
type='hostdev' have an alias of the form "net%d", while those that are
hostdev use "hostdev%d". This special handling was completely lacking
prior to the fix for Bug 827519 which was:

When searching for the highest alias index, libvirt looks at the alias
for each netdev and if it is type='hostdev' it ignores the entry. If
the type is not hostdev, then it expects the "net%d" form; if it
doesn't find that, it fails and logs the above error message.

That fix works except in the case of <interface type='network'> where
the network uses hostdev (i.e. the network is a pool of VFs to be
assigned to the guests via PCI passthrough). In this case, the check
for type='hostdev' would fail because it was done as:

     def->net[i]->type == VIR_DOMAIN_NET_TYPE_HOSTDEV

(which compares what was written in the config) when it actually
should have been:

    virDomainNetGetActualType(def->net[i]) == VIR_DOMAIN_NET_TYPE_HOSTDEV

(which compares the type of netdev that was actually allocated from
the network at runtime).

Of course the latter wouldn't be of any use if the netdevs of
type='network' hadn't already acquired their actual network connection
yet, but manual examination of the code showed that this is never the
case.

While looking through qemu_command.c, two other places were found to
directly compare the net[i]->type field rather than getting actualType:

* qemuAssignDeviceAliases() - in this case, the incorrect comparison
  would cause us to create a "net%d" alias for a netdev with
  type='network' but actualType='hostdev'. This alias would be
  subsequently overwritten by the proper "hostdev%d" form, so
  everything would operate properly, but a string would be
  leaked. This patch also fixes this problem.

* qemuAssignDevicePCISlots() - would defer assigning a PCI address to
  a netdev if it was type='hostdev', but not for type='network +
  actualType='hostdev'. In this case, the actual device usually hasn't
  been acquired yet anyway, and even in the case that it has, there is
  no practical difference between assigning a PCI address while
  traversing the netdev list or while traversing the hostdev
  list. Because changing it would be an effective NOP (but potentially
  cause some unexpected regression), this usage was left unchanged.

11 years agoqemucapabilitiesdata: Add qemu-1.6.50 data
Michal Privoznik [Thu, 3 Oct 2013 11:27:45 +0000 (13:27 +0200)]
qemucapabilitiesdata: Add qemu-1.6.50 data

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemucapabilitiesdata: Add qemu-1.6.0 data
Michal Privoznik [Thu, 3 Oct 2013 13:02:02 +0000 (15:02 +0200)]
qemucapabilitiesdata: Add qemu-1.6.0 data

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemucapabilitiesdata: Add qemu-1.4.2 data
Michal Privoznik [Thu, 3 Oct 2013 12:00:57 +0000 (14:00 +0200)]
qemucapabilitiesdata: Add qemu-1.4.2 data

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemucapabilitiesdata: Add qemu-1.3.1 data
Michal Privoznik [Thu, 3 Oct 2013 12:16:32 +0000 (14:16 +0200)]
qemucapabilitiesdata: Add qemu-1.3.1 data

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemucapabilitiesdata: Add qemu-1.2.2 data
Michal Privoznik [Thu, 3 Oct 2013 12:30:26 +0000 (14:30 +0200)]
qemucapabilitiesdata: Add qemu-1.2.2 data

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemuMonitorTestFree: Join worker thread
Michal Privoznik [Wed, 2 Oct 2013 16:20:18 +0000 (18:20 +0200)]
qemuMonitorTestFree: Join worker thread

Join the worker thread no matter if it is running or zombie already.
With current implementation the thread is joined iff @running is true.
However, when worker executes the last line, @running is set to false.
Hence qemuMonitorTestFree() won't join it (and free resources) even
though we can clearly see worker has run (nobody else sets @running =
false).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemumonitorjsontest: Test qemuMonitorJSONSystemPowerdown
Michal Privoznik [Tue, 1 Oct 2013 14:28:51 +0000 (16:28 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONSystemPowerdown

Right now, we are testing qemuMonitorSystemPowerdown instead of
qemuMonitorJSONSystemPowerdown. It makes no harm, as both functions have
the same header and the former is just a wrapper over the latter. But we
should be consistent as we're testing the JSON functions only in here.

11 years agoUse 'vnet' as prefix for veth devices
Daniel P. Berrange [Wed, 2 Oct 2013 11:24:54 +0000 (12:24 +0100)]
Use 'vnet' as prefix for veth devices

The XML parser reserves 'vnet' as a prefix for automatically
generated NIC device names. Switch the veth device creation
to use this prefix, so it does not have to worry about clashes
with user specified names in the XML.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRetry veth device creation on failure
Daniel P. Berrange [Wed, 2 Oct 2013 11:18:49 +0000 (12:18 +0100)]
Retry veth device creation on failure

The veth device creation code run in two steps, first it looks
for two free veth device names, then it runs ip link to create
the veth pair. There is an obvious race between finding free
names and creating them, when guests are started in parallel.

Rewrite the code to loop and re-try creation if it fails, to
deal with the race condition.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid deleting NULL veth device name
Daniel P. Berrange [Wed, 2 Oct 2013 10:26:59 +0000 (11:26 +0100)]
Avoid deleting NULL veth device name

If veth device allocation has a fatal error, the veths
array may contain NULL device names. Avoid calling the
virNetDevVethDelete function on such names.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid reporting an error if veth device is already deleted
Daniel P. Berrange [Wed, 2 Oct 2013 10:16:14 +0000 (11:16 +0100)]
Avoid reporting an error if veth device is already deleted

The kernel automatically destroys veth devices when cleaning
up the container network namespace. During normal shutdown, it
is thus likely that the attempt to run 'ip link del vethN'
will fail. If it fails, check if the device exists, and avoid
reporting an error if it has gone. This switches to use the
virCommand APIs instead of virRun too.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't set netdev offline in container cleanup
Daniel P. Berrange [Wed, 2 Oct 2013 10:10:45 +0000 (11:10 +0100)]
Don't set netdev offline in container cleanup

During container cleanup there is a race where the kernel may
have destroyed the veth device before we try to set it offline.
This causes log error messages. Given that we're about to
delete the device entirely, setting it offline is pointless.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetMigrationCapability
Michal Privoznik [Wed, 2 Oct 2013 17:03:53 +0000 (19:03 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetMigrationCapability

And so do qemuMonitorJSONSetMigrationCapability.

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetTargetArch
Michal Privoznik [Wed, 2 Oct 2013 16:55:42 +0000 (18:55 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetTargetArch

11 years agoqemumonitorjsontest: Test qemuMonitorJSONSetBlockIoThrottle
Michal Privoznik [Wed, 2 Oct 2013 16:46:42 +0000 (18:46 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONSetBlockIoThrottle

Also do qemuMonitorJSONGetBlockIoThrottle.

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetPtyPaths
Michal Privoznik [Wed, 2 Oct 2013 15:11:30 +0000 (17:11 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetPtyPaths

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetSpiceMigrationStatus
Michal Privoznik [Wed, 2 Oct 2013 14:52:36 +0000 (16:52 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetSpiceMigrationStatus

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetMigrationStatus
Michal Privoznik [Wed, 2 Oct 2013 14:43:35 +0000 (16:43 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetMigrationStatus

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetMigrationCacheSize
Michal Privoznik [Wed, 2 Oct 2013 14:01:46 +0000 (16:01 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetMigrationCacheSize

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetBlockStatsInfo
Michal Privoznik [Wed, 2 Oct 2013 13:08:02 +0000 (15:08 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetBlockStatsInfo

While the reply can be reused test qemuMonitorJSONGetBlockExtent and
qemuMonitorJSONGetBlockExtent too.

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetBlockInfo
Michal Privoznik [Wed, 2 Oct 2013 12:39:10 +0000 (14:39 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetBlockInfo

11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetBalloonInfo
Michal Privoznik [Wed, 2 Oct 2013 10:02:53 +0000 (12:02 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetBalloonInfo

11 years agoqemuMonitorJSONSendKey: Avoid double free
Michal Privoznik [Wed, 2 Oct 2013 16:18:13 +0000 (18:18 +0200)]
qemuMonitorJSONSendKey: Avoid double free

After successful @cmd construction the memory where @keys points to is
part of @cmd. Avoid double freeing it.

11 years agoqemuMonitorJSONGetVirtType: Fix error message
Michal Privoznik [Wed, 2 Oct 2013 11:58:40 +0000 (13:58 +0200)]
qemuMonitorJSONGetVirtType: Fix error message

When querying for kvm, we try to find 'enabled' field. Hence the error
message should report we haven't found 'enabled' and not 'running'
(which is not even in the reply). Probably a typo or copy-paste error.

11 years agoqemu_hotplug: Allow QoS update in qemuDomainChangeNet
Michal Privoznik [Tue, 1 Oct 2013 13:04:48 +0000 (15:04 +0200)]
qemu_hotplug: Allow QoS update in qemuDomainChangeNet

The qemuDomainChangeNet() is called when 'virsh update-device' is
invoked on a NIC. Currently, we fail to update the QoS even though
we have routines for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirNetDevBandwidthEqual: Make it more robust
Michal Privoznik [Wed, 2 Oct 2013 07:18:02 +0000 (09:18 +0200)]
virNetDevBandwidthEqual: Make it more robust

So far the virNetDevBandwidthEqual() expected both ->in and ->out items
to be allocated for both @a and @b compared. This is not necessary true
for all our code. For instance, running 'update-device' twice over a NIC
with the very same XML results in SIGSEGV-ing in this function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agotest: Implement readonly snapshot APIs
Cole Robinson [Tue, 6 Aug 2013 15:20:37 +0000 (11:20 -0400)]
test: Implement readonly snapshot APIs

This is just stolen from qemu_driver.c with tweaks to fit the
test driver.

11 years agotest: Wire up managed save APIs
Cole Robinson [Tue, 6 Aug 2013 23:33:25 +0000 (19:33 -0400)]
test: Wire up managed save APIs

Also add a <test:hasmanagedsave> element to set this data when starting
the connection.

11 years agotest: Allow specifying object transient state in driver XML
Cole Robinson [Tue, 6 Aug 2013 22:36:30 +0000 (18:36 -0400)]
test: Allow specifying object transient state in driver XML

Similar to the runstate commit, allow a boolean <test:transient/>
element for setting domain persistence at driver startup.

11 years agoqemu: cgroup: Fix crash if starting nographics guest
Cole Robinson [Tue, 1 Oct 2013 11:55:19 +0000 (07:55 -0400)]
qemu: cgroup: Fix crash if starting nographics guest

We can dereference graphics[0] even if guest has no graphics device
configured. I screwed this up in a216e6487255d3b65d97c7ec1fa5da63dbced902

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

11 years agoselinux: Only close the selabel_handle once
Ján Tomko [Tue, 1 Oct 2013 11:15:12 +0000 (13:15 +0200)]
selinux: Only close the selabel_handle once

On selinux driver initialization failure (missing/incorrectly
formatted contexts file), selabel_handle was closed twice.

Introduced by 6159710.

11 years agoFix handling of IPv6 listen addresses in cmdDomDisplay
Ján Tomko [Tue, 1 Oct 2013 09:16:30 +0000 (11:16 +0200)]
Fix handling of IPv6 listen addresses in cmdDomDisplay

Use virSocketAddrIsWildcard instead of STREQ to check for the ANY
address and put brackets around the address if it contains ':'.

11 years agoutil: recognize SMB/CIFS filesystems as shared
Laine Stump [Thu, 26 Sep 2013 09:40:17 +0000 (05:40 -0400)]
util: recognize SMB/CIFS filesystems as shared

This should resolve:

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

libvirt previously recognized NFS, GFS2, OCFS2, and AFS filesystems as
"shared", and thus eligible for exceptions to certain rules/actions
about chowning image files before handing them off to a guest. This
patch widens the definition of "shared filesystem" to include SMB and
CIFS filesystems (aka "Windows file sharing"); both of these use the
same protocol, but different drivers so there are different magic
numbers for each.

11 years agotests: Introduce qemucapabilitiestest
Michal Privoznik [Thu, 19 Sep 2013 11:44:41 +0000 (13:44 +0200)]
tests: Introduce qemucapabilitiestest

This test is there to ensure that our capabilities detection code isn't
broken somehow.

How to gather test data:

Firstly, the data is split into two separate files. The former (with
suffix .replies) contains all the qemu replies. This is very fragile as
introducing a new device can mean yet another monitor command and hence
edit of this file in the future. But there's no better way of doing
this. To get this data simply turn on debug logs and copy all the
QEMU_MONITOR_IO_PROCESS lines. But be careful to not copy incomplete
ones (yeah, we report some incomplete lines too). Long story short, at
the libvirtd startup, a dummy qemu is spawn to get all the capabilities.

The latter (with suffix .caps) contains capabilities XML. Just start a
domain and copy the corresponding part from its state XML file.
Including <qemuCaps> tag.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemuMonitorTest: Make check for monitor command match optional
Michal Privoznik [Thu, 19 Sep 2013 13:19:08 +0000 (15:19 +0200)]
qemuMonitorTest: Make check for monitor command match optional

In a few cases we might want to not care if monitor command executed on
the mocked monitor matches the one we have reply for. Sounds crazy, but
if we just want monitor to return certain values (e.g. read from a file)
there is no need to care about command match.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agotests: Learn qemuMonitorTestNew optional greeting
Michal Privoznik [Thu, 19 Sep 2013 11:56:30 +0000 (13:56 +0200)]
tests: Learn qemuMonitorTestNew optional greeting

Currently, when creating a new mocked monitor, the greeting can't be
chosen. This is crucial for next patches, because some info as qemu
version is obtained in the greeting message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu_capabilities: Introduce virQEMUCapsInitQMPMonitor
Michal Privoznik [Thu, 19 Sep 2013 11:14:25 +0000 (13:14 +0200)]
qemu_capabilities: Introduce virQEMUCapsInitQMPMonitor

This basically covers the talking-to-monitor part of
virQEMUCapsInitQMP.  The patch itself has no real value,
but it creates an entity to be tested in the next patches.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoRelease of libvirt-1.1.3
Daniel Veillard [Tue, 1 Oct 2013 07:04:14 +0000 (15:04 +0800)]
Release of libvirt-1.1.3

- configure.ac docs/news.html.in libvirt.spec.in: update for release
- po/*.po*: updated localization and regenerated

11 years agoVMware: Add Fusion version test
Doug Goldstein [Mon, 30 Sep 2013 21:58:37 +0000 (16:58 -0500)]
VMware: Add Fusion version test

This adds a test for the version string of VMware Fusion.

11 years agolxc: do cleanup when failed to bind fs as read-only
Chen Hanxiao [Mon, 30 Sep 2013 09:06:25 +0000 (17:06 +0800)]
lxc: do cleanup when failed to bind fs as read-only

We forgot to do cleanup when lxcContainerMountFSTmpfs
failed to bind fs as read-only.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix max stream packet size for old clients
Daniel P. Berrange [Mon, 30 Sep 2013 16:27:51 +0000 (17:27 +0100)]
Fix max stream packet size for old clients

The libvirtd server pushes data out to clients. It does not
know what protocol version the client might have, so must be
conservative and use the old payload limits. ie send no more
than 256kb of data per packet.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoLXC: workaround machined uncleaned data with containers running systemd.
Cédric Bosdonnat [Mon, 30 Sep 2013 14:46:29 +0000 (16:46 +0200)]
LXC: workaround machined uncleaned data with containers running systemd.

The problem is described by [0] but its effect on libvirt is that
starting a container with a full distro running systemd after having
stopped it simply fails.

The container cleanup now calls the machined Terminate function to make
sure that everything is in order for the next run.

 [0]: https://bugs.freedesktop.org/show_bug.cgi?id=68370

11 years agovirfile: safezero: align mmap offset to page size
Oskari Saarenmaa [Mon, 30 Sep 2013 11:01:45 +0000 (14:01 +0300)]
virfile: safezero: align mmap offset to page size

mmap's offset must be aligned to page size or mapping will fail.
mmap-based safezero is only used if posix_fallocate isn't available.

Signed-off-by: Oskari Saarenmaa <os@ohmu.fi>
11 years agovirscsi: hostdev SCSI AdapterId retrieval fix
Boris Fiuczynski [Mon, 30 Sep 2013 12:23:17 +0000 (14:23 +0200)]
virscsi: hostdev SCSI AdapterId retrieval fix

Fixed the retrieval of the AdapterId from the AdapterName of the
hostdev source so it does return an error instead of leaving the
adapter_id uninitialized.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agovirsh-volume: Add missing check when calling virStreamNew
Hongwei Bi [Sun, 29 Sep 2013 09:24:11 +0000 (17:24 +0800)]
virsh-volume: Add missing check when calling virStreamNew

Check return value of virStreamNew when called by cmdVolUpload and
cmdVolDownload.

11 years agovirsh-domain: Free dom before return false in cmdDump
Hongwei Bi [Fri, 27 Sep 2013 22:02:31 +0000 (06:02 +0800)]
virsh-domain: Free dom before return false in cmdDump

11 years agoqemu: process: Silence coverity warning when rewinding log file
Peter Krempa [Mon, 30 Sep 2013 09:47:47 +0000 (11:47 +0200)]
qemu: process: Silence coverity warning when rewinding log file

The change in ef29de14c37d14abc546e90555a0093797facfdd that introduced
better error logging from qemu introduced a warning from coverity about
unused return value from lseek. Silence this warning and fix typo in the
corresponding error message.

Reported by: John Ferlan

11 years agopython: Document virNodeGetInfo bug
Michal Privoznik [Mon, 30 Sep 2013 09:23:08 +0000 (11:23 +0200)]
python: Document virNodeGetInfo bug

The memory size in virNodeGetInfo python API binding is reported in MiB
instead of KiB (like we have in C struct). However, there already might
be applications out there relying on this inconsistence so we can't
simply fix it. Document this sad fact as known bug.

11 years agoRemove tab from previous commit
Daniel Veillard [Sun, 29 Sep 2013 16:09:59 +0000 (00:09 +0800)]
Remove tab from previous commit

11 years agoVMware: Initial VMware Fusion support
Doug Goldstein [Tue, 24 Sep 2013 16:24:31 +0000 (11:24 -0500)]
VMware: Initial VMware Fusion support

Add support for VMware Fusion in the existing VMware driver.  Connect
via the URI vmwarefusion:///session

11 years agoVMware: Support more than 2 driver backends
Doug Goldstein [Tue, 24 Sep 2013 16:24:30 +0000 (11:24 -0500)]
VMware: Support more than 2 driver backends

Currently the VMware version check code only supports two types of
VMware backends, Workstation and Player. But in the near future we will
have an additional one so we need to support more. Additionally, we
discover and cache the path to the vmrun binary so we should use that
path when using the corresponding binary from the VMware VIX SDK.

11 years agobuild: fix build --without-lxc
Eric Blake [Sat, 28 Sep 2013 03:21:02 +0000 (21:21 -0600)]
build: fix build --without-lxc

'make distcheck' fails from a directory configured --without-lxc:

  GEN      virt-login-shell.1
Can't write-open ../../tools/virt-login-shell.1: Permission denied at /usr/bin/pod2man line 69.

* tools/Makefile.am (EXTRA_DIST): Ship pre-built man page.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: tweak vpath builds of net_rpc
Eric Blake [Fri, 27 Sep 2013 17:12:20 +0000 (11:12 -0600)]
build: tweak vpath builds of net_rpc

Another case missed by commits 716c7bb and 6973e02.

* src/Makefile.am (VIR_NET_RPC_GENERATED): Drop $(srcdir).
(libvirt_net_rpc_la_SOURCES): List generated files more compactly.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoMakefile.am: Always include rule to make org.libvirt.api.policy
Michal Privoznik [Fri, 27 Sep 2013 16:04:31 +0000 (18:04 +0200)]
Makefile.am: Always include rule to make org.libvirt.api.policy

When running 'make dist' on a system without policykit, we currently
fail. This is because $(srcdir)/access/org.libvirt.api.policy is in
EXTRA_DIST, however, the rule to generate the file is conditional
whether we build with polkit or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agofchosttest: Run the test only under linux
Michal Privoznik [Fri, 27 Sep 2013 14:47:12 +0000 (16:47 +0200)]
fchosttest: Run the test only under linux

Currently, we have functions to handle fc_host implemented just
for linux. On all other platforms an error is thrown. It makes no
sense to run the test on those platforms then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agogenprotocol.pl: Fix code on FreeBSD too
Michal Privoznik [Fri, 27 Sep 2013 14:20:49 +0000 (16:20 +0200)]
genprotocol.pl: Fix code on FreeBSD too

On some systems (linux, cygwin and gnukfreebsd) rpcgen generates files
which when compiling produces this warning:

remote/remote_protocol.c: In function 'xdr_remote_node_get_cpu_stats_ret':
remote/remote_protocol.c:530: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

Hence, on those systems we need to post-process the files by the
rpc/genprotocol.pl perl script. At the beginning of the script the OS is
detected via $^O perl variable. From my latest build on FreeBSD I see we
need to fix the code there too. On FreeBSD the variable contains
'freebsd' string:

http://perldoc.perl.org/perlport.html#PLATFORMS

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoevent: Make debug message match function comments
Doug Goldstein [Sat, 21 Sep 2013 16:07:21 +0000 (11:07 -0500)]
event: Make debug message match function comments

The debug message said there was a timeout of 0 pending for -1 ms which
made me think this is where a hang was coming from but according to the
function comments this case means that there is no timeout pending so
make the debug message say that instead of saying there's a -1 ms
timeout.

11 years agoBSD: Ensure process creation timestamp is init'd
Doug Goldstein [Sat, 21 Sep 2013 16:02:08 +0000 (11:02 -0500)]
BSD: Ensure process creation timestamp is init'd

While BSDs don't support process creation timestamp information via
PEERCRED for Unix sockets, we need to actually initialize the value
because it is used by the libvirt code.

11 years agoBSD: Ensure UNIX socket credentials are valid
Doug Goldstein [Wed, 4 Sep 2013 17:21:45 +0000 (12:21 -0500)]
BSD: Ensure UNIX socket credentials are valid

Ensure that the socket credentials we got back on BSD are valid before
using them.

11 years agoFix crash in libvirtd when events are registered & ACLs active
Daniel P. Berrange [Fri, 27 Sep 2013 14:46:07 +0000 (15:46 +0100)]
Fix crash in libvirtd when events are registered & ACLs active

When a client disconnects from libvirtd, all event callbacks
must be removed. This involves running the public API

  virConnectDomainEventDeregisterAny

This code does not run in normal API dispatch context, so no
identity was set. The result was that the access control drivers
denied the attempt to deregister callbacks. The callbacks thus
continued to trigger after the client was free'd causing fairly
predictable use of free memory & a crash.

This can be triggered by any client with readonly access when
the ACL drivers are active.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirsh: Fix domdisplay when domain only uses TLS
Christophe Fergeau [Wed, 25 Sep 2013 15:48:01 +0000 (17:48 +0200)]
virsh: Fix domdisplay when domain only uses TLS

It's possible to create a domain which will only use a TLS port
and will not have a non-TLS port set by using:
<graphics type='spice' autoport='yes' defaultMode='secure'/>
In such a setup, the 'graphics' node for the running domain will be:
<graphics type='spice' tlsPort='5900'
          autoport='yes' listen='127.0.0.1'
          defaultMode='secure'>

However, cmdDomDisplay loops over all the 'graphics' node, and it
ignores nodes which don't have a 'port' attribute. This means
'virsh domdisplay' will only return an empty string for domains
as the one above.

This commit looks for both 'port' and 'tlsPort' before deciding
to ignore a graphics node. It also makes sure 'port' is not printed
when it's not set.
This makes 'virsh domdisplay' return
'spice://127.0.0.1?tls-port=5900' for domains using only a TLS
port.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
11 years agoqemu: Free all driver data in qemuStateCleanup
Jiri Denemark [Fri, 27 Sep 2013 13:34:43 +0000 (15:34 +0200)]
qemu: Free all driver data in qemuStateCleanup

https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case A)

While activeScsiHostdevs and webSocketPorts were allocated in
qemuStateInitialize, they were not freed in qemuStateCleanup.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemu: Don't leak reference to virQEMUDriverConfigPtr
Jiri Denemark [Fri, 27 Sep 2013 13:07:38 +0000 (15:07 +0200)]
qemu: Don't leak reference to virQEMUDriverConfigPtr

https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case D)

qemuProcessStart created two references to virQEMUDriverConfigPtr before
calling fork():

    cfg = virQEMUDriverGetConfig(driver);
    ...
    hookData.cfg = virObjectRef(cfg);

However, the child only unreferenced hookData.cfg and the parent only
removed the cfg reference. That said, we don't need to increment the
reference counter when assigning cfg to hookData. Both the child and the
parent will correctly remove the reference on cfg (the child will do
that through hookData).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agobuild: fix testsuite building under cygwin
Eric Blake [Fri, 27 Sep 2013 11:01:47 +0000 (05:01 -0600)]
build: fix testsuite building under cygwin

Similar to commit 8f34f19.

* tests/Makefile.am (virnetserverclienttest_CFLAGS): Add XDR_CFLAGS.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: Fix VPATH build error for locking daemon
Viktor Mihajlovski [Fri, 27 Sep 2013 12:46:59 +0000 (14:46 +0200)]
build: Fix VPATH build error for locking daemon

Removed superfluous/wrong srcdir prefix.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agorpc: Increase bound limit for virDomainGetJobStats
Jiri Denemark [Fri, 27 Sep 2013 08:48:02 +0000 (10:48 +0200)]
rpc: Increase bound limit for virDomainGetJobStats

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

Commit 6d7d0b1869ed293e3208d11f375cecea0129dfc5 (in 1.1.2) added bounds
checking to virDomainGetJobStats. But even at that time the API was able
to return 20 parameters while the limit was set to 16.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agolxc: fix a warning typo in virLXCControllerEventSend
Chen Hanxiao [Fri, 27 Sep 2013 05:43:24 +0000 (13:43 +0800)]
lxc: fix a warning typo in virLXCControllerEventSend

s/becuase/because/

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agomaint: fix comment typos
Eric Blake [Thu, 26 Sep 2013 21:40:34 +0000 (15:40 -0600)]
maint: fix comment typos

* src/lxc/lxc_controller.c (virLXCControllerSetupDisk): Fix typo.
* src/lxc/lxc_driver.c (lxcDomainAttachDeviceDiskLive): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix use of rpc.h on cygwin
Eric Blake [Thu, 26 Sep 2013 21:14:38 +0000 (15:14 -0600)]
build: fix use of rpc.h on cygwin

Caused by commit 012c25e8 splitting out a convenience library.

  CC       libvirtd_conf_la-libvirtd-config.lo
In file included from ../src/rpc/virnetmessage.h:24:0,
                 from ../src/rpc/virnetserverprogram.h:27,
                 from ../src/rpc/virnetserver.h:32,
                 from libvirtd-config.c:31:
../src/rpc/virnetprotocol.h:9:21: fatal error: rpc/rpc.h: No such file
or directory

* daemon/Makefile.am (libvirtd_conf_la_CFLAGS): Add XDR_CFLAGS.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC: free dst before lxcDomainAttachDeviceDiskLive returns
Chen Hanxiao [Thu, 26 Sep 2013 06:01:52 +0000 (14:01 +0800)]
LXC: free dst before lxcDomainAttachDeviceDiskLive returns

Free dst before lxcDomainAttachDeviceDiskLive returns

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoqemu: virDomainControllerFind may return 0 if controller found
Chen Hanxiao [Tue, 24 Sep 2013 08:03:15 +0000 (16:03 +0800)]
qemu: virDomainControllerFind may return 0 if controller found

The return value of virDomainControllerFind >=0 means that
the specific controller was found.
But some functions invoke it and treat 0 as not found.
This patch fix these incorrect invocation.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoDistribute check-aclperms.pl
Guido Günther [Thu, 26 Sep 2013 11:27:18 +0000 (13:27 +0200)]
Distribute check-aclperms.pl

so "make check" can work for the distributed tarballs too.

11 years agoconf: clean up virDomainChrSourceDefParseXML
Peter Krempa [Thu, 26 Sep 2013 07:24:09 +0000 (09:24 +0200)]
conf: clean up virDomainChrSourceDefParseXML

Tweak some conditions and use correct typecasts in enums.

11 years agoconf: Don't crash on invalid chardev source definition of RNGs and other
Peter Krempa [Thu, 26 Sep 2013 06:12:39 +0000 (08:12 +0200)]
conf: Don't crash on invalid chardev source definition of RNGs and other

Since commit 297c99a5 an invalid source definition XML of a character
device that is used as backend for RNG devices, smartcards and redirdevs
causes crash of the daemon when parsing such a definition.

The device types mentioned above are not a part of a regular character
device but are backends for other types. Thus when parsing such device
NULL is passed as the argument @chr_def. Later when checking the
validity of the definition @chr_def was dereferenced when parsing a UNIX
socket backend with missing path of the socket and crashed the daemon.

Sample offending configuration:
  <devices>
  ...
    <rng model='virtio'>
      <backend model='egd' type='unix'>
        <source mode='bind' service='1024'/>
      </backend>
    </rng>
  </devices>

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

11 years agospec: Clean up distribution of ChangeLog (and others)
Cole Robinson [Wed, 25 Sep 2013 17:20:40 +0000 (13:20 -0400)]
spec: Clean up distribution of ChangeLog (and others)

- Move COPYING* to libvirt-client, so every package pulls them in
- Move AUTHORS ChangeLog.gz NEWS README TODO from -daemon to -docs
- Drop duplicate distribution of docs in -python

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

11 years agotest: Allow specifying object runstate in driver XML
Cole Robinson [Tue, 6 Aug 2013 21:42:16 +0000 (17:42 -0400)]
test: Allow specifying object runstate in driver XML

When passing in custom driver XML, allow a block like

<domain xmlns:test='http://libvirt.org/schemas/domain/test/1.0'>
  ...
  <test:runstate>5</test:runstate>
</domain>

This is only read at initial driver start time, and sets the initial
run state of the object. This is handy for UI testing.

It's only wired up for domains, since that's the only conf/
infrastructure that supports namespaces at the moment.

11 years agoAvoid use of uninitialized data in virnetmessagetest
Daniel P. Berrange [Wed, 25 Sep 2013 14:37:10 +0000 (15:37 +0100)]
Avoid use of uninitialized data in virnetmessagetest

If an error occurs in virnetmessagetest it was possible it
would free uninitialized data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid crash on OOM in virnetmessagetest
Daniel P. Berrange [Wed, 25 Sep 2013 14:36:39 +0000 (15:36 +0100)]
Avoid crash on OOM in virnetmessagetest

The virnetmessagetest code did not check for failure to
allocate the message object. This lead to a crash on OOM
in the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid crash on OOM in virportallocatortest
Daniel P. Berrange [Wed, 25 Sep 2013 14:35:44 +0000 (15:35 +0100)]
Avoid crash on OOM in virportallocatortest

The virportallocatortest did not check if the object
allocation failed in all cases. This lead to a crash
on OOM in the testsuite

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid crash on OOM in virlockspacetest
Daniel P. Berrange [Wed, 25 Sep 2013 14:31:48 +0000 (15:31 +0100)]
Avoid crash on OOM in virlockspacetest

The virlockspacetest.c did not check for failure to create
a lockspace, causing a crash on OOM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid crash on OOM in virbuftest
Daniel P. Berrange [Wed, 25 Sep 2013 14:31:18 +0000 (15:31 +0100)]
Avoid crash on OOM in virbuftest

The virbuftest code did not check virBufferError before
accessing the buffer contents, resulting in a crash on
OOM conditions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid uninitialized data in qemuMonitorTestNew
Daniel P. Berrange [Wed, 25 Sep 2013 14:30:27 +0000 (15:30 +0100)]
Avoid uninitialized data in qemuMonitorTestNew

The virDomainChrSourceDef variable should be memset to
0, so that the cleanup block does not free uninitialized
data on OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid double free in qemuMonitorCommonTestInit on OOM
Daniel P. Berrange [Wed, 25 Sep 2013 14:29:45 +0000 (15:29 +0100)]
Avoid double free in qemuMonitorCommonTestInit on OOM

The qemuMonitorCommonTestInit method did not allocate the
test object, so it should not free it upon failure. Doing
so causes a double free with the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak on OOM in qemuMonitorCommonTestNew
Daniel P. Berrange [Wed, 25 Sep 2013 14:28:55 +0000 (15:28 +0100)]
Fix leak on OOM in qemuMonitorCommonTestNew

Don't leak the path string in qemuMonitorCommonTestNew if
an OOM occurs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't ignore errors parsing nwfilter rules
Daniel P. Berrange [Wed, 25 Sep 2013 14:26:58 +0000 (15:26 +0100)]
Don't ignore errors parsing nwfilter rules

For inexplicable reasons, the nwfilter XML parser is intentionally
ignoring errors that arise during parsing. As well as meaning that
users don't get any feedback on their XML mistakes, this will lead
it to silently drop data in OOM conditions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak in virLockSpaceResourceFree
Daniel P. Berrange [Wed, 25 Sep 2013 14:17:51 +0000 (15:17 +0100)]
Fix leak in virLockSpaceResourceFree

Normally a lockspace resource is not freed while there are
active owners. During initial resource creation though, an
OOM error will trigger this scenario. virLockSpaceResourceFree
was not freeing the 'owners' field in this case.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak of parser state in virJSONValueFromString
Daniel P. Berrange [Wed, 25 Sep 2013 14:17:04 +0000 (15:17 +0100)]
Fix leak of parser state in virJSONValueFromString

If OOM or another error occurs in virJSONValueFromString the
parser state object will be leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix double-free in virJSONParserHandleStartMap on OOM
Daniel P. Berrange [Wed, 25 Sep 2013 14:16:24 +0000 (15:16 +0100)]
Fix double-free in virJSONParserHandleStartMap on OOM

If OOM occurs in virJSONParserHandleStartMap it will free
a variable that is owned by another object. This leads to
a later double-free.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak of iterators in virDBusMessageIterEncode
Daniel P. Berrange [Wed, 25 Sep 2013 14:15:45 +0000 (15:15 +0100)]
Fix leak of iterators in virDBusMessageIterEncode

If virDBusMessageIterEncode hits an OOM condition it often
leaks the memory associated with the dbus iterator object

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't print all test suite errors to stderr in vmx2xmltest
Daniel P. Berrange [Wed, 25 Sep 2013 10:34:00 +0000 (11:34 +0100)]
Don't print all test suite errors to stderr in vmx2xmltest

The vmx2xmltest test would print all errors to stderr, which
is not helpful when running OOM tests, and differs from the
behaviour of other tests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak of comment string if virConfAddEntry fails on OOM
Daniel P. Berrange [Wed, 25 Sep 2013 10:32:07 +0000 (11:32 +0100)]
Fix leak of comment string if virConfAddEntry fails on OOM

The code parsing comments in config files called virConfAddEntry
but did not check for failure. This caused the comment string to
leak on OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd missing check for OOM with virVMXEscapeHexPipe
Daniel P. Berrange [Wed, 25 Sep 2013 10:31:26 +0000 (11:31 +0100)]
Add missing check for OOM with virVMXEscapeHexPipe

The virVMXFormatConfig called virVMXEscapeHexPipe but
forgot to check for OOM. This caused data to silently
be lost.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix crash on OOM parsing storage pool XML
Daniel P. Berrange [Wed, 25 Sep 2013 09:22:42 +0000 (10:22 +0100)]
Fix crash on OOM parsing storage pool XML

The virStoragePoolDefParseSource method would set def->nhosts
before allocating def->hosts. If the allocation failed due to
OOM, the cleanup code would crash accessing out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix double free of hostdev on OOM in xenParseSxprPCI
Daniel P. Berrange [Wed, 25 Sep 2013 09:20:45 +0000 (10:20 +0100)]
Fix double free of hostdev on OOM in xenParseSxprPCI

If xenParseSxprPCI failed to expand the def->hostdevs array
due to OOM, it would free the hostdev instance twice.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't clobber 'ret' in LXC XML test case
Daniel P. Berrange [Wed, 25 Sep 2013 08:35:29 +0000 (09:35 +0100)]
Don't clobber 'ret' in LXC XML test case

The testCompareXMLToXMLHelper method clobbered the 'ret' variable
in several places leading to a failure to report OOM errors from
the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>