]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoutil: use string libvirt to prefix error message instead of libvir
Guannan Ren [Mon, 4 Mar 2013 12:38:18 +0000 (20:38 +0800)]
util: use string libvirt to prefix error message instead of libvir

BZ:https://bugzilla.redhat.com/show_bug.cgi?id=912021
Without error handler set, virDefaultErrorFunc will be called, the
error message is prefixed with "libvir:". It become a little better
by using prefix "libvirt:" when working with upper application.

For example:
1, stop libvirtd daemon
2, run virt-top.
libvir: XML-RPC error : Failed to connect \
        socket to '/var/run/libvirt/libvirt-sock-ro': \
        No such file or directory
libvirt: VIR_ERR_SYSTEM_ERROR: VIR_FROM_RPC: \
        Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': \
        No such file or directory

12 years agolibvirt does not logout of iscsi targets, causing system hang on shutdown
Fritz Elfert [Thu, 28 Feb 2013 20:46:19 +0000 (21:46 +0100)]
libvirt does not logout of iscsi targets, causing system hang on shutdown

There's a quite old bug entry here:

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

I just stumbled over that very issue on F18. Doing a little bit
debugging of the shutdown sequence, it turns out that - at least on my
F18 installation - libvirtd is shutdown *after* iscsid, which makes it
impossible for libvirt to perform the logout of the iscsi session properly.

This patch simply adds another startup dependancy on iscsid.service
which in turn delays iscsid shutdown until after libvirtd has stopped.
Having that applied, the system shuts down properly again.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: Remove managed save flag from VM when starting with --force-boot
Peter Krempa [Mon, 4 Mar 2013 11:10:28 +0000 (12:10 +0100)]
qemu: Remove managed save flag from VM when starting with --force-boot

At the start of the guest after the image is unlinked the state wasn't
touched up to match the state on disk.

12 years agoqemu: Use -1 as unpriviledged uid/gid
Christophe Fergeau [Sat, 2 Mar 2013 14:19:47 +0000 (15:19 +0100)]
qemu: Use -1 as unpriviledged uid/gid

Commit f506a4c1 changed virSetUIDGID() to be a noop
when uid/gid are -1, while it used to be a noop when
they are <= 0.

The changes in this commit broke creating new VMs in GNOME Boxes
as qemuDomainCheckDiskPresence gets called during domain creation/startup,
which in turn calls virFileAccessibleAs which fails after calling
virSetUIDGID(0, 0) (Boxes uses session libvirtd). virSetUIDGID is called with
(0, 0) as these are the default user/group values in virQEMUDriverConfig
for session libvirtd.

This commit changes virQEMUDriverConfigNew to use -1 as the unpriviledged
uid/gid. I've also looked at the various places where cfg->user is used,
and they all seem to handle -1 correctly.

12 years agohook: log the exit status of the hook not 256
Guido Günther [Sun, 24 Feb 2013 18:43:04 +0000 (19:43 +0100)]
hook: log the exit status of the hook not 256

Adjust the docs accordingly. See http://bugs.debian.org/701570.

12 years agovirnetdevmacvlan.c: Introduce mutex for macvlan creation
Michal Privoznik [Thu, 28 Feb 2013 14:59:01 +0000 (15:59 +0100)]
virnetdevmacvlan.c: Introduce mutex for macvlan creation

Currently, after we removed the qemu driver lock, it may happen
that two or more threads will start up a machine with macvlan and
race over virNetDevMacVLanCreateWithVPortProfile(). However,
there's a racy section in which we are generating a sequence of
possible device names and detecting if they exits. If we found
one which doesn't we try to create a device with that name.
However, the other thread is doing just the same. Assume it will
succeed and we must therefore fail. If this happens more than 5
times (which in massive parallel startup surely will) we return
-1 without any error reported. This patch is a simple hack to
both of these problems. It introduces a mutex, so only one thread
will enter the section, and if it runs out of possibilities,
error is reported. Moreover, the number of retries is raised to 20.

12 years agoRevert hack for autodestroy in qemuProcessStop
Daniel P. Berrange [Thu, 28 Feb 2013 16:43:43 +0000 (16:43 +0000)]
Revert hack for autodestroy in qemuProcessStop

This reverts the hack done in

commit 568a6cda277f04ab9baaeb97490e548b7b608aa6
Author: Jiri Denemark <jdenemar@redhat.com>
Date:   Fri Feb 15 15:11:47 2013 +0100

    qemu: Avoid deadlock in autodestroy

since we now have a fix which avoids the deadlock scenario
entirely

12 years agoFix deadlock in QEMU close callback APIs
Daniel P. Berrange [Thu, 28 Feb 2013 13:30:49 +0000 (13:30 +0000)]
Fix deadlock in QEMU close callback APIs

There is a lock ordering problem in the QEMU close callback
APIs.

When starting a guest we have a lock on the VM. We then
set a autodestroy callback, which acquires a lock on the
close callbacks.

When running auto-destroy, we obtain a lock on the close
callbacks, then run each callbacks - which obtains a lock
on the VM.

This causes deadlock if anyone tries to start a VM, while
autodestroy is taking place.

The fix is to do autodestroy in 2 phases. First obtain
all the callbacks and remove them from the list under
the close callback lock. Then invoke each callback
from outside the close callback lock.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix crash in QEMU auto-destroy with transient guests
Daniel P. Berrange [Thu, 28 Feb 2013 12:18:48 +0000 (12:18 +0000)]
Fix crash in QEMU auto-destroy with transient guests

When the auto-destroy callback runs it is supposed to return
NULL if the virDomainObjPtr is no longer valid. It was not
doing this for transient guests, so we tried to virObjectUnlock
a mutex which had been freed. This often led to a crash.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agopython: fix fd leak in generator.py
Guannan Ren [Thu, 28 Feb 2013 10:03:46 +0000 (18:03 +0800)]
python: fix fd leak in generator.py

12 years agopython: fix typoes and repeated global vars references
Guannan Ren [Thu, 28 Feb 2013 10:03:44 +0000 (18:03 +0800)]
python: fix typoes and repeated global vars references

12 years agoqemu: Make sure qemuProcessStart is run within a job
Jiri Denemark [Thu, 28 Feb 2013 11:48:01 +0000 (12:48 +0100)]
qemu: Make sure qemuProcessStart is run within a job

qemuProcessStart expects to be run with a job already set and every
caller except for qemuMigrationPrepareAny use it correctly. This bug can
be observed in libvirtd logs during incoming migration as

    warning : qemuDomainObjEnterMonitorInternal:979 : This thread seems
    to be the async job owner; entering monitor without asking for a
    nested job is dangerous

12 years agoFix starting qemu instances when apparmor driver is enabled
Jim Fehlig [Wed, 27 Feb 2013 23:32:35 +0000 (16:32 -0700)]
Fix starting qemu instances when apparmor driver is enabled

With the apparmor security driver enabled, qemu instances fail
to start

# grep ^security_driver /etc/libvirt/qemu.conf
security_driver = "apparmor"
# virsh start test-kvm
error: Failed to start domain test-kvm
error: internal error security label already defined for VM

The model field of virSecurityLabelDef object is always populated
by virDomainDefGetSecurityLabelDef(), so remove the check for a
NULL model when verifying if a label is already defined for the
instance.

Checking for a NULL model and populating it later in
AppArmorGenSecurityLabel() has been left in the code to be
consistent with virSecuritySELinuxGenSecurityLabel().

12 years agoFix a message typo
Serge Hallyn [Thu, 28 Feb 2013 22:08:43 +0000 (16:08 -0600)]
Fix a message typo

As pointed out in
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1034661
The sentence

"The function of PCI device addresses must less than 8"

does not quite make sense.  Update that to read

"The function of PCI device addresses must be less than 8"

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoqemu: Don't fail to shutdown domains with unresponsive agent
Michal Privoznik [Mon, 25 Feb 2013 17:52:12 +0000 (18:52 +0100)]
qemu: Don't fail to shutdown domains with unresponsive agent

Currently, qemuDomainShutdownFlags() chooses the agent method of
shutdown whenever the agent is configured. However, this
assumption is not enough as the guest agent may be unresponsive
at the moment. So unless guest agent method has been explicitly
requested, we should fall back to the ACPI method.

12 years agoqemu: virConnectGetVersion returns bogus value
Viktor Mihajlovski [Thu, 28 Feb 2013 10:11:17 +0000 (11:11 +0100)]
qemu: virConnectGetVersion returns bogus value

The unitialized local variable qemuVersion can cause an random value
to be returned for the hypervisor version, observable with virsh version.
Introduced by commit b46f7f4a0b96c2d2d01d64d960bd7bc90dc16b0c

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu: fix use-after-free when parsing NBD disk
Paolo Bonzini [Mon, 25 Feb 2013 17:44:20 +0000 (18:44 +0100)]
qemu: fix use-after-free when parsing NBD disk

disk->src is still used for disks->hosts->name, do not free it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agomaint: fix typo in network docs
Eric Blake [Thu, 28 Feb 2013 04:18:04 +0000 (21:18 -0700)]
maint: fix typo in network docs

* docs/formatnetwork.html.in: Spell variation correctly.

12 years agoDon't try to add non-existant devices to ACL
Daniel P. Berrange [Wed, 27 Feb 2013 16:57:16 +0000 (16:57 +0000)]
Don't try to add non-existant devices to ACL

The QEMU driver has a list of devices nodes that are whitelisted
for all guests. The kernel has recently started returning an
error if you try to whitelist a device which does not exist.
This causes a warning in libvirt logs and an audit error for
any missing devices. eg

2013-02-27 16:08:26.515+0000: 29625: warning : virDomainAuditCgroup:451 : success=no virt=kvm resrc=cgroup reason=allow vm="vm031714" uuid=9d8f1de0-44f4-a0b1-7d50-e41ee6cd897b cgroup="/sys/fs/cgroup/devices/libvirt/qemu/vm031714/" class=path path=/dev/kqemu rdev=? acl=rw

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix typo in internal VIR_QEMU_PROCESS_START_AUTODESROY constant
Daniel P. Berrange [Wed, 27 Feb 2013 16:53:08 +0000 (16:53 +0000)]
Fix typo in internal VIR_QEMU_PROCESS_START_AUTODESROY constant

s/VIR_QEMU_PROCESS_START_AUTODESROY/VIR_QEMU_PROCESS_START_AUTODESTROY/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAvoid spamming logs with cgroups warnings
Daniel P. Berrange [Wed, 27 Feb 2013 16:51:04 +0000 (16:51 +0000)]
Avoid spamming logs with cgroups warnings

The code for putting the emulator threads in a separate cgroup
would spam the logs with warnings

2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 3
2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 4
2013-02-27 16:08:26.732+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 6

This is because it has only created child cgroups for 3 of the
controllers, but was trying to move the processes from all the
controllers. The fix is to only try to move threads in the
controllers we actually created. Also remove the warning and
make it return a hard error to avoid such lazy callers in the
future.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix autodestroy of QEMU guests
Daniel P. Berrange [Wed, 27 Feb 2013 16:23:16 +0000 (16:23 +0000)]
Fix autodestroy of QEMU guests

The virQEMUCloseCallbacksRunOne method was passing a uuid string
to virDomainObjListFindByUUID, when it actually expected to get
a raw uuid buffer. This was not caught by the compiler because
the method was using a 'void *uuid' instead of first casting
it to the expected type.

This regression was accidentally caused by refactoring in

  commit 568a6cda277f04ab9baaeb97490e548b7b608aa6
  Author: Jiri Denemark <jdenemar@redhat.com>
  Date:   Fri Feb 15 15:11:47 2013 +0100

    qemu: Avoid deadlock in autodestroy

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: -numa doesn't (yet) support disjoint range
Eric Blake [Wed, 27 Feb 2013 00:43:12 +0000 (17:43 -0700)]
qemu: -numa doesn't (yet) support disjoint range

https://bugzilla.redhat.com/show_bug.cgi?id=896092 mentions that
qemu 1.4 and earlier only accept a simple start-stop range for
the cpu=... argument of -numa.  Libvirt would attempt to use
-numa cpu=1,3 for a disjoint range, which did not work as intended.

Upstream qemu will be adding a new syntax for disjoint cpu ranges
in 1.5; but the design for that syntax is still under discussion
at the time of this patch.  So for libvirt 1.0.3, it is safest to
just reject attempts to build an invalid qemu command line; in the
future, we can add a capability bit and translate to the final
accepted design for selecting a disjoint cpu range in numa.

* src/qemu/qemu_command.c (qemuBuildNumaArgStr): Reject disjoint
ranges.

12 years agoRevert "Add support for <option> tag in network config"
Laine Stump [Wed, 27 Feb 2013 15:55:24 +0000 (10:55 -0500)]
Revert "Add support for <option> tag in network config"

This reverts commit 383ebc46947b0119123880c1ff9ae345fdb8d5f6.

We decided the xml for this feature needed more thought to make sure
we are doing it the best way, in particular wrt option values that
have multiple items.

12 years agoutil: Add docs for virXMLProp string
Peter Krempa [Thu, 21 Feb 2013 10:07:55 +0000 (11:07 +0100)]
util: Add docs for virXMLProp string

To avoid confusion about usage of this function explicitly document that
this function returns copy of the attribute string.

12 years agotests: Test XML entities in source path for RNG device
Peter Krempa [Mon, 25 Feb 2013 22:18:44 +0000 (23:18 +0100)]
tests: Test XML entities in source path for RNG device

Users may want to specify XML entities in paths to devices. Ensure they
are parsed and used properly.

12 years agodocs: Fix attribute name for virtio-rng backend
Peter Krempa [Mon, 25 Feb 2013 22:03:21 +0000 (23:03 +0100)]
docs: Fix attribute name for virtio-rng backend

12 years agotests: fix leaks in storagevolxml2argvtest
Ján Tomko [Wed, 27 Feb 2013 09:11:52 +0000 (10:11 +0100)]
tests: fix leaks in storagevolxml2argvtest

Reported by John Ferlan.

12 years agolibvirt.c: Make VIR_MIGRATE_NON_SHARED_{INC,DISK} mutually exclusive
Michal Privoznik [Tue, 26 Feb 2013 16:18:08 +0000 (17:18 +0100)]
libvirt.c: Make VIR_MIGRATE_NON_SHARED_{INC,DISK} mutually exclusive

These two flags in fact are mutually exclusive. Requesting them both
doesn't make any sense regardless of hypervisor driver. Hence, we have
to make it within libvirt.c file instead of fixing it in each driver.

12 years agodoc: document new storage volume/pool types
Philipp Hahn [Tue, 26 Feb 2013 12:41:21 +0000 (13:41 +0100)]
doc: document new storage volume/pool types

Add qed for dirfs pool.
Add ocfs2 for disk pool.
Add lvm2 for disk and logical pool.
Add cifs and glusterfs for netfs pool.

Note: POOL_DISK_LVM2 can not be created by "parted mklabel", but is only
returned from auto-detection on disk pools.

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agobuild: don't use gcrypt.h without gnutls support
Eric Blake [Tue, 26 Feb 2013 23:43:03 +0000 (16:43 -0700)]
build: don't use gcrypt.h without gnutls support

Eugene Marcotte reported that if gcrypt-devel (a prereq of
gnutls-devel) is not present, then compilation fails due to
an unconditional use of <gcrypt.h>.

* src/libvirt.c (includes): Properly guard use of gcrypt.h.

12 years agoRevert "S390: domain_conf support for CCW"
Eric Blake [Tue, 26 Feb 2013 23:32:15 +0000 (16:32 -0700)]
Revert "S390: domain_conf support for CCW"

This reverts commit 0bbbd42c30543d8251536c2fa11166834c886ada.

The design for this feature is not complete, and may change the
name of the 'schid' attribute.  Revert requested by Viktor Mihajlovski.

12 years agoRevert "S390: Documentation for CCW address type"
Eric Blake [Tue, 26 Feb 2013 23:31:27 +0000 (16:31 -0700)]
Revert "S390: Documentation for CCW address type"

This reverts commit 24aa7f8d11054b7b2e643cf3cd5c80a199764af0.

The implementation to match the documentation is not complete yet,
and the final design might change the name of the 'schid' attribute.

12 years agoschema: Restrict mode to octal
Philipp Hahn [Tue, 26 Feb 2013 08:14:20 +0000 (09:14 +0100)]
schema: Restrict mode to octal

virStrToLong(..., 8, ...) already requires the mode to be octal.
Change the relax-ng schema to check for octal as well.

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agotests: skip virstoragetest on RHEL 5
Eric Blake [Tue, 26 Feb 2013 19:45:38 +0000 (12:45 -0700)]
tests: skip virstoragetest on RHEL 5

virstoragetest was failing on RHEL 5, but with no good error message:

TEST: virstoragetest
                                        0   FAIL

It turns out that qemu-img was so old, that it lacked support for
-o backing_file.  It didn't help that the test was also using
qemu-img from PATH, even after first probing for kvm-img.

* tests/virstoragetest.c (testPrepImages): Consistently use
discovered binary.  Skip instead of fail if qemu-img fails during
setup.

12 years agointerface: udev backend coverity NULL deref
Doug Goldstein [Tue, 26 Feb 2013 06:27:19 +0000 (00:27 -0600)]
interface: udev backend coverity NULL deref

This fixes a potential NULL deref identified by John Ferlan
<jferlan@redhat.com> if scandir() didn't return an expected value.

12 years agoRemove some C99 variable decls in parallels driver
Daniel P. Berrange [Tue, 26 Feb 2013 17:52:40 +0000 (17:52 +0000)]
Remove some C99 variable decls in parallels driver

The parallels storage driver declared some loop variables
inside the for(;;). This is not allowed by libvirt coding
standards

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix crash changing CDROM media
Daniel P. Berrange [Mon, 25 Feb 2013 17:22:14 +0000 (17:22 +0000)]
Fix crash changing CDROM media

This change tried to fix a crash with changing CDROM media but
failed to actually do so

  commit d0172d2b1b5d865aaa042070d7c2d00effb2ff8c
  Author: Osier Yang <jyang@redhat.com>
  Date:   Tue Feb 19 20:27:45 2013 +0800

    qemu: Remove the shared disk entry if the operation is ejecting or updating

It was still accessing disk->src, when the entire 'disk' object
has been free'd already. Even if it weren't free'd, accessing
the 'src' value of virDomainDiskDef is not allowed without
first validating disk->type is file or block. Just remove the
broken code entirely.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agotests: old automake lacks abs_builddir
Eric Blake [Tue, 26 Feb 2013 16:40:38 +0000 (09:40 -0700)]
tests: old automake lacks abs_builddir

On RHEL 5, 'make check' included failures such as:

TEST: virstoragetest
unable to create directory /virstoragedata/sub
unable to return to correct directory, refusing to clean up /virstoragedata

It turns out that with automake 1.9.x, $(abs_builddir) is not
automatically provided.  We have previously worked around this
by using `pwd` before, but because we did not do it everywhere,
we had a number of broken tests.

This patch brings RHEL 5 from 8 failed tests down to 5 (the
remaining failures may be due to bugs in the older libxml2 and
RNG schema validation available in RHEL 5, so I'm not sure if
they can be fixed in libvirt, but I'm still investigating).

* tests/Makefile.am (AM_CFLAGS): Reliably set abs_builddir.
(*_la_CFLAGS): Factor out common settings; delete when nothing
remains to be added.

12 years agotests: consistent skip messages
Eric Blake [Tue, 26 Feb 2013 16:36:27 +0000 (09:36 -0700)]
tests: consistent skip messages

On RHEL 5, I noticed this test failure message:

TEST: qemumonitorjsontest
libvirt not compiled with yajl, skippingSKIP: qemumonitorjsontest

* tests/virstoragetest.c (testPrepImages): Use simpler fputs.
* tests/qemumonitorjsontest.c (mymain): Ensure trailing newline.

12 years agolibvirt: fix error message when connection can't be opened
Ján Tomko [Tue, 26 Feb 2013 12:00:08 +0000 (13:00 +0100)]
libvirt: fix error message when connection can't be opened

VIR_ERR_NO_CONNECT already contains "no connection driver available".

This patch changes:
no connection driver available for No connection for URI hello
to:
no connection driver available for hello

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

12 years agoqemu: do not set unpriv_sgio if neither supported nor requested
Paolo Bonzini [Mon, 25 Feb 2013 16:38:32 +0000 (17:38 +0100)]
qemu: do not set unpriv_sgio if neither supported nor requested

Currently we call virSetDeviceUnprivSGIO with val == 0 if a block device
has an sgio attribute.  But for sgio='filtered', we know that a
kernel with no unpriv_sgio support will always behave as the user
wanted.  In this case, there is no need to call the function and
report a (bogus) error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agotests: uniformly report test failures
Eric Blake [Fri, 22 Feb 2013 22:42:39 +0000 (15:42 -0700)]
tests: uniformly report test failures

testutils.c likes to print summaries after a test completes,
including if it failed.  But if the test outright exit()s,
this summary is skipped.  Enforce that we return instead of exit.

* cfg.mk (sc_prohibit_exit_in_tests): New syntax check.
* tests/commandhelper.c (main): Fix offenders.
* tests/qemumonitorjsontest.c (mymain): Likewise.
* tests/seclabeltest.c (main): Likewise.
* tests/securityselinuxlabeltest.c (mymain): Likewise.
* tests/securityselinuxtest.c (mymain): Likewise.
* tests/testutils.h (VIRT_TEST_MAIN_PRELOAD): Likewise.
* tests/testutils.c (virtTestMain): Likewise.
(virtTestCaptureProgramOutput): Use symbolic name.

12 years agotests: don't test json when not compiled in
Eric Blake [Fri, 22 Feb 2013 22:28:53 +0000 (15:28 -0700)]
tests: don't test json when not compiled in

Now that the segfault is solved, we can skip instead of fail
the test when yajl is not present.

* tests/qemumonitorjsontest.c (mymain): Skip if no yajl.

12 years agotests: avoid segfault if json monitor not present
Eric Blake [Fri, 22 Feb 2013 21:56:21 +0000 (14:56 -0700)]
tests: avoid segfault if json monitor not present

On a machine without yajl headers, I was seeing random segfaults
from qemumonitorjsontest (about 90% of the runs on my particular
machine).  The segfault was inside virClassIsDerivedFrom, which
points to a case of a race leading to unreferencing a stale
pointer to an object that had already been freed.  I also noticed
that if I got the segfault, I was seeing messages such as:

2013-02-22 16:12:37.504+0000: 19833: error : virNetSocketWriteWire:1361 : Cannot write data: Bad file descriptor

which is also evidence of deferencing a stale pointer.  I traced it
to a race where qemuMonitorTestIO could execute late, after the
main thread had already called qemuMonitorTestFree and called
virNetSocketClose(test->client) but not clearing it out to NULL.
Sure enough, after test->client has been closed, fd is -1, which
causes an attempt to write to the socket to fail, which in turn
triggers the error code of qemuMonitorTestIO that tries to re-close
test->client.

* tests/qemumonitortestutils.c (qemuMonitorTestIO): Don't attempt
to free client again if test already quit.

12 years agoqemu: minor monitor lock cleanups
Eric Blake [Fri, 22 Feb 2013 20:19:43 +0000 (13:19 -0700)]
qemu: minor monitor lock cleanups

If virCondInit fails (okay, so that's unlikely), then we end up
attempting a virObjectUnlock() on the cleanup path, even though
we don't hold a lock.  This is not guaranteed to be safe.  While
at it, I noticed a couple places where we were referencing mon->fd
outside locks.

* src/qemu/qemu_monitor.c (qemuMonitorOpenInternal): Minimize lock
duration.  mon->watch doesn't need clean up on error.
(qemuMonitorGetBlockExtent, qemuMonitorBlockResize): Don't
dereference fd outside of lock.

12 years agoqemu: don't override earlier json error
Eric Blake [Fri, 22 Feb 2013 16:41:38 +0000 (09:41 -0700)]
qemu: don't override earlier json error

I built without yajl support, and noticed a strange failure message
in qemumonitorjsontest:

2013-02-22 16:12:37.503+0000: 19812: error : virJSONValueToString:1119 : internal error No JSON parser implementation is available
2013-02-22 16:12:37.503+0000: 19812: error : qemuMonitorJSONCommandWithFd:253 : out of memory

While a later patch will fix the test to skip when json is not present,
this patch avoids overriding the more useful error message from
virJSONValueToString returning NULL.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONCommandWithFd):
Don't override message.
(qemuMonitorJSONCheckError): Don't print NULL.
* src/qemu/qemu_agent.c (qemuAgentCommand): Don't override message.
(qemuAgentCheckError): Don't print NULL.
(qemuAgentArbitraryCommand): Properly fail on OOM.

12 years agoconf: Avoid leaking of RNG device definition
Peter Krempa [Mon, 25 Feb 2013 21:31:11 +0000 (22:31 +0100)]
conf: Avoid leaking of RNG device definition

12 years agoqemu: Refactor qemuDomainSetMemoryParameters
Peter Krempa [Mon, 18 Feb 2013 15:13:04 +0000 (16:13 +0100)]
qemu: Refactor qemuDomainSetMemoryParameters

The new TypedParam helper APIs allow to simplify this function
significantly.

This patch integrates the fix in 75e5bec97b3045e4f926248d5c742f8a50d0f9
by correctly ordering the setting functions instead of reordering the
parameters.

12 years agointerface: Fix udev backend bridge device display
Doug Goldstein [Mon, 25 Feb 2013 02:31:03 +0000 (20:31 -0600)]
interface: Fix udev backend bridge device display

The bridge device was showing the vnet devices created for the domains
as connected to the bridge. libvirt should only show host devices when
trying to get the interface definition rather than the domain devices as
well.

12 years agostorage: cast -1 for uid_t|gid_t
Philipp Hahn [Fri, 22 Feb 2013 16:41:32 +0000 (17:41 +0100)]
storage: cast -1 for uid_t|gid_t

uid_t and gid_t are opaque types, ranging from s32 to u32 to u64.

Explicitly cast the magic -1 to the appropriate type.

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agostorage: Cast uid_t|gid_t to unsigned int
Philipp Hahn [Fri, 22 Feb 2013 16:43:15 +0000 (17:43 +0100)]
storage: Cast uid_t|gid_t to unsigned int

uid_t and gid_t are opaque types, ranging from s32 to u32 to u64.

Explicitly cast them to unsigned int for printing.

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agoutil: Fix printf format for uid_t|gid_t
Philipp Hahn [Fri, 22 Feb 2013 16:36:30 +0000 (17:36 +0100)]
util: Fix printf format for uid_t|gid_t

The uid_t|gid_t values are explicitly casted to "unsigned long", but the
printf() still used "%d", which is for signed values.

Change the format to "%u".

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agotests: Add tests for virtio-rng device handling
Peter Krempa [Tue, 12 Feb 2013 16:56:00 +0000 (17:56 +0100)]
tests: Add tests for virtio-rng device handling

Adds XML parsing and qemu commandline tests for the VirtIO RNG device
support.

12 years agoqemu: Implement support for EGD backend for virtio-rng
Peter Krempa [Wed, 13 Feb 2013 10:22:23 +0000 (11:22 +0100)]
qemu: Implement support for EGD backend for virtio-rng

This patch adds a new capability bit QEMU_CAPS_OBJECT_RNG_EGD and code
to support the egd backend for the VirtIO RNG device.

The device is added by 3 qemu command line options:
-chardev socket,id=charrng0,host=1.2.3.4,port=1234 (communication
                                                    backend)
-object rng-egd,chardev=charrng0,id=rng0 (RNG protocol client)
-device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4 (the RNG device)

12 years agoqemu: Implement support for default 'random' backend for virtio-rng
Peter Krempa [Fri, 11 Jan 2013 16:48:21 +0000 (17:48 +0100)]
qemu: Implement support for default 'random' backend for virtio-rng

This patch implements support for the virtio-rng-pci device and the
rng-random backend in qemu.

Two capabilities bits are added to track support for those:

QEMU_CAPS_DEVICE_VIRTIO_RNG - for the device support and
QEMU_CAPS_OBJECT_RNG_RANDOM - for the backend support.

qemu is invoked with these additional parameters if the device is
enabled:

-object rng-random,id=rng0,filename=/test/phile (to add the backend)
-device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4 (to add the device)

12 years agoconf: Add RNG device ABI compatibility check
Peter Krempa [Thu, 7 Feb 2013 15:27:44 +0000 (16:27 +0100)]
conf: Add RNG device ABI compatibility check

12 years agoconf: Add support for RNG device configuration in XML
Peter Krempa [Fri, 11 Jan 2013 16:34:37 +0000 (17:34 +0100)]
conf: Add support for RNG device configuration in XML

This patch adds basic configuration support for the RNG device
supporting the virtio model with the "random" and "egd" backend types as
described in the schema in the previous patch.

12 years agodoc: schema: Add basic documentation for the virtual RNG device support
Peter Krempa [Thu, 20 Dec 2012 11:06:52 +0000 (12:06 +0100)]
doc: schema: Add basic documentation for the virtual RNG device support

This patch documents XML elements used for (basic) support of virtual
RNG devices.

In the devices section in the domain XML users may specify:

For the default 'random' backend:
  <devices>
    <rng model='virtio'>
      <backend model='random'>/dev/urandom</backend>
    </rng>
  </devices>

For the slightly more advanced EGD backend:
  <devices>
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <!-- this is a definition of a character device -->
        <source mode='bind' service='1234'/>
        <source mode='connect' host='1.2.3.4' service='1234'/>
        <!-- or other valid character device configuration -->
      </backend>
    </rng>
  </devices>

For the planned random daemon/pool:
  <devices>
    <rng model='virtio'>
      <backend model='pool' pool='poolname'>class</backend>
    </rng>
  </devices>

to enable the RNG device for guests.

12 years agoconf: Add fake switch statement to warn for new device types
Peter Krempa [Thu, 21 Feb 2013 11:37:59 +0000 (12:37 +0100)]
conf: Add fake switch statement to warn for new device types

This patch adds a fake switch statement to force the compiler to warn
after a new device type was added. This should remind the contributor to
add the new device also to this iterator function.

12 years agouse client id for IPv6 DHCP host definition
Gene Czarcinski [Fri, 15 Feb 2013 19:02:26 +0000 (14:02 -0500)]
use client id for IPv6 DHCP host definition

Originally, only a host name was used to associate a
DHCPv6 request with a specific IPv6 address.  Further testing
demonstrates that this is an unreliable method and, instead,
a client-id or DUID needs to be used.  According to DHCPv6
standards, this id can be a duid-LLT, duid-LL, or duid-UUID
even though dnsmasq will accept almost any text string.

Although validity checking of a specified string makes sure it is
hexadecimal notation with bytes separated by colons, there is no
rigorous check to make sure it meets the standard.

Documentation and schemas have been updated.

Signed-off-by: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agoTrivial fix: in dhcp-host the name is optional
Gene Czarcinski [Fri, 15 Feb 2013 19:02:25 +0000 (14:02 -0500)]
Trivial fix: in dhcp-host the name is optional

Although in IPv4 one must pick either mac or name, either
can be omitted.  Similarly, for IPv6, the name
can be optionally omitted.

Signed-off-by: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agoutil: fix typo in comment
Laine Stump [Sat, 23 Feb 2013 15:30:38 +0000 (10:30 -0500)]
util: fix typo in comment

12 years agostorage: qemu-img: change INFO to DEBUG
Ján Tomko [Mon, 18 Feb 2013 13:48:20 +0000 (14:48 +0100)]
storage: qemu-img: change INFO to DEBUG

For really old qemu-img binaries which do not support specifying
the format of the backing file, display a DEBUG message instead of
INFO that this can't be done.

12 years agostorage: move qemu-img options before positional arguments
Ján Tomko [Mon, 18 Feb 2013 13:45:03 +0000 (14:45 +0100)]
storage: move qemu-img options before positional arguments

Modify the expected output of storagevolxml2argv tests as well.

12 years agostorage: add test for qemu-img command line generation
Ján Tomko [Mon, 18 Feb 2013 12:43:28 +0000 (13:43 +0100)]
storage: add test for qemu-img command line generation

12 years agostorage: separate qemu-img command generation and execution
Ján Tomko [Mon, 18 Feb 2013 11:52:58 +0000 (12:52 +0100)]
storage: separate qemu-img command generation and execution

This allows us to create a test for the generated command line.

12 years agostorage: move flag setting after declarations
Ján Tomko [Mon, 18 Feb 2013 11:50:46 +0000 (12:50 +0100)]
storage: move flag setting after declarations

12 years agorun: license as LGPL
Eric Blake [Sat, 23 Feb 2013 00:10:48 +0000 (17:10 -0700)]
run: license as LGPL

It makes no sense to prohibit reuse of the wrapper in other LGPL
projects, since most of libvirt is designed to be LGPL.  Of
course, when using the wrapper to wrap a GPL program, the combined
result is still effectively GPL, but that shouldn't force us to
license the wrapper as GPL in isolation.

* run.in: Relicense to LGPLv2+.

12 years agoqemu_migration: Cancel running jobs on failed migration
Michal Privoznik [Wed, 30 Jan 2013 16:53:37 +0000 (17:53 +0100)]
qemu_migration: Cancel running jobs on failed migration

If a migration fails, we need to stop all block jobs running so
qemu doesn't try to send data to destination over and over again.

12 years agoqemu_migration: Stop NBD server at Finish phase
Michal Privoznik [Tue, 27 Nov 2012 15:34:24 +0000 (16:34 +0100)]
qemu_migration: Stop NBD server at Finish phase

At the end of migration, it is important to stop NBD
server and thus release all allocated resources.

12 years agoqemu_migration: Introduce qemuMigrationDriveMirror
Michal Privoznik [Fri, 23 Nov 2012 14:42:51 +0000 (15:42 +0100)]
qemu_migration: Introduce qemuMigrationDriveMirror

This function does the source part of NBD magic. It
invokes drive-mirror on each non shared and RW disk with
a source and wait till the mirroring process completes.
When it does we can proceed with migration.

Currently, an active waiting is done: every 500ms libvirt
asks qemu if block-job is finished or not.  However, once
the job finishes, qemu doesn't report its progress so we
can only assume if the job finished successfully or not.
The better solution would be to listen to the event which
is sent as soon as the job finishes. The event does
contain the result of job.

12 years agoqemu_migration: Introduce qemuMigrationStartNBDServer()
Michal Privoznik [Thu, 31 Jan 2013 13:48:06 +0000 (14:48 +0100)]
qemu_migration: Introduce qemuMigrationStartNBDServer()

We need to start NBD server and feed it with all non-<shared/>,
RW and source-full disks. Moreover, with new virPortAllocator we
must ensure the borrowed port for NBD server will be returned if
either migration completes or qemu process is torn down.

12 years agoqemu: Introduce nbd-server-stop command
Michal Privoznik [Thu, 31 Jan 2013 13:47:49 +0000 (14:47 +0100)]
qemu: Introduce nbd-server-stop command

This will be used after all migration work is done
to stop NBD server running on destination.  It
doesn't take any arguments, just issues a command.

12 years agoqemu: Introduce nbd-server-add command
Michal Privoznik [Thu, 22 Nov 2012 15:17:13 +0000 (16:17 +0100)]
qemu: Introduce nbd-server-add command

This will be used with new migration scheme.
This patch creates basically just monitor stub
functions. Wiring them into something useful
is done in later patches.

12 years agoqemu: Introduce nbd-server-start command
Michal Privoznik [Thu, 22 Nov 2012 15:08:52 +0000 (16:08 +0100)]
qemu: Introduce nbd-server-start command

This will be used with new migration scheme.
This patch creates basically just monitor stub
functions. Wiring them into something useful
is done in later patches.

12 years agoIntroduce NBD migration cookie
Michal Privoznik [Tue, 29 Jan 2013 12:38:50 +0000 (13:38 +0100)]
Introduce NBD migration cookie

This migration cookie is meant for two purposes. The first is to be sent
in begin phase from source to destination to let it know we support new
implementation of VIR_MIGRATE_NON_SHARED_{DISK,INC} so destination can
start NBD server. Then, the second purpose is, destination can let us
know, on which port the NBD server is running.

12 years agoqemu: Introduce NBD_SERVER capability
Michal Privoznik [Wed, 21 Nov 2012 13:28:44 +0000 (14:28 +0100)]
qemu: Introduce NBD_SERVER capability

This just keeps track whether qemu knows nbd-server-* commands
so we can use it during migration or not.

12 years agoAdd support for <option> tag in network config
Pieter Hollants [Thu, 21 Feb 2013 22:40:17 +0000 (23:40 +0100)]
Add support for <option> tag in network config

This patch adds support for a new <option>-Tag in the <dhcp> block of
network configs, based on a subset of the fifth proposal by Laine
Stump in the mailing list discussion at
https://www.redhat.com/archives/libvir-list/2012-November/msg01054.html.
Any such defined option will result in a dhcp-option=<number>,"<value>"
statement in the generated dnsmasq configuration file.

Currently, DHCP options can be specified by number only and there is
no whitelisting or blacklisting of option numbers, which should
probably be added.

Signed-off-by: Pieter Hollants <pieter@hollants.com>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agorun: use portable shell
Eric Blake [Sat, 23 Feb 2013 00:10:48 +0000 (17:10 -0700)]
run: use portable shell

Nothing in run required bash, except for the shebang.  On systems
where /bin/bash doesn't exist (I hit it on FreeBSD), using /bin/sh
instead fixes a 'make check' failure:
gmake[3]: Entering directory `/usr/home/dummy/libvirt/python'
  GEN    check-local
/usr/local/bin/bash: ../run: /bin/bash: bad interpreter: No such file or directory

* run.in: Use /bin/sh, not bash.

12 years agostorage: use f_frsize, not f_bsize, for calculating available space
Sage Weil [Fri, 22 Feb 2013 23:43:00 +0000 (15:43 -0800)]
storage: use f_frsize, not f_bsize, for calculating available space

The bfree and blocks fields are supposed to be in units of frsize.  We were
calculating capacity correctly using those units, but the available
calculation was using bsize instead.  Most file systems report these as the
same value specifically because many programs are buggy, but that is no
reason to rely on that behavior, or to behave inconsistently.

This bug has been present since e266ded (2008) and aa296e6c, when the code
was originally introduced (the latter via cut and paste).

Signed-off-by: Sage Weil <sage@newdream.net>
12 years agomaint: check all symfiles for sorting
Eric Blake [Fri, 22 Feb 2013 23:46:25 +0000 (16:46 -0700)]
maint: check all symfiles for sorting

On FreeBSD, I got a 'make check' failure:
  GEN    check-symsorting
Symbol block at ./libvirt_atomic.syms:4: viratomic.h not found

* src/Makefile.am (SYM_FILES): New define.
(check-symsorting): Check on all symfiles, even when not used.
* src/libvirt_atomic.syms: Fix offender.

12 years agoqemu: Implement virDomainMigrate*CompressionCache
Jiri Denemark [Mon, 18 Feb 2013 20:54:58 +0000 (21:54 +0100)]
qemu: Implement virDomainMigrate*CompressionCache

12 years agovirsh: Add migrate-compcache command
Jiri Denemark [Mon, 18 Feb 2013 20:14:49 +0000 (21:14 +0100)]
virsh: Add migrate-compcache command

This is a command wrapping virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache.

12 years agoremote: Implement virDomainMigrate*CompressionCache
Jiri Denemark [Mon, 18 Feb 2013 19:20:04 +0000 (20:20 +0100)]
remote: Implement virDomainMigrate*CompressionCache

12 years agopython: Implement virDomainMigrateGetCompressionCache wrapper
Jiri Denemark [Mon, 18 Feb 2013 22:20:48 +0000 (23:20 +0100)]
python: Implement virDomainMigrateGetCompressionCache wrapper

12 years agoIntroduce virDomainMigrate*CompressionCache APIs
Jiri Denemark [Mon, 18 Feb 2013 16:31:08 +0000 (17:31 +0100)]
Introduce virDomainMigrate*CompressionCache APIs

Introduce virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache APIs.

12 years agoqemu: Implement virDomainGetJobStats
Jiri Denemark [Tue, 12 Feb 2013 19:29:17 +0000 (20:29 +0100)]
qemu: Implement virDomainGetJobStats

12 years agoqemu: Parse more fields from query-migrate QMP command
Jiri Denemark [Fri, 8 Feb 2013 08:58:03 +0000 (09:58 +0100)]
qemu: Parse more fields from query-migrate QMP command

As a side effect, this also fixes reporting disk migration process.
It was added to memory migration progress, which was wrong. Disk
progress has dedicated fields in virDomainJobInfo structure.

12 years agovirsh: Use virDomainGetJobStats in domjobinfo if available
Jiri Denemark [Fri, 8 Feb 2013 08:55:17 +0000 (09:55 +0100)]
virsh: Use virDomainGetJobStats in domjobinfo if available

12 years agoremote: Implement virDomainGetJobStats
Jiri Denemark [Wed, 30 Jan 2013 09:49:28 +0000 (10:49 +0100)]
remote: Implement virDomainGetJobStats

12 years agoremote: Auto-allocate params in remoteDeserializeTypedParameters
Jiri Denemark [Wed, 30 Jan 2013 09:28:54 +0000 (10:28 +0100)]
remote: Auto-allocate params in remoteDeserializeTypedParameters

remoteDeserializeTypedParameters can now be called with either
preallocated params array (size of which is announced by nparams) or it
can allocate params array according to the number of parameters received
from the server.

12 years agopython: Implement virDomainGetJobStats wrapper
Jiri Denemark [Mon, 18 Feb 2013 22:20:08 +0000 (23:20 +0100)]
python: Implement virDomainGetJobStats wrapper

12 years agoIntroduce virDomainGetJobStats API
Jiri Denemark [Fri, 25 Jan 2013 23:30:49 +0000 (00:30 +0100)]
Introduce virDomainGetJobStats API

This is an extensible version of virDomainGetJobInfo.

12 years agoqemu: Add support for compressed migration
Jiri Denemark [Mon, 14 Jan 2013 11:45:20 +0000 (12:45 +0100)]
qemu: Add support for compressed migration

12 years agoIntroduce VIR_MIGRATE_COMPRESSED flag
Jiri Denemark [Thu, 10 Jan 2013 12:39:34 +0000 (13:39 +0100)]
Introduce VIR_MIGRATE_COMPRESSED flag

This flag may be used with migration APIs to request compression of
migration data.

12 years agos/arm/armv7l/ in caps-qemu-kvm.xml
Daniel P. Berrange [Fri, 22 Feb 2013 15:49:51 +0000 (15:49 +0000)]
s/arm/armv7l/ in caps-qemu-kvm.xml

Fix the caps-qemu-kvm.xml test data file to refer to correct
arm arch name.

12 years agoUpdate arch names in RNG schema to match virarch.c
Daniel P. Berrange [Thu, 21 Feb 2013 11:20:25 +0000 (11:20 +0000)]
Update arch names in RNG schema to match virarch.c

When the virarch.c file was introduced to formalize the arch
list, we forgot to update the RNG schema with the new arches.

12 years agoconf: Don't leak 'ram' video property on error
Christophe Fergeau [Thu, 21 Feb 2013 15:21:31 +0000 (16:21 +0100)]
conf: Don't leak 'ram' video property on error

It's only freed on normal returns from virDomainVideoDefParseXML,
but not when erroring out.

12 years agoconf: Don't leak 'primary' video property on error
Christophe Fergeau [Thu, 21 Feb 2013 15:21:31 +0000 (16:21 +0100)]
conf: Don't leak 'primary' video property on error

It's only freed on normal returns from virDomainVideoDefParseXML,
but not when erroring out.