]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
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>
12 years agoFix double-free in virJSONParserHandleStartMap on OOM
Daniel P. Berrange [Wed, 25 Sep 2013 14:16:24 +0000 (15:16 +0100)] 
Fix double-free in virJSONParserHandleStartMap on OOM

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix crash on OOM in virDomainSnapshotDefParse
Daniel P. Berrange [Wed, 25 Sep 2013 08:34:25 +0000 (09:34 +0100)] 
Fix crash on OOM in virDomainSnapshotDefParse

The virDomainSnapshotDefParse method assigned to def->ndisks
before allocating def->disks. Thus if an OOM occurred, the
cleanup code would access out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDon't clobber return value in virInterfaceDefParseProtoIPv6
Daniel P. Berrange [Wed, 25 Sep 2013 08:33:12 +0000 (09:33 +0100)] 
Don't clobber return value in virInterfaceDefParseProtoIPv6

Several places in virInterfaceDefParseProtoIPv6 clobber the
default 'ret' return value. So when jumping to cleanup on
error, 'ret' may mistakenly be set to 0 instead of -1. This
caused failure to report OOM errors, meaning data was silently
lost during parsing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix handling of OOM when getting Xen dom ID
Daniel P. Berrange [Wed, 25 Sep 2013 08:31:30 +0000 (09:31 +0100)] 
Fix handling of OOM when getting Xen dom ID

The methods for obtaining the Xen dom ID cannot distinguish
between returning -1 due to an error and returning -1 due to
the domain being shutoff. Change them to return the dom ID
via an output parameter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix crash on OOM in xenParseSxpr
Daniel P. Berrange [Wed, 25 Sep 2013 08:30:20 +0000 (09:30 +0100)] 
Fix crash on OOM in xenParseSxpr

The xenParseSxpr method sets def->nconsoles to 1 before allocating
the def->consoles array. If the allocation fails due to OOM the
cleanup code will thus crash accessing out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agovirsh-domain: Add a missing check and fix leak in cmdScreenshot
Hongwei Bi [Wed, 25 Sep 2013 14:54:24 +0000 (22:54 +0800)] 
virsh-domain: Add a missing check and fix leak in cmdScreenshot

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoFix leak of serial value in xenFormatXM on OOM
Daniel P. Berrange [Tue, 24 Sep 2013 15:46:44 +0000 (16:46 +0100)] 
Fix leak of serial value in xenFormatXM on OOM

If an OOM occurs in xenFormatXM when formatting to the
serial device value, the value is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix broken formatting on OOM in xenFormatXM
Daniel P. Berrange [Tue, 24 Sep 2013 15:45:58 +0000 (16:45 +0100)] 
Fix broken formatting on OOM in xenFormatXM

If an OOM occurs when xenFormatXM is setting the 'hpet'
variable it is silently ignored. Fix it to propagate
to the callers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix crash on OOM in xenParseXM handling consoles
Daniel P. Berrange [Tue, 24 Sep 2013 15:45:09 +0000 (16:45 +0100)] 
Fix crash on OOM in xenParseXM handling consoles

The xenParseXM sets def->nconsoles to 1 before claling
VIR_REALLOC_N on def->consoles. So if the alloc fails
due to OOM, the cleanup code will crash accessing a
console that does not exist.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix leak of char device in xenParseXM
Daniel P. Berrange [Tue, 24 Sep 2013 15:44:26 +0000 (16:44 +0100)] 
Fix leak of char device in xenParseXM

If an OOM occurs in xenParseXM, a virDomainChrDef may be
leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix leak of command line args in qemuParseCommandLine
Daniel P. Berrange [Tue, 24 Sep 2013 15:38:26 +0000 (16:38 +0100)] 
Fix leak of command line args in qemuParseCommandLine

If qemuParseCommandLine finds an arg it does not understand
it adds it to the QEMU passthrough custom arg list. If the
qemuParseCommandLine method hits an error for any reason
though, it just does 'VIR_FREE(cmd)' on the custom arg list.
This means all actual args / env vars are leaked. Introduce
a qemuDomainCmdlineDefFree method to be used for cleanup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix leak in qemuParseCommandLine on OOM
Daniel P. Berrange [Tue, 24 Sep 2013 15:37:24 +0000 (16:37 +0100)] 
Fix leak in qemuParseCommandLine on OOM

If the call to virDomainControllerInsert fails in
qemuParseCommandLine, the controller struct is leaked.

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