]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
11 years agospec: Don't save/restore running VMs on libvirt-client update
Cole Robinson [Thu, 21 Nov 2013 20:04:35 +0000 (15:04 -0500)] 
spec: Don't save/restore running VMs on libvirt-client update

Restarting an active libvirt-guests.service is the equivalent of
doing:

/usr/libexec/libvirt-guests.sh stop
/usr/libexec/libvirt-guests.sh start

Which in a default configuration will managedsave every running VM,
and then restore them. Certainly not something we should do every
time the libvirt-client RPM is updated.

Just drop the try-restart attempt, I don't know what purpose it
serves anyways.

https://bugzilla.redhat.com/show_bug.cgi?id=962225
(cherry picked from commit d65e0e1466b09964b85c79b8cc78be454df53583)

11 years agoFix busy wait loop in LXC container I/O handling
Daniel P. Berrange [Fri, 1 Nov 2013 16:24:30 +0000 (16:24 +0000)] 
Fix busy wait loop in LXC container I/O handling

If the host side of an LXC container console disconnected
and the guest side continued to write data, until the PTY
buffer filled up, the LXC controller would busy wait. It
would repeatedly see POLLHUP from poll() and not disable
the watch.

This was due to some bogus logic detecting blocking
conditions. Upon seeing a POLLHUP we must disable all
reading & writing from the PTY, and setup the epoll to
wake us up again when the connection comes back.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 5087a5a0092853702eb5e0c0297937a7859bcab3)

11 years agolibvirt-guests: Run only after libvirtd
Cole Robinson [Tue, 19 Nov 2013 20:19:25 +0000 (15:19 -0500)] 
libvirt-guests: Run only after libvirtd

Possible fix for occasional libvirt-guests failure at boot time:

https://bugzilla.redhat.com/show_bug.cgi?id=906009
(cherry picked from commit d92036754a70098377798d93cb6d20378959e3a7)

11 years agoDon't depend on syslog.service
Guido Günther [Mon, 11 Nov 2013 08:36:41 +0000 (09:36 +0100)] 
Don't depend on syslog.service

Syslog is socket activated since at least systemd v35 so we can drop
this dependency. Debian's linitian otherwise complains about it.

References:

    http://www.freedesktop.org/wiki/Software/systemd/syslog/
    http://lintian.debian.org/tags/systemd-service-file-refers-to-obsolete-target.html

(cherry picked from commit 3c9e40a1e8762f039874aab5d181864de79be069)

11 years agoFix migration with QEMU 1.6
Michael Avdienko [Fri, 15 Nov 2013 11:47:43 +0000 (20:47 +0900)] 
Fix migration with QEMU 1.6

QEMU 1.6.0 introduced new migration status: setup
Libvirt does not expect such string in QMP and refuses to migrate with error
"unexpected migration status in setup"

This patch fixes it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit d35ae4143d11f45856ae002fcd419da0eb9bba9f)

11 years agolibxl: fix dubious cpumask handling in libxlDomainSetVcpuAffinities
Jeremy Fitzhardinge [Wed, 30 Oct 2013 17:38:08 +0000 (10:38 -0700)] 
libxl: fix dubious cpumask handling in libxlDomainSetVcpuAffinities

Rather than casting the virBitmap pointer to uint8_t* and then using
the structure contents as a byte array, use the virBitmap API to determine
the bitmap size and test each bit.

Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
(cherry picked from commit ba1bf10063a0205c1de12b209b0282833710214f)

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

This should resolve:

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

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

(cherry picked from commit e4e73337e5a5aa708bb356751404ab8ae6583f42)

11 years agoDisable nwfilter driver when running unprivileged
Ján Tomko [Tue, 12 Nov 2013 12:18:54 +0000 (13:18 +0100)] 
Disable nwfilter driver when running unprivileged

When opening a new connection to the driver, nwfilterOpen
only succeeds if the driverState has been allocated.

Move the privilege check in driver initialization before
the state allocation to disable the driver.

This changes the nwfilter-define error from:
error: cannot create config directory (null): Bad address
To:
this function is not supported by the connection driver:
virNWFilterDefineXML

https://bugzilla.redhat.com/show_bug.cgi?id=1029266
(cherry picked from commit b7829f959b33c6e32422222a9ed745c0da7dc696)

11 years agoqemu: don't use deprecated -no-kvm-pit-reinjection
Ján Tomko [Mon, 1 Jul 2013 16:28:50 +0000 (18:28 +0200)] 
qemu: don't use deprecated -no-kvm-pit-reinjection

Since qemu-kvm 1.1 [1] (since 1.3. in upstream QEMU [2])
'-no-kvm-pit-reinjection' has been deprecated.
Use -global kvm-pit.lost_tick_policy=discard instead.

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

[1] http://git.kernel.org/cgit/virt/kvm/qemu-kvm.git/commit/?id=4e4fa39
[2] http://git.qemu.org/?p=qemu.git;a=commitdiff;h=c21fb4f

(cherry picked from commit 1569fa14d8f6b6636cf78d7ee62ae3bd205f5638)

Conflicts:
tests/qemucapabilitiesdata/caps_1.2.2-1.caps
tests/qemucapabilitiesdata/caps_1.2.2-1.replies
tests/qemucapabilitiesdata/caps_1.3.1-1.caps
tests/qemucapabilitiesdata/caps_1.3.1-1.replies
tests/qemucapabilitiesdata/caps_1.4.2-1.caps
tests/qemucapabilitiesdata/caps_1.4.2-1.replies
tests/qemucapabilitiesdata/caps_1.5.3-1.caps
tests/qemucapabilitiesdata/caps_1.5.3-1.replies
tests/qemucapabilitiesdata/caps_1.6.0-1.caps
tests/qemucapabilitiesdata/caps_1.6.0-1.replies
tests/qemucapabilitiesdata/caps_1.6.50-1.caps
tests/qemucapabilitiesdata/caps_1.6.50-1.replies
(qemucapabilitiestest is not backported)

11 years agoqemu: Don't access vm->priv on unlocked domain
Michal Privoznik [Wed, 6 Nov 2013 10:46:06 +0000 (11:46 +0100)] 
qemu: Don't access vm->priv on unlocked domain

Since 86d90b3a (yes, my patch; again) we are supporting NBD storage
migration. However, on error recovery path we got the steps reversed.
The correct order is: return NBD port to the virPortAllocator and then
either unlock the vm or remove it from the driver. Not vice versa.

==11192== Invalid write of size 4
==11192==    at 0x11488559: qemuMigrationPrepareAny (qemu_migration.c:2459)
==11192==    by 0x11488EA6: qemuMigrationPrepareDirect (qemu_migration.c:2652)
==11192==    by 0x114D1509: qemuDomainMigratePrepare3Params (qemu_driver.c:10332)
==11192==    by 0x519075D: virDomainMigratePrepare3Params (libvirt.c:7290)
==11192==    by 0x1502DA: remoteDispatchDomainMigratePrepare3Params (remote.c:4798)
==11192==    by 0x12DECA: remoteDispatchDomainMigratePrepare3ParamsHelper (remote_dispatch.h:5741)
==11192==    by 0x5212127: virNetServerProgramDispatchCall (virnetserverprogram.c:435)
==11192==    by 0x5211C86: virNetServerProgramDispatch (virnetserverprogram.c:305)
==11192==    by 0x520A8FD: virNetServerProcessMsg (virnetserver.c:165)
==11192==    by 0x520A9E1: virNetServerHandleJob (virnetserver.c:186)
==11192==    by 0x50DA78F: virThreadPoolWorker (virthreadpool.c:144)
==11192==    by 0x50DA11C: virThreadHelper (virthreadpthread.c:161)
==11192==  Address 0x1368baa0 is 576 bytes inside a block of size 688 free'd
==11192==    at 0x4A07F5C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11192==    by 0x5079A2F: virFree (viralloc.c:580)
==11192==    by 0x11456C34: qemuDomainObjPrivateFree (qemu_domain.c:267)
==11192==    by 0x50F41B4: virDomainObjDispose (domain_conf.c:2034)
==11192==    by 0x50C2991: virObjectUnref (virobject.c:262)
==11192==    by 0x50F4CFC: virDomainObjListRemove (domain_conf.c:2361)
==11192==    by 0x1145C125: qemuDomainRemoveInactive (qemu_domain.c:2087)
==11192==    by 0x11488520: qemuMigrationPrepareAny (qemu_migration.c:2456)
==11192==    by 0x11488EA6: qemuMigrationPrepareDirect (qemu_migration.c:2652)
==11192==    by 0x114D1509: qemuDomainMigratePrepare3Params (qemu_driver.c:10332)
==11192==    by 0x519075D: virDomainMigratePrepare3Params (libvirt.c:7290)
==11192==    by 0x1502DA: remoteDispatchDomainMigratePrepare3Params (remote.c:4798)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 1f2f879ed17a784559f67b0fa2408d2436b731fd)

11 years agovirpci: Don't error on unbinded devices
Michal Privoznik [Thu, 31 Oct 2013 10:32:58 +0000 (10:32 +0000)] 
virpci: Don't error on unbinded devices

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

If a PCI deivce is not binded to any driver (e.g. there's yet no PCI
driver in the linux kernel) but still users want to passthru the device
we fail the whole operation as we fail to resolve the 'driver' link
under the PCI device sysfs tree. Obviously, this is not a fatal error
and it shouldn't be error at all.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit df4283a55bf3516b333352e2052dbe3317936953)

11 years agovirSecurityLabelDefParseXML: Don't parse label on model='none'
Michal Privoznik [Mon, 11 Nov 2013 08:58:31 +0000 (09:58 +0100)] 
virSecurityLabelDefParseXML: Don't parse label on model='none'

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

If there's the following snippet in the domain XML, the domain will be
lost upon the daemon restart (if the domain is started prior restart):

    <seclabel type='dynamic' relabel='yes'/>

The problem is, the 'label', 'imagelabel' and 'baselabel' are parsed
whenever the VIR_DOMAIN_XML_INACTIVE is *not* present or the label is
static. The latter is not our case, obviously. So, when libvirtd starts
up, it finds domain state xml and parse it. During parsing, many XML
flags are enabled but VIR_DOMAIN_XML_INACTIVE. Hence, our parser tries
to extract 'label', 'imagelabel' and 'baselabel' from the XML which
fails for model='none'. Err, this model - even though not specified in
XML - can be taken from qemu wide config file: /etc/libvirtd/qemu.conf.

However, in order to know we are dealing with model='none' the code in
question must be moved forward a bit. Then a new check must be
introduced. This is what the first two chunks are doing.

But this alone is not sufficient. The domain state XML won't contain the
model attribute without slight modification. The model should be
inserted into the XML even if equal to 'none' and the state XML is being
generated - what if the origin (the @security_driver variable in
qemu.conf) changes during libvirtd restarts?

At the end, a test to catch this scenario is introduced.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 9fb3f9571db4bd20b8287a160e9b2680f23dde45)

11 years agoPrep for release 1.1.3.1 v1.1.3.1
Cole Robinson [Wed, 6 Nov 2013 17:36:17 +0000 (12:36 -0500)] 
Prep for release 1.1.3.1

11 years agoPush RPM deps down into libvirt-daemon-driver-XXXX sub-RPMs
Daniel P. Berrange [Tue, 29 Oct 2013 11:27:45 +0000 (11:27 +0000)] 
Push RPM deps down into libvirt-daemon-driver-XXXX sub-RPMs

For inexplicable reasons, many of the 3rd party package deps
were left against the 'libvirt-daemon' RPM when the drivers
were split out. This makes a minimal install heavier that
it should be. Push them all down into libvirt-daemon-driver-XXX
so they're only pulled in when truly needed

With this change applied, a minimal install of just the
libvirt-daemon-driver-lxc RPM is reduced by 41 MB on a
Fedora 19 host.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 23142ac91a86309214923f446be9d0dd54d99d95)

11 years agoFix race condition reconnecting to vms & loading configs
Daniel P. Berrange [Mon, 28 Oct 2013 11:49:18 +0000 (11:49 +0000)] 
Fix race condition reconnecting to vms & loading configs

The following sequence

 1. Define a persistent QMEU guest
 2. Start the QEMU guest
 3. Stop libvirtd
 4. Kill the QEMU process
 5. Start libvirtd
 6. List persistent guests

At the last step, the previously running persistent guest
will be missing. This is because of a race condition in the
QEMU driver startup code. It does

 1. Load all VM state files
 2. Spawn thread to reconnect to each VM
 3. Load all VM config files

Only at the end of step 3, does the 'virDomainObjPtr' get
marked as "persistent". There is therefore a window where
the thread reconnecting to the VM will remove the persistent
VM from the list.

The easy fix is to simply switch the order of steps 2 & 3.

In addition to this though, we must only attempt to reconnect
to a VM which had a non-zero PID loaded from its state file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit f26701f565525dd402df021d8923489e62412158)

11 years agoFix leak of objects when reconnecting to QEMU instances
Daniel P. Berrange [Tue, 29 Oct 2013 13:58:00 +0000 (13:58 +0000)] 
Fix leak of objects when reconnecting to QEMU instances

The 'error' cleanup block in qemuProcessReconnect() had a
'return' statement in the middle of it. This caused a leak
of virConnectPtr & virQEMUDriverConfigPtr instances. This
was identified because netcf recently started checking its
refcount in libvirtd shutdown:

netcfStateCleanup:109 : internal error: Attempt to close netcf state driver with open connections

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 54a241122063094146f1bdec9fab38df5617fb68)

11 years agoDon't update dom->persistent without lock held
Daniel P. Berrange [Mon, 28 Oct 2013 14:07:26 +0000 (14:07 +0000)] 
Don't update dom->persistent without lock held

virDomainObjListLoadAllConfigs sets dom->persistent after
having released its lock on the domain object. This exposes
a possible race condition.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit b260a77e34ed93f1b4f4f6436435cf5955e3f4b8)

11 years agoBlock all use of libvirt.so in setuid programs
Daniel P. Berrange [Thu, 10 Oct 2013 16:45:14 +0000 (17:45 +0100)] 
Block all use of libvirt.so in setuid programs

Avoid people introducing security flaws in their apps by
forbidding the use of libvirt.so in setuid programs, with
a check in virInitialize.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 9cd6a57db6ea6762fbf85c59c379a27fa6e7fd2e)

11 years agoRemove (nearly) all use of getuid()/getgid()
Daniel P. Berrange [Wed, 9 Oct 2013 11:13:45 +0000 (12:13 +0100)] 
Remove (nearly) all use of getuid()/getgid()

Most of the usage of getuid()/getgid() is in cases where we are
considering what privileges we have. As such the code should be
using the effective IDs, not real IDs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 9b0af09240618184fea5884952941217e65b824f)

11 years agoAdd stub getegid impl for platforms lacking it
Daniel P. Berrange [Thu, 17 Oct 2013 13:51:32 +0000 (14:51 +0100)] 
Add stub getegid impl for platforms lacking it

We already have stubs for getuid, geteuid, getgid but
not for getegid. Something in gnulib already does a
check for it during configure, so we already have the
HAVE_GETEGID macro defined.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit c566fa1ad007a280bdf5132f7f91010459036ff6)

11 years agoDon't allow remote driver daemon autostart when running setuid
Daniel P. Berrange [Wed, 9 Oct 2013 10:47:13 +0000 (11:47 +0100)] 
Don't allow remote driver daemon autostart when running setuid

We don't want setuid programs automatically spawning libvirtd,
so disable any use of autostart when setuid.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 171bb129115d49c567b643acaf20b363b124b8cf)

11 years agoOnly allow the UNIX transport in remote driver when setuid
Daniel P. Berrange [Wed, 9 Oct 2013 10:44:50 +0000 (11:44 +0100)] 
Only allow the UNIX transport in remote driver when setuid

We don't know enough about quality of external libraries used
for non-UNIX transports, nor do we want to spawn external
commands when setuid. Restrict to the bare minimum which is
UNIX transport for local usage. Users shouldn't need to be
running setuid if connecting to remote hypervisors in any
case.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit e22b0232c7b94aefaef87c52c4d626fa532fcce3)

11 years agoBlock all use of getenv with syntax-check
Daniel P. Berrange [Wed, 9 Oct 2013 10:19:27 +0000 (11:19 +0100)] 
Block all use of getenv with syntax-check

The use of getenv is typically insecure, and we want people
to use our wrappers, to force them to think about setuid
needs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 71b21f12bece1127b28b404f11f57b4c2d48983a)

11 years agoRemove all direct use of getenv
Daniel P. Berrange [Wed, 9 Oct 2013 10:18:15 +0000 (11:18 +0100)] 
Remove all direct use of getenv

Unconditional use of getenv is not secure in setuid env.
While not all libvirt code runs in a setuid env (since
much of it only exists inside libvirtd) this is not always
clear to developers. So make all the code paranoid, even
if it only ever runs inside libvirtd.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 1e4a02bdfe6307f93763fa2c9681f280c564aee5)

11 years agoMake virCommand env handling robust in setuid env
Daniel P. Berrange [Wed, 9 Oct 2013 10:03:02 +0000 (11:03 +0100)] 
Make virCommand env handling robust in setuid env

When running setuid, we must be careful about what env vars
we allow commands to inherit from us. Replace the
virCommandAddEnvPass function with two new ones which do
filtering

  virCommandAddEnvPassAllowSUID
  virCommandAddEnvPassBlockSUID

And make virCommandAddEnvPassCommon use the appropriate
ones

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 9b8f307c6ad002a17a0510513883d06395636793)

11 years agoInitialize threading & error layer in LXC controller
Daniel P. Berrange [Tue, 8 Oct 2013 13:35:01 +0000 (14:35 +0100)] 
Initialize threading & error layer in LXC controller

In Fedora 20, libvirt_lxc crashes immediately at startup with a
trace

 #0  0x00007f0cddb653ec in free () from /lib64/libc.so.6
 #1  0x00007f0ce0e16f4a in virFree (ptrptr=ptrptr@entry=0x7f0ce1830058) at util/viralloc.c:580
 #2  0x00007f0ce0e2764b in virResetError (err=0x7f0ce1830030) at util/virerror.c:354
 #3  0x00007f0ce0e27a5a in virResetLastError () at util/virerror.c:387
 #4  0x00007f0ce0e28858 in virEventRegisterDefaultImpl () at util/virevent.c:233
 #5  0x00007f0ce0db47c6 in main (argc=11, argv=0x7fff4596c328) at lxc/lxc_controller.c:2352

Normally virInitialize calls virErrorInitialize and
virThreadInitialize, but we don't link to libvirt.so
in libvirt_lxc, and nor did we ever call the error
or thread initializers.

I have absolutely no idea how this has ever worked, let alone
what caused it to stop working in Fedora 20.

In addition not all code paths from virLogSetFromEnv will
ensure virLogInitialize is called correctly, which is another
possible crash scenario.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 97973ebb7a64a3be6710ddd38d124307991ad7cb)

11 years agoFix flaw in detecting log format
Daniel P. Berrange [Fri, 11 Oct 2013 16:07:54 +0000 (17:07 +0100)] 
Fix flaw in detecting log format

The log message regex has been

[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug|info|warning|error :

The precedence of '|' is high though, so this is equivalent to matching

   [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug

Or

   info

Or

   warning

Or

   error :

Which is clearly not what it should have done. This caused the code to
skip over things which are not log messages. The solution is to simply
add brackets.

A test case is also added to validate correctness.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 5787f0b95ed5a58be020836bda4b27fa3538086c)

11 years agoMove virt-login-shell into libvirt-login-shell sub-RPM
Daniel P. Berrange [Thu, 17 Oct 2013 13:18:18 +0000 (14:18 +0100)] 
Move virt-login-shell into libvirt-login-shell sub-RPM

Many people will not want the setuid virt-login-shell binary
installed by default, so move it into a separate sub-RPM
named libvirt-login-shell. This RPM is only generated if
LXC is enabled

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 8adc92694fecbd35f28cf236edff14509bf4eaf4)

11 years agoSet a sane $PATH for virt-login-shell
Daniel P. Berrange [Wed, 9 Oct 2013 10:19:52 +0000 (11:19 +0100)] 
Set a sane $PATH for virt-login-shell

The virt-login-shell binary shouldn't need to execute programs
relying on $PATH, but just in case set a fixed $PATH value
of /bin:/usr/bin

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit d665003da1359410bc4036895a648a7d7256ddaa)

11 years agoremote: fix regression in event deregistration
Zhou Yimin [Thu, 17 Oct 2013 07:59:21 +0000 (15:59 +0800)] 
remote: fix regression in event deregistration

Introduced by 7b87a3
When I quit the process which only register VIR_DOMAIN_EVENT_ID_REBOOT,
I got error like:
"libvirt: XML-RPC error : internal error: domain event 0 not registered".
Then I add the following code, it fixed.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 9712c2510ec87a87578576a407768380e250a6a4)

11 years agopython: Fix Create*WithFiles filefd passing
Marian Neagul [Tue, 22 Oct 2013 15:03:39 +0000 (16:03 +0100)] 
python: Fix Create*WithFiles filefd passing

Commit d76227be added functions virDomainCreateWithFiles and
virDomainCreateXMLWithFiles, but there was a little piece missing in
python bindings.  This patch fixes proper passing of file descriptors
in the overwrites of these functions.

11 years agobuild: fix build of virt-login-shell on systems with older gnutls
Jim Fehlig [Tue, 22 Oct 2013 05:12:22 +0000 (23:12 -0600)] 
build: fix build of virt-login-shell on systems with older gnutls

On systems where gnutls uses libgcrypt, I'm seeing the following
build failure

libvirt.c:314: error: variable 'virTLSThreadImpl' has initializer but incomplete type
libvirt.c:319: error: 'GCRY_THREAD_OPTION_PTHREAD' undeclared here (not in a function)
...

Fix by undefining WITH_GNUTLS_GCRYPT in config-post.h

11 years agobuild: fix linking virt-login-shell
Jim Fehlig [Mon, 21 Oct 2013 21:36:11 +0000 (15:36 -0600)] 
build: fix linking virt-login-shell

After commit 3e2f27e1, I've noticed build failures of virt-login-shell
when libapparmor-devel is installed on the build host

CCLD     virt-login-shell
../src/.libs/libvirt-setuid-rpc-client.a(libvirt_setuid_rpc_client_la-vircommand.o):
In function `virExec':
/home/jfehlig/virt/upstream/libvirt/src/util/vircommand.c:653: undefined
reference to `aa_change_profile'
collect2: error: ld returned 1 exit status

I was about to commit an easy fix under the build-breaker rule
(build-fix-1.patch), but thought to extend the notion of SECDRIVER_LIBS
to SECDRIVER_CFLAGS, and use both throughout src/Makefile.am where it
makes sense (build-fix-2.patch).

Should I just stick with the simple fix, or is something along the lines
of patch 2 preferred?

Regards,
Jim

>From a0f35945f3127ab70d051101037e821b1759b4bb Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Mon, 21 Oct 2013 15:30:02 -0600
Subject: [PATCH] build: fix virt-login-shell build with apparmor

With libapparmor-devel installed, virt-login-shell fails to link

CCLD     virt-login-shell
../src/.libs/libvirt-setuid-rpc-client.a(libvirt_setuid_rpc_client_la-vircommand.o): In function `virExec':
/home/jfehlig/virt/upstream/libvirt/src/util/vircommand.c:653: undefined reference to `aa_change_profile'
collect2: error: ld returned 1 exit status

Fix by linking libvirt_setuid_rpc_client with previously determined
SECDRIVER_LIBS in src/Makefile.am.  While at it, introduce SECDRIVER_CFLAGS
and use both throughout src/Makefile.am where it makes sense.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agoDon't link virt-login-shell against libvirt.so (CVE-2013-4400)
Daniel P. Berrange [Thu, 10 Oct 2013 12:09:08 +0000 (13:09 +0100)] 
Don't link virt-login-shell against libvirt.so (CVE-2013-4400)

The libvirt.so library has far too many library deps to allow
linking against it from setuid programs. Those libraries can
do stuff in __attribute__((constructor) functions which is
not setuid safe.

The virt-login-shell needs to link directly against individual
files that it uses, with all library deps turned off except
for libxml2 and libselinux.

Create a libvirt-setuid-rpc-client.la library which is linked
to by virt-login-shell. A config-post.h file allows this library
to disable all external deps except libselinux and libxml2.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 3e2f27e13b94f7302ad948bcacb5e02c859a25fc)

11 years agoClose all non-stdio FDs in virt-login-shell (CVE-2013-4400)
Daniel P. Berrange [Wed, 9 Oct 2013 14:14:34 +0000 (15:14 +0100)] 
Close all non-stdio FDs in virt-login-shell (CVE-2013-4400)

We don't want to inherit any FDs in the new namespace
except for the stdio FDs. Explicitly close them all,
just in case some do not have the close-on-exec flag
set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit b7fcc799ad5d8f3e55b89b94e599903e3c092467)

11 years agoOnly allow 'stderr' log output when running setuid (CVE-2013-4400)
Daniel P. Berrange [Wed, 9 Oct 2013 09:59:36 +0000 (10:59 +0100)] 
Only allow 'stderr' log output when running setuid (CVE-2013-4400)

We must not allow file/syslog/journald log outputs when running
setuid since they can be abused to do bad things. In particular
the 'file' output can be used to overwrite files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 8c3586ea755c40d5e01b22cb7b5c1e668cdec994)

11 years agoAdd helpers for getting env vars in a setuid environment
Daniel P. Berrange [Wed, 9 Oct 2013 09:52:39 +0000 (10:52 +0100)] 
Add helpers for getting env vars in a setuid environment

Care must be taken accessing env variables when running
setuid. Introduce a virGetEnvAllowSUID for env vars which
are safe to use in a setuid environment, and another
virGetEnvBlockSUID for vars which are not safe. Also add
a virIsSUID helper method for any other non-env var code
to use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit ae53e5d10e434e07079d7e3ba11ec654ba6a256e)

11 years agoFix perms for virConnectDomainXML{To,From}Native (CVE-2013-4401)
Daniel P. Berrange [Thu, 3 Oct 2013 15:37:57 +0000 (16:37 +0100)] 
Fix perms for virConnectDomainXML{To,From}Native (CVE-2013-4401)

The virConnectDomainXMLToNative API should require 'connect:write'
not 'connect:read', since it will trigger execution of the QEMU
binaries listed in the XML.

Also make virConnectDomainXMLFromNative API require a full
read-write connection and 'connect:write' permission. Although the
current impl doesn't trigger execution of QEMU, we should not
rely on that impl detail from an API permissioning POV.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 57687fd6bf7f6e1b3662c52f3f26c06ab19dc96c)

11 years agobuild: Add lxc testcase to dist list
Daniel Hansel [Tue, 15 Oct 2013 12:13:15 +0000 (14:13 +0200)] 
build: Add lxc testcase to dist list

Introduced by commit 3f029fb5319b9dc9cc2fbf8d1ba4505ee9e4b1e3 the RPM build
was broken due to a missing LXC textcase.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
(cherry picked from commit 6285c17f790a7e5027aed0207fc5d9eb9130cc0e)

11 years agoConvert uuid to a string before printing it
Ján Tomko [Tue, 15 Oct 2013 08:29:18 +0000 (10:29 +0200)] 
Convert uuid to a string before printing it

Introduced by 1fa7946.

https://bugzilla.redhat.com/show_bug.cgi?id=1019023
(cherry picked from commit 15fac93b951eb67553ca64443c740c1b975696a9)

11 years agoLXC: Fix handling of RAM filesystem size units
Ján Tomko [Wed, 9 Oct 2013 12:17:13 +0000 (14:17 +0200)] 
LXC: Fix handling of RAM filesystem size units

Since 76b644c when the support for RAM filesystems was introduced,
libvirt accepted the following XML:
<source usage='1024' unit='KiB'/>

This was parsed correctly and internally stored in bytes, but it
was formatted as (with an extra 's'):
<source usage='1024' units='KiB'/>
When read again, this was treated as if the units were missing,
meaning libvirt was unable to parse its own XML correctly.

The usage attribute was documented as being in KiB, but it was not
scaled if the unit was missing. Transient domains still worked,
because this was balanced by an extra 'k' in the mount options.

This patch:
Changes the parser to use 'units' instead of 'unit', as the latter
was never documented (fixing persistent domains) and some programs
(libvirt-glib, libvirt-sandbox) already parse the 'units' attribute.

Removes the extra 'k' from the tmpfs mount options, which is needed
because now we parse our own XML correctly.

Changes the default input unit to KiB to match documentation, fixing:
https://bugzilla.redhat.com/show_bug.cgi?id=1015689
(cherry picked from commit 3f029fb5319b9dc9cc2fbf8d1ba4505ee9e4b1e3)

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

After successful @cmd construction the memory where @keys points to is
part of @cmd. Avoid double freeing it.
(cherry picked from commit 3e8343e1510741623aa5bc1dfb74ec39fde868dd)

12 years agorpc: fix getsockopt for LOCAL_PEERCRED on Mac OS X
Ryota Ozaki [Sat, 5 Oct 2013 05:56:36 +0000 (14:56 +0900)] 
rpc: fix getsockopt for LOCAL_PEERCRED on Mac OS X

This fixes the following error:
  error : virGetUserEnt:703 : Failed to find user record for uid '32654'

'32654' (it's random and varies) comes from getsockopt with
LOCAL_PEERCRED option. getsockopt returns w/o error but seems
to not set any value to the buffer for uid.

For Mac OS X, LOCAL_PEERCRED has to be used with SOL_LOCAL level.
With SOL_LOCAL, getsockopt returns a correct uid.

Note that SOL_LOCAL can be found in
/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/un.h.

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 5a468b38b6b9ac66c1db5d8ed5d5a122a9cf01cd)

12 years agoRemove use of virConnectPtr from all remaining nwfilter code
Daniel P. Berrange [Thu, 3 Oct 2013 11:51:48 +0000 (12:51 +0100)] 
Remove use of virConnectPtr from all remaining nwfilter code

The virConnectPtr is passed around loads of nwfilter code in
order to provide it as a parameter to the callback registered
by the virt drivers. None of the virt drivers use this param
though, so it serves no purpose.

Avoiding the need to pass a virConnectPtr means that the
nwfilterStateReload method no longer needs to open a bogus
QEMU driver connection. This addresses a race condition that
can lead to a crash on startup.

The nwfilter driver starts before the QEMU driver and registers
some callbacks with DBus to detect firewalld reload. If the
firewalld reload happens while the QEMU driver is still starting
up though, the nwfilterStateReload method will open a connection
to the partially initialized QEMU driver and cause a crash.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 999d72fbd59ea712128ae294b69b6a54039d757b)

12 years agoDon't pass virConnectPtr in nwfilter 'struct domUpdateCBStruct'
Daniel P. Berrange [Thu, 3 Oct 2013 11:45:26 +0000 (12:45 +0100)] 
Don't pass virConnectPtr in nwfilter 'struct domUpdateCBStruct'

The nwfilter driver only needs a reference to its private
state object, not a full virConnectPtr. Update the domUpdateCBStruct
struct to have a 'void *opaque' field instead of a virConnectPtr.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit ebca369e3fe5ac999c261c2d44e60a1bac3cfe65)

12 years agoRemove virConnectPtr arg from virNWFilterDefParse*
Daniel P. Berrange [Thu, 3 Oct 2013 11:35:34 +0000 (12:35 +0100)] 
Remove virConnectPtr arg from virNWFilterDefParse*

None of the virNWFilterDefParse* methods require a virConnectPtr
arg, so just drop it

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit b77b16ce4166dcc87963ae5d279b77b162ddbb55)

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

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

https://bugzilla.redhat.com/show_bug.cgi?id=1014088
(cherry picked from commit a924d9d083c215df6044387057c501d9aa338b96)

12 years agovirNetDevBandwidthEqual: Make it more robust
Michal Privoznik [Wed, 2 Oct 2013 07:18:02 +0000 (09:18 +0200)] 
virNetDevBandwidthEqual: Make it more robust

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ee02fbc8e4a24c1347761ceff2ddb2c108e9611c)

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

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 9fa10d3901a14997f724fe50ad8a33d7f0d23abe)

12 years agoAdjust legacy max payload size to account for header information
Claudio Bley [Mon, 7 Oct 2013 10:13:00 +0000 (12:13 +0200)] 
Adjust legacy max payload size to account for header information

Commit 27e81517a87 set the payload size to 256 KB, which is
actually the max packet size, including the size of the header.

Reduce this by VIR_NET_MESSAGE_HEADER_MAX (24) and set
VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX to 262120, which was the original
value before increasing the limit in commit eb635de1fed.

(cherry picked from commit 609eb987c6cef9082486e66b666f7b9351b783ed)

12 years agoRelease of libvirt-1.1.3 v1.1.3
Daniel Veillard [Tue, 1 Oct 2013 07:04:14 +0000 (15:04 +0800)] 
Release of libvirt-1.1.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reported by: John Ferlan

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

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

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

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

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

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

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

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

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

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

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

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

Another case missed by commits 716c7bb and 6973e02.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  virConnectDomainEventDeregisterAny

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Similar to commit 8f34f19.

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

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

Removed superfluous/wrong srcdir prefix.

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

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

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

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

s/becuase/because/

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

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

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

Caused by commit 012c25e8 splitting out a convenience library.

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

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

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

Free dst before lxcDomainAttachDeviceDiskLive returns

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

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

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

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

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

Tweak some conditions and use correct typecasts in enums.

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

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

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

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

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

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

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

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

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

When passing in custom driver XML, allow a block like

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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