]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agodocs: storage: fix rbd pool indentation
Cole Robinson [Thu, 4 Dec 2014 15:34:05 +0000 (10:34 -0500)]
docs: storage: fix rbd pool indentation

10 years agoqemu: process: Avoid uninitialized use two vars when reconnecting to vm
Peter Krempa [Thu, 4 Dec 2014 15:13:31 +0000 (16:13 +0100)]
qemu: process: Avoid uninitialized use two vars when reconnecting to vm

3ecebf07110ca8d3413072557f29137943e848e3 breaks the build as it adds a
way to jump to cleanup before the 'cfg' object is retrieved and 'priv'
is initialized.

10 years agoFix handling of whitespae in preprocessor macros for API generator
Daniel P. Berrange [Thu, 4 Dec 2014 12:06:32 +0000 (12:06 +0000)]
Fix handling of whitespae in preprocessor macros for API generator

The apibuild.py script did not handle whitespace in preprocessor
macros, so it failed to detect constants declared with '# define'
instead of '#define'. Since we now correctly indent our public
header files, we have silently lost all constants from
libvirt-api.xml. This also caused us to not detect formatting
errors in constant docs

10 years agoqemu: process: Refactor reconnecting to qemu processes
Peter Krempa [Wed, 3 Dec 2014 13:22:05 +0000 (14:22 +0100)]
qemu: process: Refactor reconnecting to qemu processes

Move entering the job into the thread to simplify the program flow. Also
as the code holds a separate reference to the domain object some
conditions can be simplified.

After this patch qemuDomainObjTransferJob is no longer needed so this
patch removes it.

10 years agodocs: Create html documentation even if XHTML1 DTD is not available to validate
Ian Campbell [Fri, 28 Nov 2014 14:36:18 +0000 (14:36 +0000)]
docs: Create html documentation even if XHTML1 DTD is not available to validate

On a Debian system lacking the w3c-dtd-xhtml package the build fails
with:

        $ make -C docs/ formatcaps.html
        make: Entering directory '/local/scratch/ianc/devel/libvirt.git/docs'
        Generating formatcaps.html.tmp
        I/O error : Attempt to load network entity http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
        formatcaps.html.in:2: warning: failed to load external entity "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
                                                                                       ^
        I/O error : Attempt to load network entity http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
        ../docs/sitemap.html.in:2: warning: failed to load external entity "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
                                                                                       ^
        missing XHTML1 DTD
        rm formatcaps.html.tmp
        make: Leaving directory '/local/scratch/ianc/devel/libvirt.git/docs'
        $ ls docs/formatcaps*
        docs/formatcaps.html.in

https://www.redhat.com/archives/libvir-list/2009-November/msg00413.html
suggests that the XHTML1 DTD should not be a hard requirement and the
docs should be generated but not validated if it is not available.

Therefore when the DTD is not available arrange for the .html.tmp file
to be propagated to the .html output.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Daniel Veillard <veillard@redhat.com>
10 years agotests: Fix misplaced parenthesis in qemumonitorjsontest
Martin Kletzander [Wed, 3 Dec 2014 13:42:27 +0000 (14:42 +0100)]
tests: Fix misplaced parenthesis in qemumonitorjsontest

When trying clang, it found out that we were comparing sizeof with 0
even though we wanted to check the return value of memcmp.  That showed
us that the test was wrong and it needs a fix as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodrvbhyve: Automatically tear down guest domains on shutdown
Conrad Meyer [Fri, 14 Nov 2014 16:03:30 +0000 (11:03 -0500)]
drvbhyve: Automatically tear down guest domains on shutdown

Reboot requires more sophistication and is left as a future work item --
but at least part of the plumbing is in place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Fix virsh freeze when blockcopy storage file is removed
Erik Skultety [Wed, 3 Dec 2014 12:56:47 +0000 (13:56 +0100)]
qemu: Fix virsh freeze when blockcopy storage file is removed

If someone removes blockcopy storage file when still in mirroring phase
and then requesting blockjob abort using pivot, virsh cmd freezes. This
is not an issue with older qemu versions which did not support
asynchronous jobs (which we prefer by default).
As we have reached the mirroring phase successfully, polling monitor for
blockjob info always returns 1 and the loop never ends.
This fix introduces a check for qemuDomainBlockPivot return code, possibly
skipping the asynchronous waiting completely, if an error occurred and
asynchronous waiting was the preferred method.

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

10 years agodocs: More html/docs changes from libvirt.h.in split
John Ferlan [Wed, 3 Dec 2014 21:15:14 +0000 (16:15 -0500)]
docs: More html/docs changes from libvirt.h.in split

This changes the display from:

libvirt-storage: APIs for management of storages

to

libvirt-storage: APIs for management of storage pools and volumes

In making that change I expected my build tree html output to be
regenerated; however, it wasn't because the dependency for the separated
libvirt-storage.h wasn't there.  It was only present for libvirt.h.in

So I added each in the order displayed on the docs/html/index.html page

10 years agocpu: fix possible crash in getModels
Pavel Hrdina [Wed, 3 Dec 2014 17:50:16 +0000 (18:50 +0100)]
cpu: fix possible crash in getModels

Commit 86a15a25 introduced a new cpu driver API 'getModels'. Public API
allow you to pass NULL for models to get only number of existing models.
However the new code will crash with segfault so we have to count with
the possibility that the user wants only the number.

There is also difference in order of the models gathered by this new API
as the old approach was inserting the elements to the end of the array
so we should use 'VIR_APPEND_ELEMENT'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: driver: Reload snapshots and managedsaves prior to reconnecting
Peter Krempa [Wed, 3 Dec 2014 10:18:53 +0000 (11:18 +0100)]
qemu: driver: Reload snapshots and managedsaves prior to reconnecting

Reconnect to the VM is a possibly long-running job spawned in a separate
thread. We should reload the snapshot defs and managedsave state prior
to spawning the thread to avoid blocking of the daemon startup which
would serialize on the VM lock.

Also the reloading code would violate the domain job held while
reconnecting as the loader functions don't create jobs.

10 years agoleaseshelper: Fix incorrect alignment of a switch case
Peter Krempa [Wed, 3 Dec 2014 17:27:03 +0000 (18:27 +0100)]
leaseshelper: Fix incorrect alignment of a switch case

Introduced in ca6dbdd047d1ed691ccbae72556d85722a5f7a36

10 years agoleaseshelper: Skip entries missing expiry time on INIT action
Peter Krempa [Wed, 3 Dec 2014 17:24:38 +0000 (18:24 +0100)]
leaseshelper: Skip entries missing expiry time on INIT action

Coverity pointed out that in other places we always check the return
value from virJSONValueObjectGetNumberLong() but not in the new addition
in leaseshelper. To solve the issue and also be more robust in case
somebody would corrupt the file, skip outputting of the lease entry in
case the expiry time is missing.

10 years agostorage: fix crash caused by no check return before set close
Luyao Huang [Wed, 3 Dec 2014 15:01:32 +0000 (23:01 +0800)]
storage: fix crash caused by no check return before set close

https://bugzilla.redhat.com/show_bug.cgi?id=1087104#c5

When trying to use an invalid offset to virStorageVolUpload(), libvirt
fails in virFDStreamOpenFileInternal(), although it seems libvirt does
not check the return in storageVolUpload(), and calls
virFDStreamSetInternalCloseCb() right after.  But stream doesn't have a
privateData (is NULL) yet, and the daemon crashes then.

0  0x00007f09429a9c10 in pthread_mutex_lock () from /lib64/libpthread.so.0
1  0x00007f094514dbf5 in virMutexLock (m=<optimized out>) at util/virthread.c:88
2  0x00007f09451cb211 in virFDStreamSetInternalCloseCb at fdstream.c:795
3  0x00007f092ff2c9eb in storageVolUpload at storage/storage_driver.c:2098
4  0x00007f09451f46e0 in virStorageVolUpload at libvirt.c:14000
5  0x00007f0945c78fa1 in remoteDispatchStorageVolUpload at remote_dispatch.h:14339
6  remoteDispatchStorageVolUploadHelper at remote_dispatch.h:14309
7  0x00007f094524a192 in virNetServerProgramDispatchCall at rpc/virnetserverprogram.c:437

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agovirsh: vol-upload disallow negative offset
Shanzhi Yu [Wed, 3 Dec 2014 07:53:38 +0000 (15:53 +0800)]
virsh: vol-upload disallow negative offset

Commit 570d0f63 describes disabling negative offset usage for
vol-upload/download (e.g. cmdVolDownload and cmdVolUpload; however,
the change was only made to cmdVolDownload. There was no change to
cmdVolUpload.  This patch adds the same checks for vol-upload.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1087104
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
10 years agonetwork: dnsmasq: Don't format lease file path
Peter Krempa [Thu, 20 Nov 2014 12:56:39 +0000 (13:56 +0100)]
network: dnsmasq: Don't format lease file path

Now that we don't use the leases file at all for leases just don't
format it into the config and use the leaseshelper to do all the
lifting.

10 years agoleaseshelper: Refactor control flow
Peter Krempa [Thu, 20 Nov 2014 13:49:31 +0000 (14:49 +0100)]
leaseshelper: Refactor control flow

Untangle a few conditions into a case statement and improve reporting of
invaid commands.

10 years agoleaseshelper: improvements to support all events
Nehal J Wani [Tue, 18 Nov 2014 17:16:25 +0000 (22:46 +0530)]
leaseshelper: improvements to support all events

This patch enables the helper program to detect event(s) triggered when
there is a change in lease length or expiry and client-id. This
transfers complete control of leases database to libvirt and obsoletes
use of the lease database file (<network-name>.leases). That file will
not be created, read, or written.  This is achieved by adding the option
--leasefile-ro to dnsmasq and passing a custom env var to leaseshelper,
which helps us map events related to leases with their corresponding
network bridges, no matter what the event be.

Also, this requires the addition of a new non-lease entry in our custom
lease database: "server-duid". It is required to identify a DHCPv6
server.

Now that dnsmasq doesn't maintain its own leases database, it relies on
our helper program to tell it about previous leases and server duid.
Thus, this patch makes our leases program honor an extra action: "init",
in which it sends the known info in a particular format to dnsmasq
by printing it to stdout.

The drawback of this change is that upgrade to this new approach does
not transfer the existing leases for the network if the leaseshelper
wasn't already used.

10 years agocpu-driver: Fix the cross driver function call
Daniel Hansel [Thu, 20 Nov 2014 10:08:21 +0000 (11:08 +0100)]
cpu-driver: Fix the cross driver function call

For Intel and PowerPC the implementation is calling a cpu driver
function across driver layers (i.e. from qemu driver directly to cpu
driver).
The correct behavior is to use libvirt API functionality to perform such
a inter-driver call.

This patch introduces a new cpu driver API function getModels() to
retrieve the cpu models. The currect implementation to process the
cpu_map XML content is transferred to the INTEL and PowerPC cpu driver
specific API functions.
Additionally processing the cpu_map XML file is not safe due to the fact
that the cpu map does not exist for all architectures. Therefore it is
better to encapsulate the processing in the architecture specific cpu
drivers.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
10 years agoqemu_migration: Precreate missing storage
Michal Privoznik [Tue, 25 Nov 2014 13:19:07 +0000 (14:19 +0100)]
qemu_migration: Precreate missing storage

Based on previous commit, we can now precreate missing volumes. While
digging out the functionality from storage driver would be nicer, if
you've seen the code it's nearly impossible. So I'm going from the
other end:

1) For given disk target, disk path is looked up.
2) For the disk path, storage pool is looked up, a volume XML is
constructed and then passed to virStorageVolCreateXML() which has all
the knowledge how to create raw images, (encrypted) qcow(2) images,
etc.

One of the advantages of this approach is, we don't have to care about
image conversion - qemu does that for us. So for instance, users can
transform qcow2 into raw on migration (if the correct XML is passed to
the migration API).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_migration: Send disk sizes to the other side
Michal Privoznik [Mon, 24 Nov 2014 14:55:36 +0000 (15:55 +0100)]
qemu_migration: Send disk sizes to the other side

Up 'til now, users need to precreate non-shared storage on migration
themselves. This is not very friendly requirement and we should do
something about it. In this patch, the migration cookie is extended,
so that <nbd/> section does not only contain NBD port, but info on
disks being migrated. This patch sends a list of pairs of:

    <disk target; disk size>

to the destination. The actual storage allocation is left for next
commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks
Michal Privoznik [Mon, 1 Dec 2014 14:31:51 +0000 (15:31 +0100)]
qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks

The function queries the block devices visible to qemu
('query-block') and parses the qemu's output. The info is
returned in a hash table which is expected to be pre-filled by
qemuMonitorJSONGetAllBlockStatsInfo(). However, in the next patch
we are not going to call the latter function at all, so we should
make the former function add devices into the hash table if not
found there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: Introduce storagePoolLookupByTargetPath
Michal Privoznik [Wed, 26 Nov 2014 16:13:00 +0000 (17:13 +0100)]
storage: Introduce storagePoolLookupByTargetPath

While this could be exposed as a public API, it's not done yet as
there's no demand for that yet. Anyway, this is just preparing
the environment for easier volume creation on the destination.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoReplace virDomainSnapshotFree with virObjectUnref
John Ferlan [Mon, 1 Dec 2014 12:30:16 +0000 (07:30 -0500)]
Replace virDomainSnapshotFree with virObjectUnref

Since virDomainSnapshotFree will call virObjectUnref anyway, let's just use
that directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virInterfaceFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 17:07:19 +0000 (12:07 -0500)]
Replace virInterfaceFree with virObjectUnref

Since virInterfaceFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNWFilterFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 17:03:00 +0000 (12:03 -0500)]
Replace virNWFilterFree with virObjectUnref

Since virNWFilterFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virSecretFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 16:48:06 +0000 (11:48 -0500)]
Replace virSecretFree with virObjectUnref

Since virSecretFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStreamFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 15:19:38 +0000 (10:19 -0500)]
Replace virStreamFree with virObjectUnref

Since virStreamFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStoragePoolFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:35:12 +0000 (09:35 -0500)]
Replace virStoragePoolFree with virObjectUnref

Since virStoragePoolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStorageVolFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:26:02 +0000 (09:26 -0500)]
Replace virStorageVolFree with virObjectUnref

Since virStorageVolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNodeDeviceFree with virObjectUnref
John Ferlan [Sat, 29 Nov 2014 12:03:35 +0000 (07:03 -0500)]
Replace virNodeDeviceFree with virObjectUnref

Since virNodeDeviceFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNetworkFree with virObjectUnref
John Ferlan [Tue, 25 Nov 2014 12:42:58 +0000 (07:42 -0500)]
Replace virNetworkFree with virObjectUnref

Since virNetworkFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virDomainFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:57:02 +0000 (09:57 -0500)]
Replace virDomainFree with virObjectUnref

Since virDomainFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agorpc: Replace virXXXFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:40:31 +0000 (09:40 -0500)]
rpc: Replace virXXXFree with virObjectUnref

Modify the various virXXXFree calls to only call virObjectUnref. Calling
the public API will reset the last error thus clearing out a pending error.

10 years agoparallels: fix compilation of parallels_storage.c
Dmitry Guryanov [Tue, 18 Nov 2014 13:02:04 +0000 (16:02 +0300)]
parallels: fix compilation of parallels_storage.c

virConnect.privateData is void *, so we can't access
fields of parallelsConn, pointer to which is stored in
virConnect.privateData. So replace all occurences of
conn->privateData->storageState with privconn->storageState.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoGenerate a MAC when loading a config instead of package update
Ján Tomko [Tue, 11 Nov 2014 08:16:09 +0000 (09:16 +0100)]
Generate a MAC when loading a config instead of package update

Partially reverts commit 5754dbd.

The code in the specfile adds a MAC address to every <bridge>,
even for <forward mode='bridge'> for which we don't support
changing MAC addresses.

Remove it completely. For new networks, we have been adding
MAC addresses on definition/creation since the commit mentioned above.
For existing networks (pre-0.9.0), the MAC is added by this commit.

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

10 years agoSilently ignore MAC in NetworkLoadConfig
Ján Tomko [Mon, 10 Nov 2014 16:40:07 +0000 (17:40 +0100)]
Silently ignore MAC in NetworkLoadConfig

Libvirt's RPMs have been adding it to networks which don't support it.

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

10 years agolibvirt.c: Move virDomainGetFSInfo to libvirt-domain.c
Michal Privoznik [Tue, 2 Dec 2014 08:29:21 +0000 (09:29 +0100)]
libvirt.c: Move virDomainGetFSInfo to libvirt-domain.c

Since our big split of libvirt.c there are only a few functions
living there. The majority was moved to corresponding subfile,
e.g. domain functions were moved to libvirt-domain.c. However,
the patches for virDomainGetFSInfo() and virDomainFSInfoFree()
introduction were posted prior the big split and merged after.
This resulted in two domain functions landing in wrong file.
Move them to the correct one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonwfilter: fix crash when adding non-existing nwfilter
Pavel Hrdina [Mon, 1 Dec 2014 16:23:00 +0000 (17:23 +0100)]
nwfilter: fix crash when adding non-existing nwfilter

Adding non-existing nwfilter to a network interface device without any
nwfilter specified will crash libvirt daemon with segfault. The reason is
that the nwfilter is not found an libvirt will try to restore old
nwfilter configuration but there is no nwfilter specified.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoconf: fix a comment typo in virDomainVideoDefaultRAM
Wang Rui [Tue, 2 Dec 2014 03:55:09 +0000 (11:55 +0800)]
conf: fix a comment typo in virDomainVideoDefaultRAM

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoconf: replace call to virNetworkFree() with virObjectUnref()
Laine Stump [Tue, 25 Nov 2014 09:17:51 +0000 (04:17 -0500)]
conf: replace call to virNetworkFree() with virObjectUnref()

The function virNetworkObjListExport() in network_conf.c had a call to
the public API virNetworkFree() which was causing a link error:

CCLD     libvirt_driver_vbox_network_impl.la
 ./.libs/libvirt_conf.a(libvirt_conf_la-network_conf.o): In function `virNetworkObjListExport':
/home/laine/devel/libvirt/src/conf/network_conf.c:4496: undefined reference to `virNetworkFree'

This would happen when I added

  #include "network_conf.h"

into domain_conf.h, then attempted to call a new function from that
file (and enum converter, similar to virNetworkForwardTypeToString())

In the end, virNetworkFree() ends up just calling virObjectUnref(obj)
anyway (after clearing all pending errors, which we probably *don't*
want to do in the cleanup of a utility function), so this is likely
more correct than the original code as well.

10 years agobuild, docs: Let make see the dependencies for html/*.html
Martin Kletzander [Tue, 2 Dec 2014 06:50:18 +0000 (07:50 +0100)]
build, docs: Let make see the dependencies for html/*.html

Make was not able to realize the dependencies for html/*.html files when
running 'make -j9 dist'.  All the files are generated together with
html/index.html, so simply separating them into another variable and
adding one block into the dependency chain solves the issue.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodocs: Correct invalid hyperlinks
Martin Kletzander [Mon, 1 Dec 2014 13:36:13 +0000 (14:36 +0100)]
docs: Correct invalid hyperlinks

Since libvirt.h was split into multiple files and similarly
docs/libvirt-libvirt.html, docs/hvsupport.html have bad hyperlinks.  The
same happens for all the html.in files that used <code class='docref'>
tag, because page.xsl has no idea where to point the link that's found.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix race condition in qemuGetProcessInfo
Eduardo Costa [Mon, 1 Dec 2014 20:24:20 +0000 (18:24 -0200)]
Fix race condition in qemuGetProcessInfo

There is a race condition between the fopen and fscanf calls
in qemuGetProcessInfo. If fopen succeeds, there is a small
possibility that the file no longer exists before reading from it.
Now, if either fopen or fscanf calls fail, the function will behave
just as only fopen had failed.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: Resolve Coverity CHECKED_RETURN
John Ferlan [Mon, 1 Dec 2014 16:10:18 +0000 (11:10 -0500)]
libxl: Resolve Coverity CHECKED_RETURN

Commit id 'cb88d433' refactored the calling sequence to use a thread;
however, in doing so "lost" the check for if virNetSocketAccept returns
failure.  Since other code makes that check, Coverity complains. Although
a false positive, adding back the failure check pacifies Coverity

10 years agodomain_conf: Resolve Coverity CHECKED_RETURN
John Ferlan [Wed, 29 Oct 2014 13:25:56 +0000 (09:25 -0400)]
domain_conf: Resolve Coverity CHECKED_RETURN

Commit id '0d36a5d05' modified the code slightly, but removed the
return value check thus causing Coverity to complain that this call
was the only one where the return value wasn't checked. Since nothing
was done previously if there was a failure, just use ignore_value here
to pacify Coverity

10 years agovirhook: Resolve Coverity NULL_RETURNS
John Ferlan [Tue, 30 Sep 2014 11:01:49 +0000 (07:01 -0400)]
virhook: Resolve Coverity NULL_RETURNS

Coverity complains that many other callers to return err from
virGetLastError() will check if err is not NULL before dereferencing
it.  Just do the same here for safety.

10 years agohotplug: Resolve Coverity FORWARD_NULL
John Ferlan [Tue, 30 Sep 2014 10:55:23 +0000 (06:55 -0400)]
hotplug: Resolve Coverity FORWARD_NULL

Coverity complained that because the cfg->macFilter call checked
net->ifname != NULL before calling ebtablesRemoveForwardAllowIn, then
the virNetDevOpenvswitchRemovePort call should have the same check.

However, if I move the ebtables call prior to the check for TYPE_DIRECT
(where there is a VIR_FREE(net->ifname)), then it seems Coverity is
happy.  Since firewall info is tacked on last during setup, removing
it in the opposite order of initialization seems to be natural anyway

10 years agostorage: Add mixed fc_host/scsi_host duplicate adapter source checks
John Ferlan [Fri, 14 Nov 2014 14:50:59 +0000 (09:50 -0500)]
storage: Add mixed fc_host/scsi_host duplicate adapter source checks

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

The virStoragePoolSourceFindDuplicate only checks the incoming definition
against the same type of pool as the def; however, for "scsi_host" and
"fc_host" adapter pools, it's possible that either some pool "scsi_host"
adapter definition is already using the scsi_hostN that the "fc_host"
adapter definition wants to use or some "fc_host" pool adapter definition
is using a vHBA scsi_hostN or parent scsi_hostN that an incoming "scsi_host"
definition is trying to use.

This patch adds the mismatched type checks and adds extraneous comments
to describe what each check is determining.

This patch also modifies the documentation to be describe what scsi_hostN
devices a "scsi_host" source adapter should use and which to avoid. It also
updates the parent definition to specifically call out that for mixed
environments it's better to define which parent to use so that the duplicate
pool checks can be done properly.

10 years agostorage: Move and rename getVhbaSCSIHostParent
John Ferlan [Mon, 17 Nov 2014 13:40:59 +0000 (08:40 -0500)]
storage: Move and rename getVhbaSCSIHostParent

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

Move the API from the backend to storage_conf and rename it to
virStoragePoolGetVhbaSCSIHostParent.  A future patch will need to
use this functionality from storage_conf

10 years agoconf: Don't redefine virDomainTPMDefPtr
Martin Kletzander [Mon, 1 Dec 2014 12:19:55 +0000 (13:19 +0100)]
conf: Don't redefine virDomainTPMDefPtr

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Make pid available for security managers in qemuProcessAttach
Luyao Huang [Mon, 1 Dec 2014 09:54:35 +0000 (17:54 +0800)]
qemu: Make pid available for security managers in qemuProcessAttach

There are some small issue in qemuProcessAttach:

1.Fix virSecurityManagerGetProcessLabel always get pid = 0,
move 'vm->pid = pid' before call virSecurityManagerGetProcessLabel.

2.Use virSecurityManagerGenLabel to get image label.

3.Fix always set selinux label for other security driver label.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoconf: Add device-related code for panic devices
Martin Kletzander [Sun, 30 Nov 2014 19:54:50 +0000 (20:54 +0100)]
conf: Add device-related code for panic devices

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: Add device-related code for TPM devices
Martin Kletzander [Sun, 30 Nov 2014 19:54:50 +0000 (20:54 +0100)]
conf: Add device-related code for TPM devices

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: fix block{commit,copy} abort handling
Erik Skultety [Thu, 27 Nov 2014 12:29:42 +0000 (13:29 +0100)]
qemu: fix block{commit,copy} abort handling

When a block{commit,copy} job was aborted on a domain, block job handler
did not process it correctly, leaving a phantom job in the background.
Any further calls to any blockjob causes "block <jobtype> still active"
error. This patch fixes the blockjob handler so that it checks not only
for VIR_DOMAIN_BLOCK_JOB_FAILED status, but VIR_DOMAIN_BLOCK_JOB_CANCELED
status as well, followed by our existing cleanup routine.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun
Wang Rui [Mon, 1 Dec 2014 07:05:33 +0000 (15:05 +0800)]
qemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun

If job is failed in qemuMigrationRun, we expect the jobinfo type as
FAILED. But jobinfo type won't be updated until entering
qemuMigrationWaitForCompletion. We should make it updated in all
conditions. Moreover, we can't use qemuMigrationUpdateJobStatus
here because job may fail in libvirt, so we can't query job status
from QEMU.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoqemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions
Wang Rui [Mon, 1 Dec 2014 07:05:32 +0000 (15:05 +0800)]
qemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions

The migration job status is traced in qemuMigrationUpdateJobStatus
which is called in qemuMigrationRun. But if migration is cancelled
before the trace such as in qemuMigrationDriveMirror, the jobinfo
type won't be updated to CANCELLED. After this patch, we can get
jobinfo type CANCELLED if migration is cancelled during drive
mirror.  Moreover, we can't use qemuMigrationUpdateJobStatus
because from qemu's point of view it's just the drive mirror being
cancelled and the migration hasn't even started yet.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agodocs: Fix missing slashes in XML examples
Luyao Huang [Fri, 28 Nov 2014 06:44:24 +0000 (14:44 +0800)]
docs: Fix missing slashes in XML examples

When I pasted some XML from libvirt.org, I've found a small mistake.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemu: Don't track quiesced state of FSs
Michal Privoznik [Thu, 27 Nov 2014 10:43:56 +0000 (11:43 +0100)]
qemu: Don't track quiesced state of FSs

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

As of b6d4dad11b (1.2.5) we are trying to keep the status of FSFreeze
in the guest. Even though I've tried to fixed couple of corner cases
(6ea54769ba18), it occurred to me just recently, that the approach is
broken by design. Firstly, there are many other ways to talk to
qemu-ga (even through libvirt) that filesystems can be thawed (e.g.
qemu-agent-command) without libvirt noticing. Moreover, there are
plenty of ways to thaw filesystems without even qemu-ga noticing (yes,
qemu-ga keeps internal track of FSFreeze status). So, instead of
keeping the track ourselves, or asking qemu-ga for stale state, it's
the best to let qemu-ga deal with that (and possibly let guest kernel
propagate an error).

Moreover, there's one bug with the following approach, if fsfreeze
command failed, we've executed fsthaw subsequently. So issuing
domfsfreeze in virsh gave the following result:

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix usage of virReportSystemError
Jiri Denemark [Fri, 28 Nov 2014 08:37:42 +0000 (09:37 +0100)]
Fix usage of virReportSystemError

virReportSystemError is reserved for reporting system errors, calling it
with VIR_ERR_* error codes produces error messages that do not make any
sense, such as

    internal error: guest failed to start: Kernel doesn't support user
    namespace: Link has been severed

We should prohibit wrong usage with a syntax-check rule.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agodocs: fix simple typo in TPM paragraph
Martin Kletzander [Fri, 28 Nov 2014 08:37:09 +0000 (09:37 +0100)]
docs: fix simple typo in TPM paragraph

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agotests: fix documentation for mocking methods
Martin Kletzander [Wed, 26 Nov 2014 10:55:59 +0000 (11:55 +0100)]
tests: fix documentation for mocking methods

It looks like it was copy-pasted, so in case anyone wonders what some of
those methods do without looking at them, and for the sake of
completeness, fix them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoRevert "ip link needs 'name' in 3.16 to create the veth pair"
Martin Kletzander [Wed, 26 Nov 2014 08:25:43 +0000 (09:25 +0100)]
Revert "ip link needs 'name' in 3.16 to create the veth pair"

This reverts commit 433b427ff853ab72d32573d415e6ec569b77c7cb.

The patch was added in order to overcome a bug in iproute2 and since it
was properly identified as a bug, particularly in openSUSE 13.2, and it
is being worked on [1], the best solution for libvirt seems to be to
keep the old behaviour.

[1] https://bugzilla.novell.com/show_bug.cgi?id=907093

10 years agonetwork: Fix upgrade from libvirt older than 1.2.4
Jiri Denemark [Wed, 26 Nov 2014 15:24:27 +0000 (16:24 +0100)]
network: Fix upgrade from libvirt older than 1.2.4

Starting from libvirt-1.2.4, network state XML files moved to another
directory (see commit b9e95491) and libvirt automatically migrates the
network state files to a new location. However, the code used
dirent.d_type which is not supported by all filesystems. Thus, when
libvirt was upgraded on a host which used such filesystem, network state
XMLs were not properly moved and running networks disappeared from
libvirt.

This patch falls back to lstat() whenever dirent.d_type is DT_UNKNOWN to
fix this issue.

https://bugzilla.redhat.com/show_bug.cgi?id=1167145
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoutil: Avoid calling closedir(NULL)
Jiri Denemark [Mon, 24 Nov 2014 16:37:13 +0000 (17:37 +0100)]
util: Avoid calling closedir(NULL)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirsh: document block.n.allocation stat
Eric Blake [Mon, 24 Nov 2014 20:58:20 +0000 (13:58 -0700)]
virsh: document block.n.allocation stat

Commit 7557ddf added some additional block.* stats to
virDomainListGetStats, but failed to document them in 'man
virsh'.  Also, I noticed some inconsistent use of commas.

* tools/virsh.pod (domstats): Tweak commas, add missing stats.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodbus: fix arrays of bools
Eric Blake [Sat, 22 Nov 2014 00:03:34 +0000 (17:03 -0700)]
dbus: fix arrays of bools

Commit 2aa167ca tried to fix the DBus interaction code to allow
callers to use native types instead of 4-byte bools.  But in
fixing the issue, I missed the case of an arrayref; Conrad Meyer
shows the following valid complaint issued by clang:

  CC       util/libvirt_util_la-virdbus.lo
util/virdbus.c:956:13: error: cast from 'bool *' to 'dbus_bool_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
            GET_NEXT_VAL(dbus_bool_t, bool_val, bool, "%d");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virdbus.c:858:17: note: expanded from macro 'GET_NEXT_VAL'
            x = (dbustype *)(*xptrptr + (*narrayptr - 1));              \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

But fixing that points out that we have NEVER supported arrayrefs
of sub-int types (byte, i16, u16, and now bool).  Again, while raw
types promote, arrays do not; so the macros HAVE to deal with both
size possibilities rather than assuming that an arrayref uses the
same sizing as the promoted raw type.

Obviously, our testsuite wasn't covering as much as it should have.

* src/util/virdbus.c (GET_NEXT_VAL): Also fix array cases.
(SET_NEXT_VAL): Fix uses of sub-int arrays.
* tests/virdbustest.c (testMessageArray, testMessageArrayRef):
Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: add the missing jobinfo type in qemuDomainGetJobInfo
Wang Rui [Tue, 25 Nov 2014 11:51:45 +0000 (19:51 +0800)]
qemu: add the missing jobinfo type in qemuDomainGetJobInfo

Commit 6fcddfcd refactored job statistics but missed the jobinfo type updated
in qemuDomainGetJobInfo. After this patch, we can use virDomainGetJobInfo to
get jobinfo type again.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoResolve build breaker
John Ferlan [Tue, 25 Nov 2014 12:06:46 +0000 (07:06 -0500)]
Resolve build breaker

Commit 'c264eeaa' didn't do the prerequisite 'make syntax-check' before
pushing. There was a <tab> in the whitespace for the comment.  Replaced
with spaces and aligned.

pushed as build breaker since Jenkins complained loudly

10 years agolxc: don't unmount subtree if it contains the source of the mount
Cédric Bosdonnat [Mon, 24 Nov 2014 14:10:19 +0000 (15:10 +0100)]
lxc: don't unmount subtree if it contains the source of the mount

The typical case where we had a problem is with such a filesystem
definition as created by virt-sandbox-service:

    <filesystem type='bind' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/mysshd/var'/>
      <target dir='/var'/>
    </filesystem>

In this case, we don't want to unmount the /var subtree or we may
loose the access to the source folder.

10 years agolxc: be more patient while resolving symlinks
Cédric Bosdonnat [Fri, 21 Nov 2014 16:45:55 +0000 (17:45 +0100)]
lxc: be more patient while resolving symlinks

Resolving symlinks can fail before mounting any file system if one file
system depends on another being mounted. Symlinks are now resolved in
two passes:

  * Before any file system is mounted, but then we are more gentle if
    the source path can't be accessed
  * Right before mounting a file system, so that we are sure that we
    have the resolved path... but then if it can't be accessed we raise
    an error.

10 years agoip link needs 'name' in 3.16 to create the veth pair
Cédric Bosdonnat [Thu, 20 Nov 2014 14:26:35 +0000 (15:26 +0100)]
ip link needs 'name' in 3.16 to create the veth pair

Due to a change (or bug?) in ip link implementation, the command
    'ip link add vnet0...'
is forced into
    'ip link add name vnet0...'
The changed command also works on older versions of iproute2, just the
'name' parameter has been made mandatory.

10 years agovirt-aa-helper: /etc/libvirt-sandbox/services isn't restricted
Cédric Bosdonnat [Thu, 20 Nov 2014 10:32:38 +0000 (11:32 +0100)]
virt-aa-helper: /etc/libvirt-sandbox/services isn't restricted

To get virt-sandbox-service working with AppArmor, virt-aa-helper
needs not to choke on path in /etc/libvirt-sandbox/services.

10 years agovirt-aa-helper wasn't running virErrorInitialize
Cédric Bosdonnat [Thu, 20 Nov 2014 10:31:44 +0000 (11:31 +0100)]
virt-aa-helper wasn't running virErrorInitialize

This turns out to be working by magic but needs to be fixed.

10 years agoqemu-command: introduce new vgamem attribute for QXL video device
Pavel Hrdina [Thu, 20 Nov 2014 18:52:00 +0000 (19:52 +0100)]
qemu-command: introduce new vgamem attribute for QXL video device

Add attribute to set vgamem_mb parameter of QXL device for QEMU. This
value sets the size of VGA framebuffer for QXL device. Default value in
QEMU is 8MB so reuse it also in libvirt to not break things.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu-command: use vram attribute for all video devices
Pavel Hrdina [Thu, 20 Nov 2014 18:51:12 +0000 (19:51 +0100)]
qemu-command: use vram attribute for all video devices

So far we didn't have any option to set video memory size for qemu video
devices. There was only the vram (ram for QXL) attribute but it was valid
only for the QXL video device.

To provide this feature to users QEMU has a dedicated device attribute
called 'vgamem_mb' to set the video memory size. We will use the 'vram'
attribute for setting video memory size for other QEMU video devices.

For the cirrus device we will ignore the vram value because it has
hardcoded video size in QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agocaps: introduce new QEMU capability for vgamem_mb device property
Pavel Hrdina [Wed, 12 Nov 2014 12:58:33 +0000 (13:58 +0100)]
caps: introduce new QEMU capability for vgamem_mb device property

Allow setting vgamem size for video devices.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoQXL: fix setting ram and vram values for QEMU QXL device
Pavel Hrdina [Tue, 18 Nov 2014 16:21:48 +0000 (17:21 +0100)]
QXL: fix setting ram and vram values for QEMU QXL device

QEMU has two different type of QXL display device. The first "qxl-vga"
is for primary video device and second "qxl" is for secondary video
device.

There are also two different ways how to specify those devices on qemu
command line, the first one and obsolete is using "-vga" option and the
current new one is using "-device" option. The "-vga" could be used only
to setup primary video device, so the "-vga qxl" equal to
"-device qxl-vga". Unfortunately the "-vga qxl" doesn't support setting
additional parameters for the device and "-global" option must be used
for this purpose. It's mandatory to use "-global qxl-vga...." to set the
parameters of primary video device previously defined with "-vga qxl".

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovideo: cleanup usage of vram attribute and update documentation
Pavel Hrdina [Mon, 24 Nov 2014 10:58:53 +0000 (11:58 +0100)]
video: cleanup usage of vram attribute and update documentation

The vram attribute was introduced to set the video memory but it is
usable only for few hypervisors excluding QEMU/KVM and the old XEN
driver. Only in case of QEMU the vram was used for QXL.

This patch updates the documentation to reflect current code in libvirt
and also changes the cases when we will set the default vram attribute.
It also fixes existing strange default value for VGA devices 9MB to 16MB
because the video ram should be rounded to power of two.

The change of default value could affect migrations but I found out that
QEMU always round the video ram to power of two internally so it's safe
to change the default value to the next closest power of two and also
silently correct every domain XML definition. And it's also safe because
we don't pass the value to QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agointernal: add macro to round value to the next closest power of 2
Pavel Hrdina [Tue, 18 Nov 2014 16:13:38 +0000 (17:13 +0100)]
internal: add macro to round value to the next closest power of 2

There are two special cases, if the input number is 0 or the number is
larger then 2^31 (for 32bit unsigned int). For the special cases the
return value is 0 because they cannot be rounded.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agostorage_driver: fix a comment typo
Chen Hanxiao [Mon, 24 Nov 2014 06:13:20 +0000 (14:13 +0800)]
storage_driver: fix a comment typo

s/rereshed/refreshed

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agovirsh: expose virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:52 +0000 (20:27 -0500)]
virsh: expose virDomainGetFSInfo

Add a "domfsinfo" command that shows a list of filesystems info mounted in
the guest. For example:

virsh # domfsinfo vm1
Mountpoint                           Name     Type     Target
-------------------------------------------------------------------
/                                    sda1     ext4     hdc
/opt                                 dm-2     vfat     vda,vdb
/mnt/test                            sdb1     xfs      sda

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: add test for qemuAgentGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:45 +0000 (20:27 -0500)]
qemu: add test for qemuAgentGetFSInfo

Add test cases for qemuAgentGetFSInfo, with a sample agent response for
the qemu-get-fsinfo command and a configuration xml.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: Implement the qemu driver for virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:38 +0000 (20:27 -0500)]
qemu: Implement the qemu driver for virDomainGetFSInfo

Get mounted filesystems list, which contains hardware info of disks and its
controllers, from QEMU guest agent 2.2+. Then, convert the hardware info
to corresponding device aliases for the disks.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoremote: Implement the remote protocol for virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:31 +0000 (20:27 -0500)]
remote: Implement the remote protocol for virDomainGetFSInfo

Add daemon and driver code to (de-)serialize virDomainFSInfo.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoImplement public API for virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:25 +0000 (20:27 -0500)]
Implement public API for virDomainGetFSInfo

virDomainGetFSInfo returns a list of filesystems information mounted in the
guest, which contains mountpoints, device names, filesystem types, and
device aliases named by libvirt. This will be useful, for example, to
specify mountpoints to fsfreeze when taking snapshot of a part of disks.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: Emit the guest agent lifecycle event
Peter Krempa [Wed, 19 Nov 2014 09:31:21 +0000 (10:31 +0100)]
qemu: Emit the guest agent lifecycle event

Add code to emit the event on change of the channel state and reconnect
to the qemu process.

10 years agoexamples: Add support for the guest agent lifecycle event
Peter Krempa [Wed, 19 Nov 2014 09:27:55 +0000 (10:27 +0100)]
examples: Add support for the guest agent lifecycle event

Add code to support the event in the object-event example.

10 years agoevent: Add guest agent lifecycle event
Peter Krempa [Wed, 19 Nov 2014 09:32:20 +0000 (10:32 +0100)]
event: Add guest agent lifecycle event

As qemu is now able to notify us about change of the channel state used
for communication with the guest agent we now can more precisely track
the state of the guest agent.

To allow notifying management apps this patch implements a new event
that will be triggered on changes of the guest agent state.

10 years agospec: Automatically apply all patches with git
Jiri Denemark [Fri, 21 Nov 2014 17:09:36 +0000 (18:09 +0100)]
spec: Automatically apply all patches with git

With this change, any patch declared in libvirt.spec with Patch[0-9]* is
automatically applied in %prep. Unlike with the standard %patch[0-9]*,
patches are applied with "git am" to avoid some unexpected results.
However, as a result of this, all patches must be in the right format
for "git am" to be able to apply them; they should ideally be generated
from git using "git format-patch".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: process: Refresh virtio channel guest state when connecting to mon
Peter Krempa [Thu, 13 Nov 2014 19:16:46 +0000 (20:16 +0100)]
qemu: process: Refresh virtio channel guest state when connecting to mon

Use data provided by "query-chardev" to refresh the guest frontend state
of virtio channels.

10 years agoqemu: chardev: Extract more information about character devices
Peter Krempa [Thu, 13 Nov 2014 18:29:14 +0000 (19:29 +0100)]
qemu: chardev: Extract more information about character devices

Improve the monitor function to also retrieve the guest state of
character device (if provided) so that we can refresh the state of
virtio-serial channels and perhaps react to changes in the state in
future patches.

This patch changes the returned data from qemuMonitorGetChardevInfo to
return a structure containing the pty path and the state for all the
character devices.

The change to the testsuite makes sure that the data is parsed
correctly.

10 years agolibxl: destroy domain in migration finish phase on failure
Jim Fehlig [Thu, 13 Nov 2014 00:52:02 +0000 (17:52 -0700)]
libxl: destroy domain in migration finish phase on failure

This patch contains three domain cleanup improvements in the migration
finish phase, ensuring a domain is properly disposed when a failure is
detected or the migration is cancelled.

The check for virDomainObjIsActive is moved to libxlDomainMigrationFinish,
where cleanup can occur if migration failed and the domain is inactive.

The 'cleanup' label was missplaced in libxlDomainMigrationFinish, causing
a migrated domain to remain in the event of an error or cancelled migration.

In cleanup, the domain was not removed from the driver's list of domains.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: start domain paused on migration dst
Jim Fehlig [Thu, 13 Nov 2014 00:15:37 +0000 (17:15 -0700)]
libxl: start domain paused on migration dst

During the perform phase of migration, the domain is started on
the dst host in a running state if VIR_MIGRATE_PAUSED flag is not
specified.  In the finish phase, the domain is also unpaused if
VIR_MIGRATE_PAUSED flag is unset.  I've noticed this second unpause
fails if the domain was already unpaused following the perform phase.

This patch changes the perform phase to always start the domain
paused, and defers unpausing, if requested, to the finish phase.
Unpausing should occur in the finish phase anyhow, where the domain
can be properly destroyed if the perform phase fails and migration
is cancelled.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: acquire job in migration finish phase
Jim Fehlig [Thu, 13 Nov 2014 21:41:56 +0000 (14:41 -0700)]
libxl: acquire job in migration finish phase

Moving data reception of the perform phase of migration to a
thread introduces a race with the finish phase, where checking
if the domain is active races with the thread finishing the
perform phase.  The race is easily solved by acquiring a job in
the finish phase, which must wait for the perform phase job to
complete.

While wrapping the finish phase in a job, noticed the virDomainObj
was being unlocked in a callee - libxlDomainMigrationFinish.  Move
the unlocking to libxlDomainMigrateFinish3Params, where the lock
is acquired.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Receive migration data in a thread
Jim Fehlig [Wed, 12 Nov 2014 22:32:02 +0000 (15:32 -0700)]
libxl: Receive migration data in a thread

The libxl driver receives migration data within an IO callback invoked
by the event loop, effectively disabling the event loop while migration
occurs.

This patch moves receving of the migration data to a thread.  The
incoming connection is still accepted in the IO callback, but control
is immediately returned to the event loop after spawning the thread.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Allow libxl to find pygrub binary.
Ian Campbell [Fri, 21 Nov 2014 14:32:53 +0000 (14:32 +0000)]
libxl: Allow libxl to find pygrub binary.

Specifying an explicit path to pygrub (e.g. BINDIR "/pygrub") only works if
Xen and libvirt happen to be installed to the same prefix. A more flexible
approach is to simply specify "pygrub" which will cause libxl to use the
correct path which it knows (since it is built with the same prefix as pygrub).

This is particular problematic in the Debian packaging, since the Debian Xen
package relocates pygrub into a libexec dir, however I think this change makes
sense upstream.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agostorage: rbd: Implement support for passing config file option
Peter Krempa [Tue, 11 Nov 2014 16:31:24 +0000 (17:31 +0100)]
storage: rbd: Implement support for passing config file option

To be able to express some use cases of the RBD backing with libvirt, we
need to be able to specify a config file for the RBD client to qemu as
that is one of the commonly used options.

10 years agostorage: rbd: qemu: Add support for specifying internal RBD snapshots
Peter Krempa [Tue, 11 Nov 2014 10:35:25 +0000 (11:35 +0100)]
storage: rbd: qemu: Add support for specifying internal RBD snapshots

Some storage systems have internal support for snapshots. Libvirt should
be able to select a correct snapshot when starting a VM.

This patch adds a XML element to select a storage source snapshot for
the RBD protocol which supports this feature.

10 years agostorage: Allow parsing of RBD backing strings when building backing chain
Peter Krempa [Tue, 4 Nov 2014 16:35:16 +0000 (17:35 +0100)]
storage: Allow parsing of RBD backing strings when building backing chain

As we now have a common function to parse backing store string for RBD
backing store we can reuse it in the backing store walker so that we
don't fail on files backed by RBD storage.

This patch also adds a few tests to verify that the parsing works as
expected.