]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
9 years agoqemu: Let empty default VNC password work as documented v0.9.12-maint
Jiri Denemark [Tue, 28 Jun 2016 12:39:58 +0000 (14:39 +0200)] 
qemu: Let empty default VNC password work as documented

CVE-2016-5008

Setting an empty graphics password is documented as a way to disable
VNC/SPICE access, but QEMU does not always behaves like that. VNC would
happily accept the empty password. Let's enforce the behavior by setting
password expiration to "now".

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

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

10 years agoCVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk
Peter Krempa [Thu, 11 Sep 2014 14:35:53 +0000 (16:35 +0200)] 
CVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk

Live definition was used to look up the disk index while persistent one
was indexed leading to a crash in qemuDomainGetBlockIoTune. Use the
correct def and report a nice error.

Unfortunately it's accessible via read-only connection, though it can
only crash libvirtd in the cases where the guest is hot-plugging disks
without reflecting those changes to the persistent definition.  So
avoiding hotplug, or doing hotplug where persistent is always modified
alongside live definition, will avoid the out-of-bounds access.

Introduced in: eca96694a7f992be633d48d5ca03cedc9bbc3c9aa (v0.9.8)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140724
Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 3e745e8f775dfe6f64f18b5c2fe4791b35d3546b)

Conflicts:
src/qemu/qemu_driver.c - context due to fewer functions

11 years agoLSN-2014-0003: Don't expand entities when parsing XML
Daniel P. Berrange [Tue, 15 Apr 2014 10:20:29 +0000 (11:20 +0100)] 
LSN-2014-0003: Don't expand entities when parsing XML

If the XML_PARSE_NOENT flag is passed to libxml2, then any
entities in the input document will be fully expanded. This
allows the user to read arbitrary files on the host machine
by creating an entity pointing to a local file. Removing
the XML_PARSE_NOENT flag means that any entities are left
unchanged by the parser, or expanded to "" by the XPath
APIs.

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

11 years agovirNetClientSetTLSSession: Restore original signal mask
Michal Privoznik [Wed, 19 Mar 2014 17:10:34 +0000 (18:10 +0100)] 
virNetClientSetTLSSession: Restore original signal mask

Currently, we use pthread_sigmask(SIG_BLOCK, ...) prior to calling
poll(). This is okay, as we don't want poll() to be interrupted.
However, then - immediately as we fall out from the poll() - we try to
restore the original sigmask - again using SIG_BLOCK. But as the man
page says, SIG_BLOCK adds signals to the signal mask:

SIG_BLOCK
      The set of blocked signals is the union of the current set and the set argument.

Therefore, when restoring the original mask, we need to completely
overwrite the one we set earlier and hence we should be using:

SIG_SETMASK
      The set of blocked signals is set to the argument set.

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

11 years agobuild: use proper pod for nested bulleted VIRSH_DEBUG list
Eric Blake [Fri, 5 Apr 2013 16:00:20 +0000 (10:00 -0600)] 
build: use proper pod for nested bulleted VIRSH_DEBUG list

Newer pod (hello rawhide) complains if you attempt to mix bullets
and non-bullets in the same list:

virsh.pod around line 3177: Expected text after =item, not a bullet

As our intent was to nest an inner list, we make that explicit to
keep pod happy.

* tools/virsh.pod (ENVIRONMENT): Use correct pod syntax.

(cherry picked from commit 00d69b4af1215695ebfc8f1dbfa77804c2b293fd)

11 years agoPrepare for 0.9.12.3 v0.9.12.3
Guido Günther [Thu, 16 Jan 2014 08:48:16 +0000 (09:48 +0100)] 
Prepare for 0.9.12.3

11 years agoReally don't crash if a connection closes early
Jiri Denemark [Mon, 13 Jan 2014 14:46:24 +0000 (15:46 +0100)] 
Really don't crash if a connection closes early

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

When writing commit 173c291, I missed the fact virNetServerClientClose
unlocks the client object before actually clearing client->sock and thus
it is possible to hit a window when client->keepalive is NULL while
client->sock is not NULL. I was thinking client->sock == NULL was a
better check for a closed connection but apparently we have to go with
client->keepalive == NULL to actually fix the crash.

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

11 years agoDon't crash if a connection closes early
Jiri Denemark [Thu, 9 Jan 2014 21:26:40 +0000 (22:26 +0100)] 
Don't crash if a connection closes early

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

When a client closes its connection to libvirtd early during
virConnectOpen, more specifically just after making
REMOTE_PROC_CONNECT_SUPPORTS_FEATURE call to check if
VIR_DRV_FEATURE_PROGRAM_KEEPALIVE is supported without even waiting for
the result, libvirtd may crash due to a race in keep-alive
initialization. Once receiving the REMOTE_PROC_CONNECT_SUPPORTS_FEATURE
call, the daemon's event loop delegates it to a worker thread. In case
the event loop detects EOF on the connection and calls
virNetServerClientClose before the worker thread starts to handle
REMOTE_PROC_CONNECT_SUPPORTS_FEATURE call, client->keepalive will be
disposed by the time virNetServerClientStartKeepAlive gets called from
remoteDispatchConnectSupportsFeature. Because the flow is common for
both authenticated and read-only connections, even unprivileged clients
may cause the daemon to crash.

To avoid the crash, virNetServerClientStartKeepAlive needs to check if
the connection is still open before starting keep-alive protocol.

Every libvirt release since 0.9.8 is affected by this bug.

(cherry picked from commit 173c2914734eb5c32df6d35a82bf503e12261bcf)

Conflicts:
src/rpc/virnetserverclient.c - older locking style

11 years agoqemu: Fix job usage in virDomainGetBlockIoTune
Jiri Denemark [Fri, 20 Dec 2013 14:41:04 +0000 (15:41 +0100)] 
qemu: Fix job usage in virDomainGetBlockIoTune

CVE-2013-6458

Every API that is going to begin a job should do that before fetching
data from vm->def.

Conflicts:
src/qemu/qemu_driver.c

(cherry picked from commit 3b56425938e2f97208d5918263efa0d6439e4ecd)

11 years agoqemu: Fix job usage in qemuDomainBlockJobImpl
Jiri Denemark [Fri, 20 Dec 2013 14:04:09 +0000 (15:04 +0100)] 
qemu: Fix job usage in qemuDomainBlockJobImpl

CVE-2013-6458

Every API that is going to begin a job should do that before fetching
data from vm->def.

Conflicts:
        src/qemu/qemu_driver.c

(cherry picked from commit f93d2caa070f6197ab50d372d286018b0ba6bbd8)

11 years agoqemu: Avoid using stale data in virDomainGetBlockInfo
Jiri Denemark [Fri, 20 Dec 2013 13:50:02 +0000 (14:50 +0100)] 
qemu: Avoid using stale data in virDomainGetBlockInfo

CVE-2013-6458

Generally, every API that is going to begin a job should do that before
fetching data from vm->def. However, qemuDomainGetBlockInfo does not
know whether it will have to start a job or not before checking vm->def.
To avoid using disk alias that might have been freed while we were
waiting for a job, we use its copy. In case the disk was removed in the
meantime, we will fail with "cannot find statistics for device '...'"
error message.

Conflicts:
src/qemu/qemu_driver.c

(cherry picked from commit b799259583bd65c0b2f5042e6c3ff19637ade881)

11 years agoqemu: Do not access stale data in virDomainBlockStats
Jiri Denemark [Thu, 19 Dec 2013 21:10:04 +0000 (22:10 +0100)] 
qemu: Do not access stale data in virDomainBlockStats

CVE-2013-6458
https://bugzilla.redhat.com/show_bug.cgi?id=1043069

When virDomainDetachDeviceFlags is called concurrently to
virDomainBlockStats: libvirtd may crash because qemuDomainBlockStats
finds a disk in vm->def before getting a job on a domain and uses the
disk pointer after getting the job. However, the domain in unlocked
while waiting on a job condition and thus data behind the disk pointer
may disappear. This happens when thread 1 runs
virDomainDetachDeviceFlags and enters monitor to actually remove the
disk. Then another thread starts running virDomainBlockStats, finds the
disk in vm->def, and while it's waiting on the job condition (owned by
the first thread), the first thread finishes the disk removal. When the
second thread gets the job, the memory pointed to be the disk pointer is
already gone.

That said, every API that is going to begin a job should do that before
fetching data from vm->def.

Conflicts:
src/qemu/qemu_driver.c

(cherry picked from commit db86da5ca2109e4006c286a09b6c75bfe10676ad)

11 years agoIntroduce virReportError macro for general error reporting
Daniel P. Berrange [Wed, 18 Jul 2012 10:23:56 +0000 (11:23 +0100)] 
Introduce virReportError macro for general error reporting

Nearly every source file does something like

  #define VIR_FROM_THIS VIR_FROM_FOO
  #define virFooReportErorr(code, ...) \
     virReportErrorHelper(VIR_FROM_THIS, code,  __FILE__,    \
                          __FUNCTION__, __LINE__, \
                          __VA_ARGS__)

This creates needless duplication and inconsistent error
reporting function names in each file. It is trivial to
just have virterror_internal.h provide a virReportError
macro that is equivalent

* src/util/virterror_internal.h: Define virReportError(code, ...)

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

11 years agostring: test VIR_STRDUP
Eric Blake [Tue, 7 May 2013 21:26:28 +0000 (15:26 -0600)] 
string: test VIR_STRDUP

The surest way to avoid regressions is to test documented behavior :)

* tests/virstringtest.c (testStrdup): New test case.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 504b4a8dae06330ba1735a28c316c1c68a32c471)

11 years agostring: make VIR_STRDUP easier to use
Eric Blake [Tue, 7 May 2013 02:42:44 +0000 (20:42 -0600)] 
string: make VIR_STRDUP easier to use

While reviewing proposed VIR_STRDUP conversions, I've already noticed
several places that do:

if (str && VIR_STRDUP(dest, str) < 0)

which can be simplified by allowing str to be NULL (something that
strdup() doesn't allow).  Meanwhile, code that wants to ensure a
non-NULL dest regardless of the source can check for <= 0.

Also, make it part of the VIR_STRDUP contract that macro arguments
are evaluated exactly once.

* src/util/virstring.h (VIR_STRDUP, VIR_STRDUP_QUIET, VIR_STRNDUP)
(VIR_STRNDUP_QUIET): Improve contract.
* src/util/virstring.c (virStrdup, virStrndup): Change return
conventions.
* docs/hacking.html.in: Document this.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
HACKING
docs/hacking.html.in

(cherry picked from commit 6b74a9f5d98e066f8dfdf5d5ccda68230b516246)

11 years agovirstring: Introduce VIR_STRDUP and VIR_STRNDUP
Michal Privoznik [Wed, 3 Apr 2013 12:51:20 +0000 (14:51 +0200)] 
virstring: Introduce VIR_STRDUP and VIR_STRNDUP

The code adaptation is not done right now, but in subsequent patches.
Hence I am not implementing syntax-check rule as it would break
compilation. Developers are strongly advised to use these new macros.
They are similar to VIR_ALLOC() logic: VIR_STRDUP(dst, src) returns zero
on success, -1 otherwise. In case you don't want to report OOM error,
use the _QUIET variant of a macro.

Conflicts:
src/libvirt_private.syms
src/util/virstring.h

(cherry picked from commit c3abb5c45988a0d7583f059974513722d82e2c2b)

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)

Conflicts:
src/remote/remote_driver.c - context

11 years agoMerge commit 'v0.9.12.1' into v0.9.12-maint
Eric Blake [Fri, 4 Oct 2013 12:28:49 +0000 (06:28 -0600)] 
Merge commit 'v0.9.12.1' into v0.9.12-maint

Done by 'git merge -s ours v0.9.12.1', so that the maint branch
will contain all release tags.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoPrepare for 0.9.12.2 v0.9.12.2
Guido Günther [Tue, 1 Oct 2013 17:35:38 +0000 (19:35 +0200)] 
Prepare for 0.9.12.2

11 years agoDistribute viratomic.h
Guido Günther [Tue, 1 Oct 2013 14:32:19 +0000 (16:32 +0200)] 
Distribute viratomic.h

Since cbcb1983afbd76f0503185e4183afa10af88af47 we need viratomic.h in
the distributed tarball as well. This fixes "make distcheck".

11 years agoPrepare 0.9.12.1 v0.9.12.1
Guido Günther [Fri, 27 Sep 2013 10:17:31 +0000 (12:17 +0200)] 
Prepare 0.9.12.1

11 years agoFix crash in remoteDispatchDomainMemoryStats (CVE-2013-4296)
Daniel P. Berrange [Tue, 3 Sep 2013 15:52:06 +0000 (16:52 +0100)] 
Fix crash in remoteDispatchDomainMemoryStats (CVE-2013-4296)

The 'stats' variable was not initialized to NULL, so if some
early validation of the RPC call fails, it is possible to jump
to the 'cleanup' label and VIR_FREE an uninitialized pointer.
This is a security flaw, since the API can be called from a
readonly connection which can trigger the validation checks.

This was introduced in release v0.9.1 onwards by

  commit 158ba8730e44b7dd07a21ab90499996c5dec080a
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Apr 13 16:21:35 2011 +0100

    Merge all returns paths from dispatcher into single path

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

Conflicts:
daemon/remote.c - context

11 years agoAdd support for using 3-arg pkcheck syntax for process (CVE-2013-4311)
Daniel P. Berrange [Wed, 28 Aug 2013 14:25:40 +0000 (15:25 +0100)] 
Add support for using 3-arg pkcheck syntax for process (CVE-2013-4311)

With the existing pkcheck (pid, start time) tuple for identifying
the process, there is a race condition, where a process can make
a libvirt RPC call and in another thread exec a setuid application,
causing it to change to effective UID 0. This in turn causes polkit
to do its permission check based on the wrong UID.

To address this, libvirt must get the UID the caller had at time
of connect() (from SO_PEERCRED) and pass a (pid, start time, uid)
triple to the pkcheck program.

This fix requires that libvirt is re-built against a version of
polkit that has the fix for its CVE-2013-4288, so that libvirt
can see 'pkg-config --variable pkcheck_supports_uid polkit-gobject-1'

Signed-off-by: Colin Walters <walters@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 922b7fda77b094dbf022d625238262ea05335666)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
configure.ac - context
libvirt.spec.in - context of indentation
src/access/viraccessdriverpolkit.c - not present on this branch

11 years agoInclude process start time when doing polkit checks
Daniel P. Berrange [Thu, 25 Apr 2013 16:05:00 +0000 (17:05 +0100)] 
Include process start time when doing polkit checks

Since PIDs can be reused, polkit prefers to be given
a (PID,start time) pair. If given a PID on its own,
it will attempt to lookup the start time in /proc/pid/stat,
though this is subject to races.

It is safer if the client app resolves the PID start
time itself, because as long as the app has the client
socket open, the client PID won't be reused.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 979e9c56a7aadf2dcfbddd1abfbad594b78b4468)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
src/libvirt_private.syms - not backported
src/locking/lock_daemon.c - not backported
src/rpc/virnetserverclient.c
src/rpc/virnetsocket.c
src/rpc/virnetsocket.h
src/util/viridentity.h - not backported
src/util/virprocess.c
src/util/virprocess.h
src/util/virstring.c
src/util/virstring.h

Most conflicts were contextual (this patch adds new functions,
but upstream intermediate patches not backported here also added
new features, and the resolution was picking out just the portions
needed by this commit).  virnetsocket.c also had slightly
different locking semantics.

11 years agoMove virProcess{Kill, Abort, TranslateStatus} into virprocess.{c, h}
Daniel P. Berrange [Thu, 12 Sep 2013 16:00:04 +0000 (17:00 +0100)] 
Move virProcess{Kill, Abort, TranslateStatus} into virprocess.{c, h}

Continue consolidation of process functions by moving some
helpers out of command.{c,h} into virprocess.{c,h}

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 9467ab6074d02bd90248b5710b1c83856fefe9b4)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
src/lxc/lxc_controller.c
src/util/command.c
src/util/virprocess.c
tests/testutils.c

11 years agoMove virProcessKill into virprocess.{h, c}
Daniel P. Berrange [Thu, 12 Sep 2013 16:00:03 +0000 (17:00 +0100)] 
Move virProcessKill into virprocess.{h, c}

There are a number of process related functions spread
across multiple files. Start to consolidate them by
creating a virprocess.{c,h} file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit e5e2b65cf86ea49eba76b3c274e3b9d2177485bc)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
src/qemu/qemu_monitor.c
src/util/util.h

11 years agoRename virCommandTranslateStatus to virProcessTranslateStatus
Daniel P. Berrange [Thu, 12 Sep 2013 16:00:02 +0000 (17:00 +0100)] 
Rename virCommandTranslateStatus to virProcessTranslateStatus

The virCommand prefix was inappropriate because the API
does not use any virCommandPtr object instance. This
API closely related to waitpid/exit, so use virProcess
as the prefix

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 49ecf8b41fd1c606703d01792701ce46352b7669)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
src/util/command.c

11 years agoRename virPid{Abort, Wait} to virProcess{Abort, Wait}
Daniel P. Berrange [Thu, 12 Sep 2013 16:00:01 +0000 (17:00 +0100)] 
Rename virPid{Abort, Wait} to virProcess{Abort, Wait}

Change "Pid" to "Process" to align with the virProcessKill
API naming prefix

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 0fb58ef5cd477cf9a0efdd966a22440ef087a2af)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
src/util/util.c
src/lxc/lxc_container.c
src/lxc/lxc_controller.c

11 years agoRename virKillProcess to virProcessKill
Daniel P. Berrange [Thu, 12 Sep 2013 16:00:00 +0000 (17:00 +0100)] 
Rename virKillProcess to virProcessKill

Changing naming to follow the convention of "object" followed
by "action"

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

11 years agoIntroduce APIs for splitting/joining strings
Daniel P. Berrange [Thu, 12 Sep 2013 15:59:59 +0000 (16:59 +0100)] 
Introduce APIs for splitting/joining strings

This introduces a few new APIs for dealing with strings.
One to split a char * into a char **, another to join a
char ** into a char *, and finally one to free a char **

There is a simple test suite to validate the edge cases
too. No more need to use the horrible strtok_r() API,
or hand-written code for splitting strings.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 76c1fd33c8093d6a7173a85486e1e6f51a832135)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
tests/Makefile.am - several intermediate tests not backported

11 years agoFix TLS tests with gnutls 3
Daniel P. Berrange [Mon, 4 Mar 2013 17:27:38 +0000 (17:27 +0000)] 
Fix TLS tests with gnutls 3

When given a CA cert with basic constraints to set non-critical,
and key usage of 'key signing', this should be rejected. Version
of GNUTLS < 3 do not rejecte it though, so we never noticed the
test case was broken

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

11 years agobuild: avoid confusing make with raw name 'undefine'
Eric Blake [Wed, 12 Sep 2012 17:25:51 +0000 (11:25 -0600)] 
build: avoid confusing make with raw name 'undefine'

Make has a builtin operator 'undefine', and coupled with latest
automake.git, this test name ended up confusing make into thinking
the file name was meant to be used as the make operator.  Renaming
the file avoids the confusion.

* tests/undefine: Rename...
* tests/virsh-undefine: ...to this.
* tests/Makefile.am (test_scripts): Use new name.
Reported by Jim Meyering.

(cherry picked from commit a20f06d9d9b0353d7fb7a8e11a631253d5961b96)

11 years agovirsh: Fix POD syntax
Jiri Denemark [Fri, 26 Oct 2012 10:25:14 +0000 (12:25 +0200)] 
virsh: Fix POD syntax

The first two hunks fix "Unterminated I<...> sequence" error and the
last one fixes "’=item’ outside of any ’=over’" error.

(cherry picked from commit 61299a1c983a64c7e0337b94232fdd2d42c1f4f2)
Signed-off-by: Eric Blake <eblake@redhat.com>
Conflicts:
tools/virsh.pod - drop hunks not present this far back

11 years agobuild: more workarounds for if_bridge.h
Eric Blake [Thu, 29 Aug 2013 21:43:53 +0000 (15:43 -0600)] 
build: more workarounds for if_bridge.h

This is a second attempt at fixing the problem first attempted
in commit 2df8d99; basically undoing the fact that it was
reverted in commit 43cee32f, plus fixing two more issues: the
code in configure.ac has to EXACTLY match virnetdevbridge.c
with regards to declaring in6 types before using if_bridge.h,
and the fact that RHEL 5 has even more conflicts:

In file included from util/virnetdevbridge.c:49:
/usr/include/linux/in6.h:47: error: conflicting types for 'in6addr_any'
/usr/include/netinet/in.h:206: error: previous declaration of 'in6addr_any' was here
/usr/include/linux/in6.h:49: error: conflicting types for 'in6addr_loopback'
/usr/include/netinet/in.h:207: error: previous declaration of 'in6addr_loopback' was here

The rest of this commit message borrows from the original try
of 2df8d99:

A fresh checkout on a RHEL 6 machine with these packages:
kernel-headers-2.6.32-405.el6.x86_64
glibc-2.12-1.128.el6.x86_64
failed to configure with this message:
checking for linux/if_bridge.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support

Digging in config.log, we see that the problem is identical to
what we fixed earlier in commit d12c2811:

configure:98831: checking for linux/if_bridge.h
configure:98853: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/linux/if_bridge.h:17,
                 from conftest.c:559:
/usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
configure:98860: $? = 1

I had not hit it earlier because I was using incremental builds,
where config.cache had shielded me from the kernel-headers breakage.

* configure.ac (if_bridge.h): Avoid conflicting type definitions.
* src/util/virnetdevbridge.c (includes): Also sanitize for RHEL 5.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 70024dc9192038575ab5217ac35080b038e5b13e)

Done in one patch rather than a series for bisectability reasons
(as intermediate patches suffer from various problems on various
platforms), and because the intermediate patches include a revert,
but it is pointless to backport two patches where one undoes the
other.  Intermediate patches include: 9a2f36ec308a9a1bf661c,
d12c2812df8d9943cee32 (phew, that's a mouthful).

Conflicts:
configure.ac - skip the churn of all intermediate patches
src/util/virnetdevbridge.c - ditto

11 years agobuild: allow building with newer glibc-headers and -O0
Eric Blake [Mon, 4 Jun 2012 17:33:20 +0000 (11:33 -0600)] 
build: allow building with newer glibc-headers and -O0

glibc 2.15 (on Fedora 17) coupled with explicit disabling of
optimization during development dies a painful death:

In file included from /usr/include/limits.h:27:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:169,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:34,
                 from util/bitmap.c:26:
/usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
cc1: all warnings being treated as errors

Work around this by only conditionally defining _FORTIFY_SOURCE,
in the case where glibc can actually use it.  The trick is using
AH_VERBATIM instead of AC_DEFINE.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Squelch
_FORTIFY_SOURCE when needed to avoid glibc #warnings.

(cherry picked from commit 2af63b1c349114df98c163a8401fd9cf2facdabe)

11 years agoFix race condition when destroying guests
Daniel P. Berrange [Fri, 18 Jan 2013 14:33:51 +0000 (14:33 +0000)] 
Fix race condition when destroying guests

When running virDomainDestroy, we need to make sure that no other
background thread cleans up the domain while we're doing our work.
This can happen if we release the domain object while in the
middle of work, because the monitor might detect EOF in this window.
For this reason we have a 'beingDestroyed' flag to stop the monitor
from doing its normal cleanup. Unfortunately this flag was only
being used to protect qemuDomainBeginJob, and not qemuProcessKill

This left open a race condition where either libvirtd could crash,
or alternatively report bogus error messages about the domain already
having been destroyed to the caller

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

Conflicts:
src/qemu/qemu_driver.c

11 years agoDon't ignore return value of qemuProcessKill
Daniel P. Berrange [Thu, 27 Sep 2012 09:07:03 +0000 (10:07 +0100)] 
Don't ignore return value of qemuProcessKill

When calling qemuProcessKill from the virDomainDestroy impl
in QEMU, do not ignore the return value. This ensures that
if QEMU fails to respond to SIGKILL, the caller will know
about the failure.

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

11 years agoconf: Remove console stream callback only when freeing console helper
Peter Krempa [Fri, 3 Aug 2012 09:20:29 +0000 (11:20 +0200)] 
conf: Remove console stream callback only when freeing console helper

Commit ba226d334acbc49f6751b430e0c4e00f69eef6bf tried to fix crash of
the daemon when a domain with an open console was destroyed. The fix was
wrong as it tried to remove the callback also when the stream was
aborted, where at that point the fd stream driver was already freed and
removed.

This patch clears the callbacks with a helper right before the hash is
freed, so that it doesn't interfere with other codepaths where the
stream object is freed.

(cherry picked from commit 45edefc7a7bcbec988f54331ff37fc32e4bc2718)

11 years agoconf: Remove callback from stream when freeing entries in console hash
Peter Krempa [Fri, 27 Jul 2012 12:50:54 +0000 (14:50 +0200)] 
conf: Remove callback from stream when freeing entries in console hash

When a domain has a active console connection and is destroyed the
callback is called on private data that no longer exist causing a
segfault.

(cherry picked from commit ba226d334acbc49f6751b430e0c4e00f69eef6bf)

11 years agostorage: Need to also VIR_FREE(reg)
Luca Tettamanti [Thu, 25 Apr 2013 19:44:30 +0000 (21:44 +0200)] 
storage: Need to also VIR_FREE(reg)

Commit-id 'afc4631b' added the regfree(reg) to free resources alloc'd
during regcomp; however, reg still needed to be VIR_FREE()'d. The call
to regfree() also didn't account for possible NULL value.  Reformatted
the call to be closer to usage.
(cherry picked from commit 71da3b66a8455faf8019effe3cf504a31f91f54a)

Backported to 0.9.12 with afc4631b and its revert skipped.

Signed-off-by: Luca Tettamanti <ltettamanti acunu com>
11 years agoqemu: Add support for -no-user-config
Jiri Denemark [Thu, 26 Apr 2012 10:11:49 +0000 (12:11 +0200)] 
qemu: Add support for -no-user-config

Thanks to this new option we are now able to use modern CPU models (such
as Westmere) defined in external configuration file.

The qemu-1.1{,-device} data files for qemuhelptest are filled in with
qemu-1.1-rc2 output for now. I will update those files with real
qemu-1.1 output once it is released.

(cherry picked from commit 63b4243624b8fdabebaf5e6ec912095b2b5fdf5c)

11 years agorpc: Fix crash on error paths of message dispatching
Peter Krempa [Fri, 4 Jan 2013 15:15:04 +0000 (16:15 +0100)] 
rpc: Fix crash on error paths of message dispatching

This patch resolves CVE-2013-0170:
https://bugzilla.redhat.com/show_bug.cgi?id=893450

When reading and dispatching of a message failed the message was freed
but wasn't removed from the message queue.

After that when the connection was about to be closed the pointer for
the message was still present in the queue and it was passed to
virNetMessageFree which tried to call the callback function from an
uninitialized pointer.

This patch removes the message from the queue before it's freed.

* rpc/virnetserverclient.c: virNetServerClientDispatchRead:
    - avoid use after free of RPC messages

(cherry picked from commit 46532e3e8ed5f5a736a02f67d6c805492f9ca720)

11 years agoqemu: Fix off-by-one error while unescaping monitor strings
Peter Krempa [Thu, 14 Jun 2012 08:29:36 +0000 (10:29 +0200)] 
qemu: Fix off-by-one error while unescaping monitor strings

While unescaping the commands the commands passed through to the monitor
function qemuMonitorUnescapeArg() initialized lenght of the input string
to strlen()+1 which is fine for alloc but not for iteration of the
string.

This patch fixes the off-by-one error and drops the pointless check for
a single trailing slash that is automaticaly handled by the default
branch of switch.

(cherry picked from commit 0f4660c8787cc41fe67f869984c0ae11d680037e)

11 years agoRevert "rpc: Discard non-blocking calls only when necessary"
Jiri Denemark [Mon, 21 May 2012 14:02:05 +0000 (16:02 +0200)] 
Revert "rpc: Discard non-blocking calls only when necessary"

This reverts commit b1e374a7ac56927cfe62435179bf0bba1e08b372, which was
rather bad since I failed to consider all sides of the issue. The main
things I didn't consider properly are:

- a thread which sends a non-blocking call waits for the thread with
  the buck to process the call
- the code doesn't expect non-blocking calls to remain in the queue
  unless they were already partially sent

Thus, the reverted patch actually breaks more than what it fixes and
clients (which may even be libvirtd during p2p migrations) will likely
end up in a deadlock.

(cherry picked from commit 63643f67abcdeaa33a0f85ea8e54da75ea9908e4)

11 years agobuild: fix virnetlink on glibc 2.11
Eric Blake [Fri, 18 May 2012 15:42:25 +0000 (09:42 -0600)] 
build: fix virnetlink on glibc 2.11

We were being lazy - virnetlink.c was getting uint32_t as a
side-effect from glibc 2.14's <unistd.h>, but older glibc 2.11
does not provide uint32_t from <unistd.h>.  In fact, POSIX states
that <unistd.h> need only provide intptr_t, not all of <stdint.h>,
so the bug really is ours.  Reported by Jonathan Alescio.

* src/util/virnetlink.h: Include <stdint.h>.

(cherry picked from commit e8314e78f9c5d5ad84cfda5c61000e50d91c4a1e)

11 years agosecurity: Fix libvirtd crash possibility
Martin Kletzander [Wed, 12 Sep 2012 21:43:26 +0000 (23:43 +0200)] 
security: Fix libvirtd crash possibility

Fix for CVE-2012-4423.

When generating RPC protocol messages, it's strictly needed to have a
continuous line of numbers or RPC messages. However in case anyone
tries backporting some functionality and will skip a number, there is
a possibility to make the daemon segfault with newer virsh (version of
the library, rpc call, etc.) even unintentionally.

The problem is that the skipped numbers will get func filled with
NULLs, but there is no check whether these are set before the daemon
tries to run them. This patch very simply enhances one check and fixes
that.

(cherry picked from commit b7ff9e696063189a715802d081d55a398663c15a)

11 years agodaemon: Fix crash in virTypedParameterArrayClear
Jiri Denemark [Mon, 30 Jul 2012 10:14:54 +0000 (12:14 +0200)] 
daemon: Fix crash in virTypedParameterArrayClear

Daemon uses the following pattern when dispatching APIs with typed
parameters:

    VIR_ALLOC_N(params, nparams);
    virDomain*(dom, params, &nparams, flags);
    virTypedParameterArrayClear(params, nparams);

In case nparams was originally set to 0, virDomain* API would fill it
with the number of typed parameters it can provide and we would use this
number (rather than zero) to clear params. Because VIR_ALLOC* returns
non-NULL pointer even if size is 0, the code would end up walking
through random memory. If we were lucky enough and the memory contained
7 (VIR_TYPED_PARAM_STRING) at the right place, we would try to free a
random pointer and crash.

Let's make sure params stays NULL when nparams is 0.

(cherry picked from commit 6039a2cb49c8af4c68460d2faf365a7e1c686c7b)

13 years agoRelease of libvirt-0.9.12 v0.9.12
Daniel Veillard [Mon, 14 May 2012 02:52:04 +0000 (10:52 +0800)] 
Release of libvirt-0.9.12

* configure.ac docs/news.html.in libvirt.spec.in: updates for the release
* po/*.po: pushed new sources and synchronized new languages translations

13 years agoesx: Fix memory leaks in error paths related to transferred ownership
Matthias Bolte [Sun, 6 May 2012 17:33:59 +0000 (19:33 +0200)] 
esx: Fix memory leaks in error paths related to transferred ownership

Appending an item to a list transfers ownership of that item to the
list owner. But an error can occur in between item allocation and
appending it to the list. In this case the item has to be freed
explicitly. This was not done in some special cases resulting in
possible memory leaks.

Reported by Coverity.

13 years agoqemu: Don't skip detection of virtual cpu's on non KVM targets
Peter Krempa [Mon, 7 May 2012 11:58:22 +0000 (13:58 +0200)] 
qemu: Don't skip detection of virtual cpu's on non KVM targets

This patch lifts the limit of calling thread detection code only on KVM
guests. With upstream qemu the thread mappings are reported also on
non-KVM machines.

QEMU adopted the thread_id information from the kvm branch.

To remain compatible with older upstream versions of qemu the check is
attempted but the failure to detect threads (or even run the monitor
command - on older versions without SMP support) is treated non-fatal
and the code reports one vCPU with pid of the hypervisor (in same
fashion this was done on non-KVM guests).

13 years agoqemu: Re-detect virtual cpu threads after cpu hot (un)plug.
Peter Krempa [Mon, 7 May 2012 11:56:17 +0000 (13:56 +0200)] 
qemu: Re-detect virtual cpu threads after cpu hot (un)plug.

After a cpu hotplug the qemu driver did not refresh information about
virtual processors used by qemu and their corresponding threads. This
patch forces a re-detection as is done on start of QEMU.

This ensures that correct information is reported by the
virDomainGetVcpus API and "virsh vcpuinfo".

A failure to obtain the thread<->vcpu mapping is treated non-fatal and
the mapping is not updated in a case of failure as not all versions of
QEMU report this in the info cpus command.

13 years agoqemu: Refactor qemuDomainSetVcpusFlags
Peter Krempa [Mon, 7 May 2012 11:53:20 +0000 (13:53 +0200)] 
qemu: Refactor qemuDomainSetVcpusFlags

This patch changes a switch statement into ifs when handling live vs.
configuration modifications getting rid of redundant code in case when
both live and persistent configuration gets changed.

13 years agobuild: fix stamp file name
Eric Blake [Fri, 11 May 2012 14:20:34 +0000 (08:20 -0600)] 
build: fix stamp file name

Ever since commit c964b6a, make was trying to find the timestamp
of '""./apibuild.py".stamp"', but only touching 'apibuild.py.stamp',
and thus always rebuilding.  Reported by Daniel P. Berrange.

* docs/Makefile.am (APIBUILD, APIBUILD_STAMP): Omit bogus quotes.

13 years agousb: fix crash when failing to attach a second usb device
Guannan Ren [Fri, 11 May 2012 06:29:15 +0000 (14:29 +0800)] 
usb: fix crash when failing to attach a second usb device

when failing to attach another usb device to a domain for some reason
which has one use device attached before, the libvirtd crashed.
The crash is caused by null-pointer dereference error in invoking
usbDeviceListSteal passed in NULL value usb variable.
commit 05abd1507d66aabb6cad12eeafeb4c4d1911c585 introduces the bug.

13 years agodocs: mention migration issue of which credentials are used
Eric Blake [Mon, 30 Apr 2012 20:51:07 +0000 (14:51 -0600)] 
docs: mention migration issue of which credentials are used

Based on a report by Seth Vidal.  Just because _you_ can use virsh
to connect to both source and destinations does not mean that libvirtd
on the source (aka _root_) can likewise connect to the destination;
this matters when setting up a peer-to-peer migration instead of a
native one.

* docs/migration.html.in: Mention that in peer-to-peer, the owner
of the source libvirtd (usually root) must be able to connect to
the destination.

13 years agobuild: Fix the typo in configure.ac
Osier Yang [Thu, 10 May 2012 02:25:22 +0000 (10:25 +0800)] 
build: Fix the typo in configure.ac

s/nuamd/numad/,

13 years agoconf: Fix memory leaks in virStoragePoolDefParseSource
Alex Jia [Wed, 9 May 2012 10:48:46 +0000 (18:48 +0800)] 
conf: Fix memory leaks in virStoragePoolDefParseSource

Detected by valgrind. Leaks are introduced in commit 122fa379.

src/conf/storage_conf.c: fix memory leaks.

How to reproduce?
$ make && make -C tests check TESTS=storagepoolxml2xmltest
$ cd tests && valgrind -v --leak-check=full ./storagepoolxml2xmltest

actual result:
==28571== LEAK SUMMARY:
==28571==    definitely lost: 40 bytes in 5 blocks
==28571==    indirectly lost: 0 bytes in 0 blocks
==28571==      possibly lost: 0 bytes in 0 blocks
==28571==    still reachable: 1,054 bytes in 21 blocks
==28571==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: fix build when !HAVE_NUMACTL
Eric Blake [Wed, 9 May 2012 23:55:31 +0000 (17:55 -0600)] 
qemu: fix build when !HAVE_NUMACTL

Commit 97010eb1f forgot to change the other side of an #ifdef.

* src/qemu/qemu_process.c (qemuProcessInitNumaMemoryPolicy): Add
argument.

13 years agoReport error when parsing character device target type
Jim Fehlig [Wed, 9 May 2012 17:12:38 +0000 (11:12 -0600)] 
Report error when parsing character device target type

No useful error was being reported when an invalid character device
target type is specified in the domainXML. E.g.

    ...
    <console type="pty">
      <source path="/dev/pts/2"/>
      <target type="kvm" port="0"/>
    </console>
    ...

resulted in

error: Failed to define domain from x.xml
error: An error occurred, but the cause is unknown

With this small patch, the error is more helpful

error: Failed to define domain from x.xml
error: XML error: unknown target type 'kvm' specified for character device

13 years agonetlink: Fix build with libnl-3 v0.9.12-rc2
Jiri Denemark [Wed, 9 May 2012 09:57:44 +0000 (11:57 +0200)] 
netlink: Fix build with libnl-3

Commit 642973135c54b93242c4548ef27d591b52b0994c added three direct
references to nl_handle_* instead of using our aliases which hide
differences between libnl-3 and libnl-1.

13 years agonumad: Update comments in libvirt.spec.in
Osier Yang [Wed, 9 May 2012 04:26:36 +0000 (12:26 +0800)] 
numad: Update comments in libvirt.spec.in

Not only support CPU placement now.

13 years agonumad: Check numactl-devel if compiled with numad support
Osier Yang [Wed, 9 May 2012 04:22:58 +0000 (12:22 +0800)] 
numad: Check numactl-devel if compiled with numad support

Since now we pre-set memory policy using libnuma to fully
drive numad, it needs to check numactl-devel if "with_numad"
is "yes".

configure with groups "--with-numad=yes --with-numactl=yes",
"--with-numad=no --with-numactl=yes", "--with-numad=yes
--with-numactl=yes" works fine after the change.

13 years agonumad: Divide cur_balloon by 1024 before passing it to numad
Osier Yang [Tue, 8 May 2012 16:04:37 +0000 (00:04 +0800)] 
numad: Divide cur_balloon by 1024 before passing it to numad

Numad expects MB by default.

13 years agonumad: Always output 'placement' of <vcpu>
Osier Yang [Tue, 8 May 2012 16:04:36 +0000 (00:04 +0800)] 
numad: Always output 'placement' of <vcpu>

<vcpu> is not an optional node. The value for its 'placement'
actually always defaults to 'static' in the underlying codes.
(Even no 'cpuset' and 'placement' is specified, the domain
process will be pinned to all the available pCPUs).

13 years agonumad: Copy 'placement' of <numatune> to <vcpu> by default
Osier Yang [Tue, 8 May 2012 16:04:35 +0000 (00:04 +0800)] 
numad: Copy 'placement' of <numatune> to <vcpu> by default

With this patch, one can also fully drive numad by:

  <vcpu>2</vcpu>
  <numatune>
    <memory placement='auto'/>
  </numatune>

New tests are added.

13 years agonumad: Set memory policy from numad advisory nodeset
Osier Yang [Tue, 8 May 2012 16:04:34 +0000 (00:04 +0800)] 
numad: Set memory policy from numad advisory nodeset

Though numad will manage the memory allocation of task dynamically,
it wants management application (libvirt) to pre-set the memory
policy according to the advisory nodeset returned from querying numad,
(just like pre-bind CPU nodeset for domain process), and thus the
performance could benefit much more from it.

This patch introduces new XML tag 'placement', value 'auto' indicates
whether to set the memory policy with the advisory nodeset from numad,
and its value defaults to the value of <vcpu> placement, or 'static'
if 'nodeset' is specified. Example of the new XML tag's usage:

  <numatune>
    <memory placement='auto' mode='interleave'/>
  </numatune>

Just like what current "numatune" does, the 'auto' numa memory policy
setting uses libnuma's API too.

If <vcpu> "placement" is "auto", and <numatune> is not specified
explicitly, a default <numatume> will be added with "placement"
set as "auto", and "mode" set as "strict".

The following XML can now fully drive numad:

1) <vcpu> placement is 'auto', no <numatune> is specified.

   <vcpu placement='auto'>10</vcpu>

2) <vcpu> placement is 'auto', no 'placement' is specified for
   <numatune>.

   <vcpu placement='auto'>10</vcpu>
   <numatune>
     <memory mode='interleave'/>
   </numatune>

And it's also able to control the CPU placement and memory policy
independently. e.g.

1) <vcpu> placement is 'auto', and <numatune> placement is 'static'

   <vcpu placement='auto'>10</vcpu>
   <numatune>
     <memory mode='strict' nodeset='0-10,^7'/>
   </numatune>

2) <vcpu> placement is 'static', and <numatune> placement is 'auto'

   <vcpu placement='static' cpuset='0-24,^12'>10</vcpu>
   <numatune>
     <memory mode='interleave' placement='auto'/>
   </numatume>

A follow up patch will change the XML formatting codes to always output
'placement' for <vcpu>, even it's 'static'.

13 years agosnapshot: allow block devices past cgroup
Eric Blake [Mon, 7 May 2012 22:56:08 +0000 (16:56 -0600)] 
snapshot: allow block devices past cgroup

It turns out that when cgroups are enabled, the use of a block device
for a snapshot target was failing with EPERM due to libvirt failing
to add the block device to the cgroup whitelist.  See also
https://bugzilla.redhat.com/show_bug.cgi?id=810200

* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotUndoSingleDiskActive): Account for cgroup.
(qemuDomainSnapshotCreateDiskActive): Update caller.

13 years agotests: add some self-documentation to tests
Alon Levy [Tue, 8 May 2012 17:46:45 +0000 (20:46 +0300)] 
tests: add some self-documentation to tests

Alon tried './qemuxml2argvtest --help' to figure out a test failure,
but it didn't help.  The information is in HACKING, but it doesn't
hurt to make the tests also provide their own help.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agodomain_conf: add "default" to list of valid spice channels
Alon Levy [Tue, 8 May 2012 17:42:44 +0000 (20:42 +0300)] 
domain_conf: add "default" to list of valid spice channels

qemu's behavior in this case is to change the spice server behavior to
require secure connection to any channel not otherwise specified as
being in plaintext mode. libvirt doesn't currently allow requesting this
(via plaintext-channel=<channel name>).

RHBZ: 819499

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agodomain_conf: add "usbredir" to list of valid spice channels
Alon Levy [Tue, 8 May 2012 13:00:28 +0000 (16:00 +0300)] 
domain_conf: add "usbredir" to list of valid spice channels

Add "usbredir" channel to list of recognized spice channels.

RHBZ: 819498

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agobuild: avoid link failure on Windows
Eric Blake [Wed, 2 May 2012 18:53:04 +0000 (12:53 -0600)] 
build: avoid link failure on Windows

We only know -lpthread exists on platforms where we build
threads-pthread.c; but when we build threads-win32.c, LIB_PTHREAD
is empty.

* tests/Makefile.am (shunloadtest_LDADD): Use correct library.

13 years agovirsh: avoid heap corruption leading to virsh abort
Jim Meyering [Mon, 7 May 2012 19:22:09 +0000 (21:22 +0200)] 
virsh: avoid heap corruption leading to virsh abort

* tools/virsh.c (vshParseSnapshotDiskspec): Fix off-by-3 memmove
that would corrupt heap when parsing escaped --diskspec comma.
Bug introduced via commit v0.9.4-260-g35d52b5.

13 years agoutil: set src_pid for virNetlinkCommand when appropriate
Laine Stump [Fri, 4 May 2012 17:48:20 +0000 (13:48 -0400)] 
util: set src_pid for virNetlinkCommand when appropriate

Until now, the nl_pid of the source address of every message sent by
virNetlinkCommand has been set to the value of getpid(). Most of the
time this doesn't matter, and in the one case where it does
(communication with lldpad), it previously was the proper thing to do,
because the netlink event service (which listens on a netlink socket
for unsolicited messages from lldpad) coincidentally always happened
to bind with a local nl_pid == getpid().

With the fix for:

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

that particular nl_pid is now effectively a reserved value, so the
netlink event service will always bind to something else
(coincidentally "getpid() + (1 << 22)", but it really could be
anything). The result is that communication between lldpad and
libvirtd is broken (lldpad gets a "disconnected" error when it tries
to send a directed message).

The solution to this problem caused by a solution, is to query the
netlink event service's nlhandle for its "local_port", and send that
as the source nl_pid (but only when sending to lldpad, of course - in
other cases we maintain the old behavior of sending getpid()).

There are two cases where a message is being directed at lldpad - one
in virNetDevLinkDump, and one in virNetDevVPortProfileOpSetLink.

The case of virNetDevVPortProfileOpSetLink is simplest to explain -
only if !nltarget_kernel, i.e. the message isn't targetted for the
kernel, is the dst_pid set (by calling
virNetDevVPortProfileGetLldpadPid()), so only in that case do we call
virNetlinkEventServiceLocalPid() to set src_pid.

For virNetDevLinkDump, it's a bit more complicated. The call to
virNetDevVPortProfileGetLldpadPid() was effectively up one level (in
virNetDevVPortProfileOpCommon), although obscured by an unnecessary
passing of a function pointer. This patch removes the function
pointer, and calls virNetDevVPortProfileGetLldpadPid() directly in
virNetDevVPortProfileOpCommon - if it's doing this, it knows that it
should also call virNetlinkEventServiceLocalPid() to set src_pid too;
then it just passes src_pid and dst_pid down to
virNetDevLinkDump. Since (src_pid == 0 && dst_pid == 0) implies that
the kernel is the destination, there is no longer any need to send
nltarget_kernel as an arg to virNetDevLinkDump, so it's been removed.

The disparity between src_pid being int and dst_pid being uint32_t may
be a bit disconcerting to some, but I didn't want to complicate
virNetlinkEventServiceLocalPid() by having status returned separately
from the value.

13 years agoutil: function to get local nl_pid used by netlink event socket
Laine Stump [Fri, 4 May 2012 17:19:51 +0000 (13:19 -0400)] 
util: function to get local nl_pid used by netlink event socket

This value will be needed to set the src_pid when sending netlink
messages to lldpad. It is part of the solution to:

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

Note that libnl's port generation algorithm guarantees that the
nl_socket_get_local_port() will always be > 0 (since it is "getpid() +
(n << 22>" where n is always < 1024), so it is okay to cast the
uint32_t to int (thus allowing us to use -1 as an error sentinel).

13 years agoutil: allow specifying both src and dst pid in virNetlinkCommand
Laine Stump [Fri, 4 May 2012 16:58:36 +0000 (12:58 -0400)] 
util: allow specifying both src and dst pid in virNetlinkCommand

Until now, virNetlinkCommand has assumed that the nl_pid in the source
address of outgoing netlink messages should always be the return value
of getpid(). In most cases it actually doesn't matter, but in the case
of communication with lldpad, lldpad saves this info and later uses it
to send netlink messages back to libvirt. A recent patch to fix Bug
816465 changed the order of the universe such that the netlink event
service socket is no longer bound with nl_pid == getpid(), so lldpad
could no longer send unsolicited messages to libvirtd. Adding src_pid
as an argument to virNetlinkCommand() is the first step in notifying
lldpad of the proper address of the netlink event service socket.

13 years agoutil: fix libvirtd startup failure due to netlink error
Laine Stump [Thu, 3 May 2012 14:39:04 +0000 (10:39 -0400)] 
util: fix libvirtd startup failure due to netlink error

This is part of the solution to the problem detailed in:

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

and further detailed in

  https://www.redhat.com/archives/libvir-list/2012-May/msg00202.htm

A short explanation is included in the comments of the patch itself.

Note that this patch by itself breaks communication between lldpad and
libvirtd, so the other 3 patches in the series must be applied at the
same time as this patch.

13 years agoopenvz: simplify openvzDomainDefineCmd by using virCommandPtr
Guido Günther [Sat, 5 May 2012 06:47:05 +0000 (08:47 +0200)] 
openvz: simplify openvzDomainDefineCmd by using virCommandPtr

13 years agoqemu: call usb search function for hostdev initialization and hotplug
Guannan Ren [Sun, 6 May 2012 14:45:05 +0000 (22:45 +0800)] 
qemu: call usb search function for hostdev initialization and hotplug

src/qemu/qemu_hostdev.c:
refactor qemuPrepareHostdevUSBDevices function, make it focus on
adding usb device to activeUsbHostdevs after check. After that,
the usb hotplug function qemuDomainAttachHostDevice also could use
it.
expand qemuPrepareHostUSBDevices to perform the usb search,
rollback on failure.

src/qemu/qemu_hotplug.c:
If there are multiple usb devices available with same vendorID and productID,
but with different value of "bus, device", we give an error to let user
use <address> to specify the desired one.

13 years agousb: create functions to search usb device accurately
Guannan Ren [Fri, 4 May 2012 07:49:58 +0000 (15:49 +0800)] 
usb: create functions to search usb device accurately

usbFindDevice():get usb device according to
                idVendor, idProduct, bus, device
                it is the exact match of the four parameters

usbFindDeviceByBus():get usb device according to bus, device
                  it returns only one usb device same as usbFindDevice

usbFindDeviceByVendor():get usb device according to idVendor,idProduct
                     it probably returns multiple usb devices.

usbDeviceSearch(): a helper function to do the actual search

13 years agorpm: Handle different source URLs for maint releases
Cole Robinson [Sun, 6 May 2012 18:09:22 +0000 (14:09 -0400)] 
rpm: Handle different source URLs for maint releases

13 years agodocs: Add 'maintenance releases' link in 'News' sidebar
Cole Robinson [Sun, 6 May 2012 17:50:22 +0000 (13:50 -0400)] 
docs: Add 'maintenance releases' link in 'News' sidebar

13 years agoqemu: Emit compatible XML when migrating a domain
Jiri Denemark [Fri, 4 May 2012 19:23:17 +0000 (21:23 +0200)] 
qemu: Emit compatible XML when migrating a domain

When we added the default USB controller into domain XML, we efficiently
broke migration to older versions of libvirt that didn't support USB
controllers at all (0.9.4 and earlier) even for domains that don't use
anything that the older libvirt can't provide. We still want to present
the default USB controller in any XML seen by a user/app but we can
safely remove it from the domain XML used during migration. If we are
migrating to a new enough libvirt, it will add the controller XML back,
while older libvirt won't be confused with it although it will still
tell qemu to create the controller.

Similar approach can be used in the future whenever we find out we
always enabled some kind of device without properly advertising it in
domain XML.

13 years agoqemu: Don't use virDomainDefFormat* directly
Jiri Denemark [Fri, 4 May 2012 19:00:13 +0000 (21:00 +0200)] 
qemu: Don't use virDomainDefFormat* directly

Always use appropriate qemuDomain{,Def}Format wrapper since it may do
some additional magic based on the flags.

13 years agoqemu: reject blockiotune if qemu too old
Eric Blake [Fri, 4 May 2012 16:24:17 +0000 (10:24 -0600)] 
qemu: reject blockiotune if qemu too old

Commit 4c82f09e added a capability check for qemu per-device io
throttling, but only applied it to domain startup.  As mentioned
in the previous commit (98cec05), the user can still get an 'internal
error' message during a hotplug attempt, when the monitor command
doesn't exist.  It is confusing to allow tuning on inactive domains
only to then be rejected when starting the domain.

* src/qemu/qemu_driver.c (qemuDomainSetBlockIoTune): Reject
offline tuning if online can't match it.

13 years agoqemu: don't modify domain on failed blockiotune
Eric Blake [Fri, 4 May 2012 15:43:23 +0000 (09:43 -0600)] 
qemu: don't modify domain on failed blockiotune

If you have a qemu build that lacks the blockio tune monitor command,
then this command:

$ virsh blkdeviotune rhel6u2 hda --total_bytes_sec 1000
error: Unable to change block I/O throttle
error: internal error Unexpected error

fails as expected (well, the error message is lousy), but the next
dumpxml shows that the domain was modified anyway.  Worse, that means
if you save the domain then restore it, the restore will likely fail
due to throttling being unsupported, even though no throttling should
even be active because the monitor command failed in the first place.

* src/qemu/qemu_driver.c (qemuDomainSetBlockIoTune): Check for
error before making modification permanent.

13 years agoutil: remove error log from stubs of virNetlinkEventServiceStart|Stop
Laine Stump [Thu, 3 May 2012 15:52:17 +0000 (11:52 -0400)] 
util: remove error log from stubs of virNetlinkEventServiceStart|Stop

These two functions are called from main() on all platforms, and
always return success on platforms that don't support libnl. They
still log an error message, though, which doesn't make sense - they
should just be NOPs on those platforms. (Per a suggestion during
review, I've turned the logs into debug messages rather than removing
them completely).

13 years agonode_device: fix possible non-terminated string
Stefan Berger [Fri, 4 May 2012 17:22:22 +0000 (13:22 -0400)] 
node_device: fix possible non-terminated string

Error: STRING_NULL:
/libvirt/src/node_device/node_device_linux_sysfs.c:80:
string_null_argument: Function "saferead" does not terminate string "*buf".
/libvirt/src/util/util.c:101:
string_null_argument: Function "read" fills array "*buf" with a non-terminated string.
/libvirt/src/node_device/node_device_linux_sysfs.c:87:
string_null: Passing unterminated string "buf" to a function expecting a null-terminated string.

13 years agouuid: fix possible non-terminated string
Stefan Berger [Fri, 4 May 2012 17:22:22 +0000 (13:22 -0400)] 
uuid: fix possible non-terminated string

Error: STRING_NULL:
/libvirt/src/util/uuid.c:273:
string_null_argument: Function "getDMISystemUUID" does not terminate string "*dmiuuid".
/libvirt/src/util/uuid.c:241:
string_null_argument: Function "saferead" fills array "*uuid" with a non-terminated string.
/libvirt/src/util/util.c:101:
string_null_argument: Function "read" fills array "*buf" with a non-terminated string.
/libvirt/src/util/uuid.c:274:
string_null: Passing unterminated string "dmiuuid" to a function expecting a null-terminated string.
/libvirt/src/util/uuid.c:138:
var_assign_parm: Assigning: "cur" = "uuidstr". They now point to the same thing.
/libvirt/src/util/uuid.c:164:
string_null_sink_loop: Searching for null termination in an unterminated array "cur".

13 years agotests: fix resource leak
Stefan Berger [Fri, 4 May 2012 14:42:09 +0000 (10:42 -0400)] 
tests: fix resource leak

Error: RESOURCE_LEAK:
/libvirt/tests/qemuxml2argvtest.c:47:
alloc_arg: Calling allocation function "virAlloc" on "ret".
/libvirt/src/util/memory.c:101:
alloc_fn: Storage is returned from allocation function "calloc".
/libvirt/src/util/memory.c:101:
var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/libvirt/tests/qemuxml2argvtest.c:54:
leaked_storage: Variable "ret" going out of scope leaks the storage it points to.

13 years agoqemu: fix resource leak
Stefan Berger [Fri, 4 May 2012 14:42:09 +0000 (10:42 -0400)] 
qemu: fix resource leak

Error: RESOURCE_LEAK:
/libvirt/src/qemu/qemu_driver.c:6968:
alloc_fn: Calling allocation function "calloc".
/libvirt/src/qemu/qemu_driver.c:6968:
var_assign: Assigning: "nodeset" =  storage returned from "calloc(1UL, 1UL)".
/libvirt/src/qemu/qemu_driver.c:6977:
noescape: Variable "nodeset" is not freed or pointed-to in function "virTypedParameterAssign".
/libvirt/src/qemu/qemu_driver.c:6997:
leaked_storage: Variable "nodeset" going out of scope leaks the storage it points to.

13 years agovmx: fix resource leak
Stefan Berger [Fri, 4 May 2012 14:42:09 +0000 (10:42 -0400)] 
vmx: fix resource leak

Error: RESOURCE_LEAK:
/libvirt/src/vmx/vmx.c:2431:
alloc_fn: Calling allocation function "calloc".
/libvirt/src/vmx/vmx.c:2431:
var_assign: Assigning: "networkName" =  storage returned from "calloc(1UL, 1UL)".
/libvirt/src/vmx/vmx.c:2495:
leaked_storage: Variable "networkName" going out of scope leaks the storage it points to.

13 years agoopenvz: read vmguarpages/privvmpages to set memory tunables
Guido Günther [Wed, 25 Apr 2012 19:18:16 +0000 (21:18 +0200)] 
openvz: read vmguarpages/privvmpages to set memory tunables

13 years agoCoverity: Fix resource leak in virnetlink.c
Osier Yang [Wed, 2 May 2012 14:51:38 +0000 (22:51 +0800)] 
Coverity: Fix resource leak in virnetlink.c

13 years agoCoverity: Fix resource leak in nodeinfo.c
Osier Yang [Wed, 2 May 2012 15:18:03 +0000 (23:18 +0800)] 
Coverity: Fix resource leak in nodeinfo.c

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/nodeinfo.c:629: alloc_fn: Calling allocation function "fopen".
/builddir/build/BUILD/libvirt-0.9.10/src/nodeinfo.c:629: var_assign: Assigning: "cpuinfo" =  storage returned from "fopen("/proc/cpuinfo", "r")".
/builddir/build/BUILD/libvirt-0.9.10/src/nodeinfo.c:638: leaked_storage: Variable "cpuinfo" going out of scope leaks the storage it points to.

13 years agoCoverity: Fix resource leak in test driver
Osier Yang [Wed, 2 May 2012 14:51:36 +0000 (22:51 +0800)] 
Coverity: Fix resource leak in test driver

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/test/test_driver.c:1041: alloc_arg: Calling allocation function "virXPathNodeSet" on "devs".
/builddir/build/BUILD/libvirt-0.9.10/src/util/xml.c:621: alloc_arg: "virAllocN" allocates memory that is stored into "*list".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:129: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:129: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(count, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/util/xml.c:625: noescape: Variable "*list" is not freed or pointed-to in function "memcpy".
/builddir/build/BUILD/libvirt-0.9.10/src/test/test_driver.c:1098: leaked_storage: Variable "devs" going out of scope leaks the storage it points to.

13 years agoCoverity: Fix resource leak in xen driver
Osier Yang [Wed, 2 May 2012 14:51:35 +0000 (22:51 +0800)] 
Coverity: Fix resource leak in xen driver

Coverity logs:

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_inotify.c:103: alloc_fn: Calling allocation function "xenDaemonLookupByUUID".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xend_internal.c:2534: alloc_fn: Storage is returned from allocation function "virGetDomain".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:191: alloc_arg: "virAlloc" allocates memory that is stored into "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:210: return_alloc: Returning allocated memory "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xend_internal.c:2534: var_assign: Assigning: "ret" = "virGetDomain(conn, name, uuid)".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xend_internal.c:2541: return_alloc: Returning allocated memory "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_inotify.c:103: var_assign: Assigning: "dom" =  storage returned from "xenDaemonLookupByUUID(conn, rawuuid)".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_inotify.c:126: leaked_storage: Variable "dom" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2742: alloc_fn: Calling allocation function "fopen".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2742: var_assign: Assigning: "cpuinfo" =  storage returned from "fopen("/proc/cpuinfo", "r")".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2763: noescape: Variable "cpuinfo" is not freed or pointed-to in function "xenHypervisorMakeCapabilitiesInternal".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2574:45: noescape: "xenHypervisorMakeCapabilitiesInternal" does not free or save its pointer parameter "cpuinfo".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2768: leaked_storage: Variable "cpuinfo" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2752: alloc_fn: Calling allocation function "fopen".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2752: var_assign: Assigning: "capabilities" =  storage returned from "fopen("/sys/hypervisor/properties/capabilities", "r")".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2763: noescape: Variable "capabilities" is not freed or pointed-to in function "xenHypervisorMakeCapabilitiesInternal".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2574:60: noescape: "xenHypervisorMakeCapabilitiesInternal" does not free or save its pointer parameter "capabilities".
/builddir/build/BUILD/libvirt-0.9.10/src/xen/xen_hypervisor.c:2768: leaked_storage: Variable "capabilities" going out of scope leaks the storage it points to.

13 years agoCoverity: Fix resource leaks in phyp driver
Osier Yang [Fri, 4 May 2012 02:25:58 +0000 (10:25 +0800)] 
Coverity: Fix resource leaks in phyp driver

Coverity logs:

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:523: alloc_fn: Calling allocation function "fopen".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:523: var_assign: Assigning: "fd" =  storage returned from "fopen(local_file, "rb")".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:540: noescape: Variable "fd" is not freed or pointed-to in function "fread".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:542: noescape: Variable "fd" is not freed or pointed-to in function "feof".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:575: leaked_storage: Variable "fd" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:585: leaked_storage: Variable "fd" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2088: alloc_fn: Calling allocation function "phypVolumeLookupByName".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2026: alloc_fn: Storage is returned from allocation function "virGetStorageVol".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:724: alloc_arg: "virAlloc" allocates memory that is stored into "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:753: return_alloc: Returning allocated memory "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2026: var_assign: Assigning: "vol" = "virGetStorageVol(pool->conn, pool->name, volname, key)".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2030: return_alloc: Returning allocated memory "vol".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2088: leaked_storage: Failing to save storage allocated by "phypVolumeLookupByName(pool, voldef->name)" leaks it.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2725: alloc_fn: Calling allocation function "phypGetStoragePoolLookUpByUUID".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2689: alloc_fn: Storage is returned from allocation function "virGetStoragePool".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:592: alloc_arg: "virAlloc" allocates memory that is stored into "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:610: return_alloc: Returning allocated memory "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2689: var_assign: Assigning: "sp" = "virGetStoragePool(conn, pools[i], uuid)".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2694: return_alloc: Returning allocated memory "sp".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2725: leaked_storage: Failing to save storage allocated by "phypGetStoragePoolLookUpByUUID(conn, def->uuid)" leaks it.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2719: alloc_fn: Calling allocation function "phypStoragePoolLookupByName".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2254: alloc_fn: Storage is returned from allocation function "virGetStoragePool".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:592: alloc_arg: "virAlloc" allocates memory that is stored into "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:610: return_alloc: Returning allocated memory "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2254: return_alloc_fn: Directly returning storage allocated by "virGetStoragePool".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2719: leaked_storage: Failing to save storage allocated by "phypStoragePoolLookupByName(conn, def->name)" leaks it.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2270: alloc_fn: Calling allocation function "phypStoragePoolLookupByName".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2254: alloc_fn: Storage is returned from allocation function "virGetStoragePool".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:592: alloc_arg: "virAlloc" allocates memory that is stored into "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/datatypes.c:610: return_alloc: Returning allocated memory "ret".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2254: return_alloc_fn: Directly returning storage allocated by "virGetStoragePool".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2270: var_assign: Assigning: "sp" =  storage returned from "phypStoragePoolLookupByName(vol->conn, vol->pool)".
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2324: leaked_storage: Variable "sp" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libvirt-0.9.10/src/phyp/phyp_driver.c:2327: leaked_storage: Variable "sp" going out of scope leaks the storage it points t

13 years agoCoverity: Fix the forward_null error in Python binding codes
Osier Yang [Wed, 2 May 2012 15:05:59 +0000 (23:05 +0800)] 
Coverity: Fix the forward_null error in Python binding codes

Related coverity log:

Error: FORWARD_NULL:
/builddir/build/BUILD/libvirt-0.9.10/python/libvirt-override.c:355:
assign_zero: Assigning: "params" = 0.
/builddir/build/BUILD/libvirt-0.9.10/python/libvirt-override.c:458:
var_deref_model: Passing null variable "params" to function
"getPyVirTypedParameter", which dereferences it. (The dereference is assumed on
the basis of the 'nonnull' parameter attribute.)

13 years agoqemu: avoid 32-bit compiler warning
Eric Blake [Thu, 3 May 2012 23:04:34 +0000 (17:04 -0600)] 
qemu: avoid 32-bit compiler warning

On 32-bit platforms, gcc warns that the comparison between a long
and (ULLONG_MAX/1024/1024) is always false; throwing in a type
conversion shuts up the warning.

* src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Shut gcc up.

13 years agobuild: support libnl-3
Serge Hallyn [Thu, 3 May 2012 16:10:50 +0000 (11:10 -0500)] 
build: support libnl-3

configure.ac: check for libnl-3 in addition to libnl-1

src/Makefile.am: link against libnl when needed

src/util/virnetlink.c:
support libnl3 api.  To minimize impact on code flow, wrap the
differences under the virNetlink* namespace.

Unfortunately libnl3 moves netlink/msg.h to
/usr/include/libnl3/netlink/msg.h, so the LIBNL_CFLAGS need to be added
to a bunch of places where they weren't needed with libnl1.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric Blake <eblake@redhat.com>