]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
10 years agomaint: this branch is now dead v0.9.6-maint
Eric Blake [Thu, 18 Sep 2014 15:29:07 +0000 (09:29 -0600)] 
maint: this branch is now dead

Upstream is no longer willing to backport patches to a branch
this old.  If you disagree with the policy, please volunteer
to become the branch maintainer on libvir-list@redhat.com

Signed-off-by: Eric Blake <eblake@redhat.com>
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)

12 years agoPrep for release 0.9.6.4 v0.9.6.4
Cole Robinson [Mon, 28 Jan 2013 19:16:56 +0000 (14:16 -0500)] 
Prep for release 0.9.6.4

12 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)

Conflicts:
src/rpc/virnetserverclient.c

12 years agoqemu: Clear async job when p2p migration fails early
Jiri Denemark [Wed, 17 Oct 2012 12:08:17 +0000 (14:08 +0200)] 
qemu: Clear async job when p2p migration fails early

When p2p migration fails early because qemuMigrationIsAllowed or
qemuMigrationIsSafe say migration should be cancelled, we fail to clear
the migration-out async job. As a result of that, further APIs called
for the same domain may fail with Timed out during operation: cannot
acquire state change lock.

Reported by Guido Winkelmann.

Conflicts:
src/qemu/qemu_migration.c - qemuMigrationIsSafe was not there in
                            0.9.6 yet

12 years agoPrep for release 0.9.6.3 v0.9.6.3
Cole Robinson [Sun, 7 Oct 2012 21:49:56 +0000 (17:49 -0400)] 
Prep for release 0.9.6.3

12 years agoMerge branch 'v0.9.6-maint' of git://libvirt.org/libvirt into v0.9.6-maint
Cole Robinson [Sun, 7 Oct 2012 21:48:37 +0000 (17:48 -0400)] 
Merge branch 'v0.9.6-maint' of git://libvirt.org/libvirt into v0.9.6-maint

12 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)

12 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)

12 years agoPrep for release 0.9.6.2 v0.9.6.2
Cole Robinson [Mon, 13 Aug 2012 22:19:51 +0000 (18:19 -0400)] 
Prep for release 0.9.6.2

12 years agobuild: drop check for ANSI compiler
Eric Blake [Thu, 5 Jan 2012 21:21:11 +0000 (14:21 -0700)] 
build: drop check for ANSI compiler

Using automake.git (will become 1.12 someday), I got this error:

configure.ac:90: error: automatic de-ANSI-fication support has been removed
/usr/local/share/aclocal-1.11a/protos.m4:13: AM_C_PROTOTYPES is expanded from...
configure.ac:90: the top level
autom4te: /usr/bin/m4 failed with exit status: 1

In short, pre-C89 compilers are no longer a viable portability
target.  Besides, our code base already requires C99, so worrying
about pre-C89 seems pointless.

* configure.ac (AM_C_PROTOTYPES): Drop, since newer automake no
longer provides it.
(cherry picked from commit 307f3635093b0e89ff78d544d1f81a7c0f589e51)

12 years agotests: avoid seclabeltest crash
Eric Blake [Fri, 20 Jul 2012 20:44:54 +0000 (14:44 -0600)] 
tests: avoid seclabeltest crash

Commit a56c347 introduced a use of random numbers into seclabel
handling, but failed to initialize the random number generator
in the testsuite.  Also, fail with usual status, not 255.

* tests/seclabeltest.c (main): Initialize randomness.
(cherry picked from commit a22a36e8feaef19413e1a6af533eaa50f3c5df2d)

Conflicts:
tests/seclabeltest.c

12 years agoRemove unused <dirent.h> imports to appease syntax-check
Cole Robinson [Mon, 13 Aug 2012 00:08:53 +0000 (20:08 -0400)] 
Remove unused <dirent.h> imports to appease syntax-check

This is 0.9.6-maint only, but similar changes are upstream

12 years agoAppease gnulib sc_makefile_at_at_check
Cole Robinson [Mon, 13 Aug 2012 00:06:31 +0000 (20:06 -0400)] 
Appease gnulib sc_makefile_at_at_check

This is for v0.9.6 maint only, though similar changes are upstream.

12 years agotest: fix segfault in networkxml2argvtest
Laine Stump [Thu, 5 Apr 2012 07:18:33 +0000 (03:18 -0400)] 
test: fix segfault in networkxml2argvtest

This bug resolves https://bugzilla.redhat.com/show_bug.cgi?id=810100

rpm builds for i686 were failing with a segfault in
networkxml2argvtest. Running under valgrind showed that a region of
memory was being referenced after it had been freed (as the result of
realloc - see the valgrind report in the BZ).

The problem (in replaceTokens() - added in commit 22ec60, meaning this
bug was in 0.9.10 and 0.9.11) was that the pointers token_start and
token_end were being computed based on the value of *buf, then *buf
was being realloc'ed (potentially moving it), then token_start and
token_end were used without recomputing them to account for movement
of *buf.

The solution is to change the code so that token_start and token_end
are offsets into *buf rather than pointers. This way there is only a
single pointer to the buffer, and nothing needs readjusting after a
realloc. (You may note that some uses of token_start/token_end didn't
need to be changed to add in "*buf +" - that's because there ended up
being a +*buf and -*buf which canceled each other out).

DV gets the credit for finding this bug and pointing out the valgrind
report.
(cherry picked from commit bde32b1ada0d0c8d9e3f82bebe19472b620ef54e)

12 years agotests: dynamically replace dnsmasq path
Philipp Hahn [Mon, 30 Jan 2012 17:13:08 +0000 (18:13 +0100)] 
tests: dynamically replace dnsmasq path

The path to the dnsmasq binary can be configured while in the test data
the path is hard-coded to /usr/bin/. This break the test suite if a the
binary is located in a different location, like /usr/local/sbin/.

Replace the hard coded path in the test data by a token, which is
dynamically replaced in networkxml2argvtest with the configured path
after the test data has been loaded.

(Another option would have been to modify configure.ac to generate the
 test data during configure, but I do not know of an easy way do trick
 configure into mass-generate those test files without listing every
 single one, which I consider less flexible.)

- unit-test the unit-test:
  #include <assert.h>
  #define TEST(in,token,rep,out) { char *buf = strdup(in); assert(!replaceTokens(&buf, token, rep) && !strcmp(buf, out)); free(buf); }
  TEST("", "AA", "B", "");
  TEST("A", "AA", "B", "A");
  TEST("AA", "AA", "B", "B");
  TEST("AAA", "AA", "B", "BA");
  TEST("AA", "AA", "BB", "BB");
  TEST("AA", "AA", "BBB", "BBB");
  TEST("<AA", "AA", "B", "<B");
  TEST("<AA", "AA", "BB", "<BB");
  TEST("<AA", "AA", "BBB", "<BBB");
  TEST("AA>", "AA", "B", "B>");
  TEST("AA>", "AA", "BB", "BB>");
  TEST("AA>", "AA", "BBB", "BBB>");
  TEST("<AA>", "AA", "B", "<B>");
  TEST("<AA>", "AA", "BB", "<BB>");
  TEST("<AA>", "AA", "BBB", "<BBB>");
  TEST("<AA|AA>", "AA", "B", "<B|B>");
  TEST("<AA|AA>", "AA", "BB", "<BB|BB>");
  TEST("<AA|AA>", "AA", "BBB", "<BBB|BBB>");
  TEST("<AAAA>", "AA", "B", "<BB>");
  TEST("<AAAA>", "AA", "BB", "<BBBB>");
  TEST("<AAAA>", "AA", "BBB", "<BBBBBB>");
  TEST("AAAA>", "AA", "B", "BB>");
  TEST("AAAA>", "AA", "BB", "BBBB>");
  TEST("AAAA>", "AA", "BBB", "BBBBBB>");
  TEST("<AAAA", "AA", "B", "<BB");
  TEST("<AAAA", "AA", "BB", "<BBBB");
  TEST("<AAAA", "AA", "BBB", "<BBBBBB");
  alarm(1); /* no infinite loop */
  TEST("A", "A", "A", "A");
  TEST("AA", "A", "A", "AA");
  alarm(0);

Signed-off-by: Philipp Hahn <hahn@univention.de>
(cherry picked from commit 22ec60001e9a41fbd529922551313970224aad94)

Conflicts:
tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
tests/networkxml2argvdata/nat-network-dns-srv-record.argv

13 years agodaemon: Fix crash in virTypedParameterArrayClear
Eric Blake [Wed, 1 Aug 2012 22:14:41 +0000 (16:14 -0600)] 
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)

Conflicts:

daemon/remote.c - context differences, and fewer call sites

13 years agobuild: update to latest gnulib, for secure tarball
Eric Blake [Tue, 10 Jul 2012 15:37:07 +0000 (09:37 -0600)] 
build: update to latest gnulib, for secure tarball

Pick up some build fixes in the latest gnulib.  In particular,
we want to ensure that official tarballs are secure, but don't
want to penalize people who don't run 'make dist', since fixed
automake still hasn't hit common platforms like Fedora 17.

* .gnulib: Update to latest, for Automake CVE-2012-3386 detection.
* bootstrap: Resync from gnulib.
* bootstrap.conf (gnulib_extra_files): Drop missing, since gnulib
has dropped it in favor of Automake's version.
* cfg.mk (local-checks-to-skip): Conditionally skip the security
check in cases where it doesn't matter.
(cherry picked from commit f12e1396212b9127306245c61566f171a3df7aa3)

Conflicts:
.gnulib - skip all intermediate commits touching this file
bootstrap - likewise

13 years agobuild: update to latest gnulib
Eric Blake [Fri, 27 Jul 2012 16:51:40 +0000 (10:51 -0600)] 
build: update to latest gnulib

Gnulib finally relaxed the isatty license, needed as first mentioned here:
https://www.redhat.com/archives/libvir-list/2012-February/msg01022.html

Other improvements include better syntax-check rules (we can delete one
of ours now that it is a duplicate) and better compiler warning usage.

* .gnulib: Update to latest, for isatty.
* cfg.mk (sc_prohibit_strncpy): Drop a now-redundant rule.
* bootstrap.conf (gnulib_modules): Add isatty.
* bootstrap: Resync from gnulib.
(cherry picked from commit e925ea3156f2cc8d57a29eeeb839202adc989391)

Conflicts:
.gnulib - skip all intermediate commits touching this file
bootstrap - likewise

13 years agobuild: update to latest gnulib
Eric Blake [Thu, 12 Jan 2012 00:19:01 +0000 (17:19 -0700)] 
build: update to latest gnulib

Pick up recent gnulib improvements.

* .gnulib: Update to latest.
* bootstrap: Resync.
* bootstrap.conf (gnulib_tool_option_extras): Adjust to bootstrap
changes.
* gnulib/lib/Makefile.am: Likewise.
(cherry picked from commit 29db7a0072df10e4adbe99f452afd9503317ec35)

Conflicts:
.gnulib - skip all intermediate commits touching this file
bootstrap.conf - likewise (especially skip commit f7bd00c)

13 years agoStable release 0.9.6.1 v0.9.6.1
Cole Robinson [Fri, 15 Jun 2012 18:59:51 +0000 (14:59 -0400)] 
Stable release 0.9.6.1

13 years agoPull in GNULIB regex module for benefit of test suite on Win32
Daniel P. Berrange [Wed, 4 Apr 2012 10:56:04 +0000 (11:56 +0100)] 
Pull in GNULIB regex module for benefit of test suite on Win32
(cherry picked from commit f94d9c5793cc57b5228c7f1915bdc76c84f0a923)

13 years agoFix typos in API XML file paths
Daniel P. Berrange [Wed, 15 Feb 2012 11:29:38 +0000 (11:29 +0000)] 
Fix typos in API XML file paths

* libvirt.pc.in: Add missing '/api/' in path
* libvirt.spec.in, mingw32-libvirt.spec.in: s/apis/api/
(cherry picked from commit 5452e88c32081b48fc8d29ce266c95bf31ee53ce)

13 years agoqemu: avoid closing fd more than once
Wen Congyang [Wed, 30 May 2012 09:20:44 +0000 (17:20 +0800)] 
qemu: avoid closing fd more than once

If we migrate to fd, spec->fwdType is not MIGRATION_FWD_DIRECT,
we will close spec->dest.fd.local in qemuMigrationRun(). So we
should set spec->dest.fd.local to -1 in qemuMigrationRun().

Bug present since 0.9.5 (commit 326176179).
(cherry picked from commit b19c236d69278c967d2d8b4aae97ac76213f1c10)

13 years agocommand: check for fork error before closing fd
Wen Congyang [Wed, 30 May 2012 09:20:44 +0000 (17:20 +0800)] 
command: check for fork error before closing fd

We should not set *outfd or *errfd if virExecWithHook() failed
because the caller may close these fds.

Bug present since v0.4.5 (commit 60ed1d2a).
(cherry picked from commit 746ff701e8727439cac8ca72531d82e5cb7fa129)

13 years agofdstream: avoid double close bug
Eric Blake [Wed, 30 May 2012 15:20:37 +0000 (09:20 -0600)] 
fdstream: avoid double close bug

Wen Congyang reported that we have a double-close bug if we fail
virFDStreamOpenInternal, since childfd duplicated one of the fds[]
array contents.  In truth, since we always transfer both members
of fds to other variables, we should close the fds through those
other names, and just use fds[] for pipe().

Bug present since 0.9.0 (commit e886237a).

* src/fdstream.c (virFDStreamOpenFileInternal): Swap scope of
childfd and fds[], to avoid a double close.
(cherry picked from commit f3cfc7c8848006b613e09bb1acd081716854527e)

13 years agocommand: avoid double close bugs
Eric Blake [Tue, 29 May 2012 23:47:58 +0000 (17:47 -0600)] 
command: avoid double close bugs

KAMEZAWA Hiroyuki reported a nasty double-free bug when virCommand
is used to convert a string into input to a child command.  The
problem is that the poll() loop of virCommandProcessIO would close()
the write end of the pipe in order to let the child see EOF, then
the caller virCommandRun() would also close the same fd number, with
the second close possibly nuking an fd opened by some other thread
in the meantime.  This in turn can have all sorts of bad effects.

The bug has been present since the introduction of virCommand in
commit f16ad06f.

This is based on his first attempt at a patch, at
https://bugzilla.redhat.com/show_bug.cgi?id=823716

* src/util/command.c (_virCommand): Drop inpipe member.
(virCommandProcessIO): Add argument, to avoid closing caller's fd
without informing caller.
(virCommandRun, virCommandNewArgs): Adjust clients.
(cherry picked from commit da831afcf2f6c0d3ed1ea3128a6208f548a05d8f)

Conflicts:

src/util/command.c

13 years agoavoid fd leak
Wen Congyang [Wed, 30 May 2012 09:20:46 +0000 (17:20 +0800)] 
avoid fd leak

virCommandRunAsync() will set errfd if it succeed. We should
close it if virFDStreamOpenInternal() fails.
(cherry picked from commit 655cffa0f25be40c68624036af80bde102177612)

13 years agoavoid closing uninitialized fd
Wen Congyang [Wed, 30 May 2012 09:20:41 +0000 (17:20 +0800)] 
avoid closing uninitialized fd

If the system does not support bypass cache, we will close fd,
but it is uninitialized.
(cherry picked from commit 0a045f01cfa48fabd41c801e3f44034a4e6da485)

13 years agoSet a sensible default master start port for ehci companion controllers
Daniel P. Berrange [Mon, 14 May 2012 12:22:58 +0000 (13:22 +0100)] 
Set a sensible default master start port for ehci companion controllers

The uhci1, uhci2, uhci3 companion controllers for ehci1 must
have a master start port set. Since this value is predictable
we should set it automatically if the app does not supply it
(cherry picked from commit 03b804a200e214e3faf264b16f41a640c1344962)

13 years agoFix logic for assigning PCI addresses to USB2 companion controllers
Daniel P. Berrange [Mon, 14 May 2012 10:16:22 +0000 (11:16 +0100)] 
Fix logic for assigning PCI addresses to USB2 companion controllers

Currently each USB2 companion controller gets put on a separate
PCI slot. Not only is this wasteful of PCI slots, but it is not
in compliance with the spec for USB2 controllers. The master
echi1 and all companion controllers should be in the same slot,
with echi1 in function 7, and uhci1-3 in functions 0-2 respectively.

* src/qemu/qemu_command.c: Special case handling of USB2 controllers
  to apply correct pci slot assignment
* tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.args,
  tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml: Expand
  test to cover automatic slot assignment
(cherry picked from commit 1ebd52cb871f87b7868503b28448e96d59e41d63)

Conflicts:

tests/qemuxml2xmltest.c

13 years agoFix virDomainDeviceInfoIsSet() to check all struct fields
Daniel P. Berrange [Tue, 15 May 2012 15:16:49 +0000 (16:16 +0100)] 
Fix virDomainDeviceInfoIsSet() to check all struct fields

The virDomainDeviceInfoIsSet API was only checking if an
address or alias was set in the struct. Thus if only a
rom bar setting / filename, boot index, or USB master
value was set, they could be accidentally dropped when
formatting XML
(cherry picked from commit 2c195fdbf3293792e39bc4f06755ae751025b0ea)

Conflicts:

src/conf/domain_conf.c

(crobinso: some elements aren't in maint branch, drop them)

13 years agolxc: use hand-rolled code in place of unlockpt and grantpt
Serge E. Hallyn [Wed, 19 Oct 2011 01:39:57 +0000 (20:39 -0500)] 
lxc: use hand-rolled code in place of unlockpt and grantpt

The glibc ones (intentionally) cannot handle ptys opened in a
devpts not mounted at /dev/pts.

Drop the (un-exported, unused) virFileOpenTtyAt.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 80710c69fee323870b2a8239d93c5e5dddf28366)

Conflicts:

src/lxc/lxc_controller.c

13 years agoxen: do not use ioemu type for any emulated NIC
Stefan Bader [Fri, 13 Apr 2012 13:14:56 +0000 (15:14 +0200)] 
xen: do not use ioemu type for any emulated NIC

When using the xm/xend stack to manage instances there is a bug
that causes the emulated interfaces to be unusable when the vif
config contains type=ioemu.

The current code already has a special quirk to not use this
keyword if no specific model is given for the emulated NIC
(defaulting to rtl8139).
Essentially it works because regardless of the type argument,i
the Xen stack always creates emulated and paravirt interfaces and
lets the guest decide which one to use. So neither xl nor xm stack
actually require the type keyword for emulated NICs.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
(cherry picked from commit 10c31135f321851f02ad1985684389a42f6f5e54)

13 years agoxend_internal: Use domain/status for shutdown check
Stefan Bader [Thu, 12 Apr 2012 13:42:37 +0000 (15:42 +0200)] 
xend_internal: Use domain/status for shutdown check

On newer xend (v3.x and after) there is no state and domid reported
for inactive domains. When initially creating connections this is
handled in various places by assigning domain->id = -1.
But once an instance has been running, the id is set to the current
domain id. And it does not change when the instance is shut down.
So when querying the domain info, the hypervisor driver, which gets
asked first will indicate it cannot find information, then the
xend driver is asked and will set the status to NOSTATE because it
checks for the -1 domain id.
Checking domain/status for 0 seems to be more reliable for that.

One note: I am not sure whether the domain->id also should get set
back to -1 whenever any sub-driver thinks the instance is no longer
running.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=746007
BugLink: http://bugs.launchpad.net/bugs/929626
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
(cherry picked from commit 26e9ef476239e8cb79f819092c5aac4afdd47d0d)

(crobinso: Add Stefan to AUTHORS. maint only)

13 years agoxen-xm: SIGSEGV in xenXMDomainDefineXML: filename
Philipp Hahn [Mon, 6 Feb 2012 13:13:18 +0000 (14:13 +0100)] 
xen-xm: SIGSEGV in xenXMDomainDefineXML: filename

filename is not initialized to NULL while it's unconditionally freed in
the error path.

Signed-off-by: Philipp Hahn <hahn@univention.de>
(cherry picked from commit 360afebfb36cd7269b8a48db2e00e306bde0e641)

13 years agoxen_xm: Fix SIGSEGV in xenXMDomainDefineXML
Philipp Hahn [Mon, 6 Feb 2012 11:50:47 +0000 (12:50 +0100)] 
xen_xm: Fix SIGSEGV in xenXMDomainDefineXML

On CentOS5 with xen-3.0.3:

 Program received signal SIGSEGV, Segmentation fault.
 virFree (ptrptr=0x8) at util/memory.c:310
 310         free(*(void**)ptrptr);
 (gdb) bt
 #0  virFree (ptrptr=0x8) at util/memory.c:310
 #1  0x00002aaaaae167c8 in xenXMDomainDefineXML (conn=0x694e80, xml=0x6b2ce0 "P\fk") at xen/xm_internal.c:1199
 #2  0x00002aaaaae070d7 in xenUnifiedDomainDefineXML (conn=0x8,
     xml=0x6ac040 "<domain type='xen'>\n  <name>pv</name>\n  <uuid>20291bc0-453a-4d6c-c6ac-4e5af63b932c</uuid>\n  <memory>1048576</memory>\n  <currentMemory>1048576</currentMemory>\n  <vcpu>1</vcpu>\n  <os>\n    <type arch='x8"...) at xen/xen_driver.c:1524
 #3  0x00002aaaaada7803 in virDomainDefineXML (conn=0x694e80,
     xml=0x6ac040 "<domain type='xen'>\n  <name>pv</name>\n  <uuid>20291bc0-453a-4d6c-c6ac-4e5af63b932c</uuid>\n  <memory>1048576</memory>\n  <currentMemory>1048576</currentMemory>\n  <vcpu>1</vcpu>\n  <os>\n    <type arch='x8"...) at libvirt.c:7823
 #4  0x0000000000426173 in cmdEdit (ctl=0x7fffffffb8e0, cmd=<value optimized out>) at virsh.c:14882
 #5  0x000000000041c9ce in vshCommandRun (ctl=0x7fffffffb8e0, cmd=0x658c50) at virsh.c:17712
 #6  0x000000000042c3b9 in main (argc=1, argv=<value optimized out>) at virsh.c:19317

Signed-off-by: Philipp Hahn <hahn@univention.de>
(cherry picked from commit 046b0a6972a9adaeb7227c75fbbdfe5cf0dad62f)

13 years agoxen: Don't add <console> to xml for dom0
Cole Robinson [Sun, 29 Jan 2012 19:10:00 +0000 (14:10 -0500)] 
xen: Don't add <console> to xml for dom0

It just doesn't really make sense and confuses virt-manager
(cherry picked from commit efb0839c1d5471ab70ad81a36372c5cb6e5ed9a6)

Conflicts:

src/xenxs/xen_sxpr.c

13 years agoxen_xs: Guard against set but empty kernel argument
Guido Günther [Mon, 10 Oct 2011 16:22:44 +0000 (18:22 +0200)] 
xen_xs: Guard against set but empty kernel argument

On xen 4.1 I observed configurations that look like:

(image
    (hvm
        (kernel '')
        (loader '/foo/bar')
))

The kernel element is there but unset. This leads to an empty <kernel/>
element in the XML and even worse makes us skip the boot order parsing
and therefore not emit a <boot device='$dev>'/> element which breaks CD
booting.
(cherry picked from commit dca1a6b46fecca57eac8914f30ad5a41a9f038fe)

13 years agoxen: add error handling to UUID parsing
Guido Günther [Thu, 6 Oct 2011 10:42:39 +0000 (12:42 +0200)] 
xen: add error handling to UUID parsing

otherwise a missing UUID in a domain config just shows:

error: An error occurred, but the cause is unknown

Now we have:

error: configuration file syntax error: config value uuid was missing
(cherry picked from commit c5d2984c4270d257a5c01c236ca086162fd2849d)

13 years agoxenParseXM: don't dereference NULL pointer when script is empty
Guido Günther [Thu, 6 Oct 2011 10:56:52 +0000 (12:56 +0200)] 
xenParseXM: don't dereference NULL pointer when script is empty
(cherry picked from commit 6dd8532d96b0512ddb3b10cae8f51e16389d9cc7)

13 years agoFix sync issue in virNetClientStreamEventRemoveCallback
Radu Caragea [Mon, 4 Jun 2012 07:32:37 +0000 (09:32 +0200)] 
Fix sync issue in virNetClientStreamEventRemoveCallback

The stream lock is unlocked twice instead of being locked and then
unlocked. Probably a typo.
(cherry picked from commit 107f51b69c44b9902ed76ab0e33e89dde5d21cb1)

Conflicts:

AUTHORS

13 years agofdstream: Add internal callback on stream close
Peter Krempa [Thu, 23 Feb 2012 12:45:25 +0000 (13:45 +0100)] 
fdstream: Add internal callback on stream close

This patch adds another callback to a FDstream object. The original
callback is used by the daemon stream driver to handle events.

This callback is called if and only if the stream is about to be closed.
This might be used to handle cleanup steps after a fdstream exits. This
will be used later on in ensuring mutually exclusive access to consoles.

* src/fdstream.c:
        - emit the callback, when stream is being closed
        - add data structures needed to handle the callback
        - add function to register callback
* src/fdstream.h:
        - define function prototypes for the callback
(cherry picked from commit 0c4bfdda42f176633a9db7c52703802e3f0123fe)

13 years agofdstream: Emit stream abort callback even if poll() doesnt.
Peter Krempa [Thu, 23 Feb 2012 11:54:18 +0000 (12:54 +0100)] 
fdstream: Emit stream abort callback even if poll() doesnt.

This patch causes the fdstream driver to call the stream event callback
if virStreamAbort() is called on a stream using this driver.

A remote handler for a stream can only detect changes via stream events,
so this event callback is necessary in order to enable a daemon to abort
a stream in such a way that the client will see the change.

* src/fdstream.c:
        - modify close function to call stream event callback
(cherry picked from commit 95fdc1bc2b397909b9cefacf9ff91924897f5af4)

13 years agoDon't return a fatal error if receiving unexpected stream data
Daniel P. Berrange [Wed, 9 Nov 2011 13:54:01 +0000 (13:54 +0000)] 
Don't return a fatal error if receiving unexpected stream data

Due to the asynchronous nature of streams, we might continue to
receive some stream packets from the server even after we have
shutdown the stream on the client side. These should be discarded
silently, rather than raising an error in the RPC layer.

* src/rpc/virnetclient.c: Discard stream data silently
(cherry picked from commit a38710bd652c1a4a79df7d4ef171d20ff322e566)

13 years agoFix handling of stream EOF
Daniel P. Berrange [Fri, 7 Oct 2011 16:38:59 +0000 (17:38 +0100)] 
Fix handling of stream EOF

Very occasionally the sequence of events from poll would result
in getting a HANGUP on its own, instead of a HANGUP+READABLE
at the same time. In the former case we would send back an error
event to the client, but never send the empty packet to indicate
EOF.
(cherry picked from commit 1d46b2e900498a3f389fcbb89fc7b27d22f36d4a)

13 years agoIf receiving a stream error, mark EOF on the stream
Daniel P. Berrange [Fri, 7 Oct 2011 10:35:31 +0000 (11:35 +0100)] 
If receiving a stream error, mark EOF on the stream

If we receive an error on the stream, set the EOF marker so
that any further (bogus) incoming data is dropped.

* src/rpc/virnetclientstream.c: Set EOF on stream
(cherry picked from commit bc61aa1211666d5b0c2930a69b6b9db17288f003)

13 years agoSet to NULL members that have been freed to prevent crashes
Marc-André Lureau [Sat, 1 Oct 2011 01:39:14 +0000 (03:39 +0200)] 
Set to NULL members that have been freed to prevent crashes

Do not crash if virStreamFinish is called after error.

==11000== Invalid read of size 4
==11000==    at 0x373A8099A0: pthread_mutex_lock (pthread_mutex_lock.c:51)
==11000==    by 0x4C7CADE: virMutexLock (threads-pthread.c:85)
==11000==    by 0x4D57C31: virNetClientStreamRaiseError (virnetclientstream.c:203)
==11000==    by 0x4D385E4: remoteStreamFinish (remote_driver.c:3541)
==11000==    by 0x4D182F9: virStreamFinish (libvirt.c:14157)
==11000==    by 0x40FDC4: cmdScreenshot (virsh.c:3075)
==11000==    by 0x42BA40: vshCommandRun (virsh.c:14922)
==11000==    by 0x42ECCA: main (virsh.c:16381)
==11000==  Address 0x59b86c0 is 16 bytes inside a block of size 216 free'd
==11000==    at 0x4A06928: free (vg_replace_malloc.c:427)
==11000==    by 0x4C69E2B: virFree (memory.c:310)
==11000==    by 0x4D57B56: virNetClientStreamFree (virnetclientstream.c:184)
==11000==    by 0x4D3DB7A: remoteDomainScreenshot (remote_client_bodies.h:1812)
==11000==    by 0x4CFD245: virDomainScreenshot (libvirt.c:2903)
==11000==    by 0x40FB73: cmdScreenshot (virsh.c:3029)
==11000==    by 0x42BA40: vshCommandRun (virsh.c:14922)
==11000==    by 0x42ECCA: main (virsh.c:16381)
(cherry picked from commit be5ec76630c4af83404e8fbf2b5a6b7cb46656e7)

13 years agoFix synchronous reading of stream data
Daniel P. Berrange [Wed, 21 Sep 2011 13:51:33 +0000 (14:51 +0100)] 
Fix synchronous reading of stream data

commit 984840a2c292402926ad100aeea33f8859ff31a9 removed the
notification of waiting calls when VIR_NET_CONTINUE messages
arrive. This was to fix the case of a virStreamAbort() call
being prematurely notified of completion.

The problem is that sometimes there are dummy calls from a
virStreamRecv() call waiting that *do* need to be notified.

These dummy calls should have a status VIR_NET_CONTINUE. So
re-add the notification upon VIR_NET_CONTINUE, but only if
the waiter also has a status of VIR_NET_CONTINUE.

* src/rpc/virnetclient.c: Notify waiting call if stream data
  arrives
* src/rpc/virnetclientstream.c:  Mark dummy stream read packet
  with status VIR_NET_CONTINUE
(cherry picked from commit cb61009236a96f16fa7eabc92f5d6ed5f6313163)

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.
(cherry picked from commit c0057d9a49f6aead9a893c33069d2a11c03bc1e8)

13 years agoInstall API XML desc to a standard location
Daniel P. Berrange [Mon, 13 Feb 2012 16:46:29 +0000 (16:46 +0000)] 
Install API XML desc to a standard location

Language bindings may well want to use the libvirt-api.xml and
libvirt-qemu-api.xml files to either auto-generate themselves,
or sanity check the manually written bindings for completeness.
Currently these XML files are not installed as standard, merely
ending up as a %doc file in the RPM.

This changes them to be installed into $prefix/share/libvirt/apis/
The *-refs.xml files are not installed, since those are only
useful during generation of the online API doc files.

The pkg-config file is enhanced so that you can query the install
location of the API files. eg

  # pkg-config --variable=libvirt_qemu_api libvirt
  /home/berrange/builder/i686-pc-mingw32/sys-root/mingw/share/libvirt/libvirt-qemu-api.xml

* docs/Makefile.am: Install libvirt-api.xml & libvirt-qemu-api.xml
* libvirt.pc.in: Add vars for querying API install location
* libvirt.spec.in, mingw32-libvirt.spec.in: Include API XML files
(cherry picked from commit c95c90ee4a2e6e3e62b32909e2bd57972a73b4ab)

13 years agotests: work around pdwtags 1.9 failure
Eric Blake [Fri, 6 Jan 2012 23:07:34 +0000 (16:07 -0700)] 
tests: work around pdwtags 1.9 failure

On rawhide, gcc is new enough to output new DWARF information that
pdwtags has not yet learned, but the resulting 'make check' output
was rather confusing:

$ make -C src check
...
  GEN    virkeepaliveprotocol-structs
die__process_function: DW_TAG_INVALID (0x4109) @ <0x58c> not handled!
WARNING: your pdwtags program is too old
WARNING: skipping the virkeepaliveprotocol-structs test
WARNING: install dwarves-1.3 or newer
...
$ pdwtags --version
v1.9

I've filed the pdwtags deficiency as
https://bugzilla.redhat.com/show_bug.cgi?id=772358

* src/Makefile.am (PDWTAGS): Don't leave -t file behind on version
mismatch.  Soften warning message, since 1.9 is newer than 1.3.
Don't leak stderr from broken version.
(cherry picked from commit cf6d36257b9164ec7a4bcd31a3c56b6163169e02)

13 years agoxenapi: remove unused variable
Eric Blake [Fri, 11 Nov 2011 18:10:18 +0000 (11:10 -0700)] 
xenapi: remove unused variable

  CC     libvirt_driver_xenapi_la-xenapi_driver.lo
xenapi/xenapi_driver.c: In function 'xenapiDomainGetVcpus':
xenapi/xenapi_driver.c:1209:21: error: variable 'cpus' set but not used [-Werror=unused-but-set-variable]

* src/xenapi/xenapi_driver.c (xenapiDomainGetVcpus): Silence
compiler warning.
(cherry picked from commit 787b0a22389815190dd0a437c0ab6f3f995227b1)

13 years agobuild: fix 'make distcheck'
Eric Blake [Tue, 11 Oct 2011 21:10:17 +0000 (15:10 -0600)] 
build: fix 'make distcheck'

I got these distcheck failures with sanlock enabled:

ERROR: files left in build directory after distclean:
./tools/virt-sanlock-cleanup
./src/locking/qemu-sanlock.conf

* src/Makefile.am (DISTCLEANFILES) [HAVE_SANLOCK]: Clean built
file.
* tools/Makefile.am (DISTCLEANFILES): Likewise.
(cherry picked from commit c654ba889314c5ab50840584e55e3dfc3eac5860)
plus tweak to DISTCLEANFILES from commit ddf3bd32ce12, although that
full commit is too invasive to backport

13 years agobuild: fix 'make distcheck' with pdwtags installed
Eric Blake [Tue, 4 Oct 2011 16:24:40 +0000 (10:24 -0600)] 
build: fix 'make distcheck' with pdwtags installed

I am getting this failure with 'make distcheck':

  GEN    ../../src/remote_protocol-structs
/bin/sh: ../../src/remote_protocol-structs-t: Permission denied
make[4]: *** [../../src/remote_protocol-structs] Error 1

since it attempts a sub-run of a VPATH 'make check' where $(srcdir)
is intentionally read-only.  I'm not sure which commit introduced
the problem, although I suspect it was around 62dee6f when I
refactored protocol struct checking to be more powerful.

$(@F) is required by POSIX, and although it is not yet portable
to all make implementations, we already require GNU make.

* src/Makefile.am (PDWTAGS): Generate temp file into current
directory, since $(srcdir) is read-only during distcheck.
(cherry picked from commit 2d45ae5a013a0353688d92c3e93b7e53a2939a96)

13 years agopython: Fix doc directory name for stable releases
Cole Robinson [Fri, 27 Apr 2012 16:06:34 +0000 (12:06 -0400)] 
python: Fix doc directory name for stable releases

We were using the libvirt release version (like 0.9.11) and not
the configure version (which for stable releases is 0.9.11.X)

Most other places got this right so hopefully that's all the fallout
from the version format change :)

Signed-off-by: Cole Robinson <crobinso@redhat.com>
(cherry picked from commit 002b18b3fb8dc3c088d389344992959dfedeac9e)

13 years agodocs: Serialize running apibuild.py
Cole Robinson [Fri, 27 Apr 2012 16:05:12 +0000 (12:05 -0400)] 
docs: Serialize running apibuild.py

Use a witness file approach like we do for python/generator.py,
as suggested by Eric. Fixes the build issue reported here:

https://www.redhat.com/archives/libvir-list/2012-April/msg01435.html

Signed-off-by: Cole Robinson <crobinso@redhat.com>
(cherry picked from commit c964b6aac1c9d2fe02a814cbb1fddb8899656f50)

Conflicts:

.gitignore - context with other commits not backported

13 years agoconfigure: Use ustar format for dist tarball
Cole Robinson [Fri, 27 Apr 2012 16:03:44 +0000 (12:03 -0400)] 
configure: Use ustar format for dist tarball

Since for stable releases, some test files were over the 99 char
limit for traditional tar filenames.

Suggested by Osier here:
https://www.redhat.com/archives/libvir-list/2012-April/msg01435.html

Signed-off-by: Cole Robinson <crobinso@redhat.com>
(cherry picked from commit ddd6bef4dce89aa1ca52b208ba9c5cc4c22a551c)

13 years agoFix parallel build in docs/ directory
Daniel P. Berrange [Wed, 4 Apr 2012 11:26:04 +0000 (12:26 +0100)] 
Fix parallel build in docs/ directory

Every now & then, with parallel builds, we get a failure to
validate hvsupport.html.in.  I eventually noticed that this
is because we get 2 instances of the generator running at
once.

We already list hvsupport.html.in in BUILT_SOURCES but this
was not working. It turns out the flaw is that we were
adding deps to the 'all:' target instead of the 'all-am:'
target. BUILT_SOURCES is a dep of 'all', so any custom
targets written in Makefile.am must use 'all-am:' so that
they don't get run until BUILT_SOURCES are completely
generated

* docs/Makefile.am: s/all/all-am/
(cherry picked from commit 4f4b496e782dd20d105b89f89e07288772555346)
(cherry picked from commit 26fdec39b43d886948796b88fabc11beb967ef66)

13 years agotests: avoid test failure on rawhide gnutls
Eric Blake [Fri, 6 Jan 2012 21:07:23 +0000 (14:07 -0700)] 
tests: avoid test failure on rawhide gnutls

I hit a VERY weird testsuite failure on rawhide, which included
_binary_ output to stderr, followed by a hang waiting for me
to type something! (Here, using ^@ for NUL):

$ ./commandtest
TEST: commandtest
      WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
.WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
.WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
.8^@^@^@8^@^@^@^A^@^@^@^Bay^A^@^@^@)PRIVATE-GNOME-KEYRING-PKCS11-PROTOCOL-V-1

I finally traced it to the fact that gnome-keyring, called via
gnutls_global_init which is turn called by virNetTLSInit, opens
an internal fd that it expects to communicate to via a
pthread_atfork handler (never mind that it violates POSIX by
using non-async-signal-safe functions in that handler:
https://bugzilla.redhat.com/show_bug.cgi?id=772320).

Our problem stems from the fact that we pulled the rug out from
under the library's expectations by closing an fd that it had
just opened.  While we aren't responsible for fixing the bugs
in that pthread_atfork handler, we can at least avoid the bugs
by not closing the fd in the first place.

* tests/commandtest.c (mymain): Avoid closing fds that were opened
by virInitialize.
(cherry picked from commit 74ff57506c762f7c1f2bdbcce55f6d620687caab)

13 years agostorage: Fix any VolLookupByPath if we have an empty logical pool
Cole Robinson [Wed, 25 Jan 2012 17:07:14 +0000 (12:07 -0500)] 
storage: Fix any VolLookupByPath if we have an empty logical pool

On F16 at least, empty volume groups don't have a directory under /dev.
The directory only appears once a logical volume is created.

This tickles some behavior in BackendStablePath which ends with
libvirt sleeping for 5 seconds while waiting for the directory to appear.
This causes all sorts of problems for the virStorageVolLookupByPath API
which virtinst uses, even if trying to resolve a path that is independent
of the logical pool.

In reality we don't even need to do that checking since logical pools
always have a stable target path. Short circuit the polling in that
case.

Fixes bug 782261
(cherry picked from commit 275155f664614fd32bcf5e963488e6f97b66dae4)

13 years agodaemon: Remove deprecated HAL from init script dependencies
Peter Krempa [Fri, 2 Mar 2012 14:12:32 +0000 (15:12 +0100)] 
daemon: Remove deprecated HAL from init script dependencies

The init script for the daemon requests to start HAL although it has
been deprecated long time ago. This patch removes the dependency.
(cherry picked from commit 2dcca3ec0a28c6562ebfbe7a5eae4729fb5de904)

13 years agovirCommand: Properly handle POLLHUP
Michal Privoznik [Tue, 3 Jan 2012 17:40:55 +0000 (18:40 +0100)] 
virCommand: Properly handle POLLHUP

It is a good practise to set revents to zero before doing any poll().
Moreover, we should check if event we waited for really occurred or
if any of fds we were polling on didn't encountered hangup.
(cherry picked from commit 06b9c5b9231ef4dbd4b5ff69564305cd4f814879)

13 years agoqemu: Check for domain being active on successful job acquire
Michal Privoznik [Tue, 11 Oct 2011 08:40:36 +0000 (10:40 +0200)] 
qemu: Check for domain being active on successful job acquire

As this is needed. Although some functions check for domain
being active before obtaining job, we need to check it after,
because obtaining job unlocks domain object, during which
a state of domain can be changed.
(cherry picked from commit 9bc9999b6eb815268798120d7fe8834d822f098d)

13 years agoAvoid crash in shunloadtest
Daniel P. Berrange [Thu, 1 Dec 2011 16:33:50 +0000 (11:33 -0500)] 
Avoid crash in shunloadtest

For unknown reasons, the shunloadtest will crash on Fedora 16
inside dlopen()

 (gdb) bt
 #0  0x00000000000050e6 in ?? ()
 #1  0x00007ff61a77b9d5 in floor () from /lib64/libm.so.6
 #2  0x00007ff61e522963 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
 #3  0x00007ff61e5297e6 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
 #4  0x00007ff61e525006 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
 #5  0x00007ff61e52917a in _dl_open () from /lib64/ld-linux-x86-64.so.2
 #6  0x00007ff61e0f6f26 in dlopen_doit () from /lib64/libdl.so.2
 #7  0x00007ff61e525006 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
 #8  0x00007ff61e0f752f in _dlerror_run () from /lib64/libdl.so.2
 #9  0x00007ff61e0f6fc1 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
 #10 0x0000000000400a15 in main (argc=<optimized out>, argv=<optimized out>) at shunloadtest.c:105

Changing from RTLD_NOW to RTLD_LAZY avoids this problem,
but quite possibly does not fix the root cause.

* shunloadtest.c: s/NOW/LAZY/
(cherry picked from commit 24d9792821af4c6b304e5b0ee83f7b233cfa314e)

13 years agospec: make it easier to autoreconf when building rpm
Eric Blake [Mon, 5 Dec 2011 17:22:10 +0000 (10:22 -0700)] 
spec: make it easier to autoreconf when building rpm

Over time, Fedora and RHEL RPMs have often backported upstream
patches that touched configure.ac and/or Makefile.am; this
necessitates rerunning the autotools for the patch to be effective.
Making this a one-liner spec tweak will make it easier for future
backports to pull patches without having to find all the places
to touch to properly use the autotools.  Meanwhile, there have been
historical instances where an update in the autotools caused FTBFS
situations, so this is not on by default.

* libvirt.spec.in (enable_autotools): New variable, default off.
(BuildRequires): Conditionally add autotools.
(%build): Conditionally use them before configure.
* mingw32-libvirt.spec.in: Likewise.
(cherry picked from commit 9c417636c4045735712c066595ff31539ac88bff)

Conflicts:

mingw32-libvirt.spec.in - caused by change in context

13 years agotest: replace deprecated "fedora-13" machine with "pc-0.13"
Laine Stump [Fri, 9 Dec 2011 20:55:14 +0000 (15:55 -0500)] 
test: replace deprecated "fedora-13" machine with "pc-0.13"

One of the xml tests in the test suite was created using a
now-deprecated qemu machine type ("fedora-13", which was only ever
valid for Fedora builds of qemu). Although strictly speaking it's not
necessary to replace it with an actual supported qemu machine type
(since the xml in question is never actually sent to qemu), this patch
changes it to the actually-supported "pc-0.13" just for general
tidiness. (Also, on some Fedora builds which contain a special patch
to rid the world of "fedora-13", having it mentioned in the test suite
will cause make check to fail.)
(cherry picked from commit 7204a9fd31b06a6ce8fe5b08483c39a75faa0392)

13 years agonetwork: don't add iptables rules for externally managed networks
Laine Stump [Tue, 6 Dec 2011 20:13:50 +0000 (15:13 -0500)] 
network: don't add iptables rules for externally managed networks

This patch addresses https://bugzilla.redhat.com/show_bug.cgi?id=760442

When a network has any forward type other than route, nat or none, the
network configuration should be done completely external to libvirt -
libvirt only uses these types to allow configuring guests in a manner
that isn't tied to a specific host (all the host-specific information,
in particular interface names, port profile data, and bandwidth
configuration is in the network definition, and the guest
configuration only references it).

Due to a bug in the bridge network driver, libvirt was adding iptables
rules for networks with forward type='bridge' etc. any time libvirtd
was restarted while one of these networks was active.

This patch eliminates that error by only "reloading" iptables rules if
forward type is route, nat, or none.
(cherry picked from commit ae1232b298323dd7bef909426e2ebafa6bca9157)

13 years agospec: fix logic bug in deciding to turn on cgconfig
Eric Blake [Thu, 8 Dec 2011 20:32:37 +0000 (13:32 -0700)] 
spec: fix logic bug in deciding to turn on cgconfig

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

Commit ecd8725 tried to silence a spurious warning on the initial
libvirt install, and commit ba6cbb1 tried to fix up the logic to the
correct Fedora version, but the warning was still present due to a
logic bug: since %{fedora} and %{rhel} are never simulatanously
set, then 0%{rhel} <= 6 made the %if always true.  Checking for
minimum versions (via >=) is okay, but checking for maximum versions
(via <=) requires a prerequisite test that the platform being tested
is non-zero.

Also fix a bogus setting of with_libxl (although we previously
hard-code with_libxl to 0 for rhel earlier in the file, so this
was not as severe a bug).

* libvirt.spec.in (with_cgconfig): Don't enable cgconfig on F16.
(cherry picked from commit 3b95f284f19d2e43daa32a87cd10eaf42ea8bb4e)

13 years agospec: don't use chkconfig --list
Eric Blake [Tue, 6 Dec 2011 23:16:34 +0000 (16:16 -0700)] 
spec: don't use chkconfig --list

https://bugzilla.redhat.com/show_bug.cgi?id=694403 reports that
the specfile is incorrectly checking for a running libvirt-guests
service.  For example,

$ LC_ALL=es_ES chkconfig --list libvirt-guests
libvirt-guests    0:desactivado  1:desactivado    2:desactivado     3:activo  4:activo  5:activo     6:desactivado

will fail to find 5:on, even though it is active.  But chkconfig
already has a mode where you can silently use the exit status to
check for an active service.

* libvirt.spec.in (%post): Use simpler chkconfig options, to avoid
issues with localization.
(cherry picked from commit fea83dde7b7e0725e4353a2cc5b6e5c7c61cb294)

13 years agospec: add dmidecode as prereq
Eric Blake [Mon, 5 Dec 2011 17:32:41 +0000 (10:32 -0700)] 
spec: add dmidecode as prereq

https://bugzilla.redhat.com/show_bug.cgi?id=754909 complains that
because libvirt didn't require dmidecode, that the logs are noisy
and virConnectGetSysinfo needlessly fails.  Even 'virt-what' requires
dmidecode, so it's not that onerous of a dependency.  We may be
able to drop this in the future when we move to parsing sysfs data,
but for now, listing the dependency will help matters.

* libvirt.spec.in (Requires): Sort Requires before BuildRequires.
Add dmidecode.
(cherry picked from commit e7dfa468f9de796430a4cc9594eb256109a517bf)
extra requires for with_systemd removed, since the patch that adds
that hasn't been backported

13 years agoFix incorrect symbols for virtime.h module breaking Mingw32
Daniel P. Berrange [Mon, 5 Dec 2011 14:04:25 +0000 (14:04 +0000)] 
Fix incorrect symbols for virtime.h module breaking Mingw32

The Mingw32 linker highlighted that the symbols for virtime.h
declared in libvirt_private.syms were incorrect

* src/libvirt_private.syms: Fix virtime.h symbols
(cherry picked from commit b265beda55dd13c6e1a578285ae64191caed2694)

13 years agospec: mark directories in /var/run as ghosts
Eric Blake [Wed, 30 Nov 2011 22:34:42 +0000 (15:34 -0700)] 
spec: mark directories in /var/run as ghosts

We have several directories that are created on the fly, and which
only contain state relevant to a running libvirtd process (all
located in /var/run).  Since the directories are created as needed,
and make no sense without a running libvirtd, we want them deleted
if libvirt is uninstalled.  And in F15 and newer, /var/run is on
tmpfs (forcing us to recreate on the fly); which means that someone
trying to verify a complete rpm will fail if the directory does not
currently exist because libvirtd has not been started since boot.
The solution, then, is to mark the directories as %ghost, so that
rpm knows that we own them and will clean it up if libvirt is
uninstalled, but will no longer create the directory for us at
install, nor complain at verify time if the directory does not exist.

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

* libvirt.spec.in (%files): Add %ghost to temporary directories
that we don't install, but want cleaned up on libvirt removal.
(cherry picked from commit 764574f7c73d72e42f69f225b6bbe61fae5ab28b)

13 years agoRemove time APIs from src/util/util.h
Daniel P. Berrange [Tue, 29 Nov 2011 12:33:23 +0000 (12:33 +0000)] 
Remove time APIs from src/util/util.h

The virTimestamp and virTimeMs functions in src/util/util.h
duplicate functionality from virtime.h, in a non-async signal
safe manner. Remove them, and convert all code over to the new
APIs.

* src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
* src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
  src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
  src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
  virtime APIs
(cherry picked from commit a8bb75a3e65f0ae866f3b3fd60c57b2aa2050017)

Conflicts:

src/lxc/lxc_driver.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
 * the patches contained context with extra include files not
   yet introduced on the branch.
src/util/event_poll.c
 * the branch had context with a call to EVENT_DEBUG that
   was no longer existing in the original patch.

13 years agoMake logging async signal safe wrt time stamp generation
Daniel P. Berrange [Tue, 29 Nov 2011 12:32:31 +0000 (12:32 +0000)] 
Make logging async signal safe wrt time stamp generation

Use the new virTimeStringNowRaw() API for generating log timestamps
in an async signal safe manner

* src/util/logging.c: Use virTimeStringNowRaw
(cherry picked from commit 32d3ec7466a554f7a4a3e9d4017a24aa540ecf18)

Conflicts:

src/util/logging.c

13 years agoAdd internal APIs for dealing with time
Daniel P. Berrange [Tue, 29 Nov 2011 12:11:01 +0000 (12:11 +0000)] 
Add internal APIs for dealing with time

The logging APIs need to be able to generate formatted timestamps
using only async signal safe functions. This rules out using
gmtime/localtime/malloc/gettimeday(!) and much more.

Introduce a new internal API which is async signal safe.

  virTimeMillisNowRaw replacement for gettimeofday. Uses clock_gettime
                      where available, otherwise falls back to the unsafe
                      gettimeofday

  virTimeFieldsNowRaw  replacements for gmtime(), convert a timestamp
  virTimeFieldsThenRaw into a broken out set of fields. No localtime()
                       replacement is provided, because converting to
                       local time is not practical with only async signal
                       safe APIs.

  virTimeStringNowRaw  replacements for strftime() which print a timestamp
  virTimeStringThenRaw into a string, using a pre-determined format, with
                       a fixed size buffer (VIR_TIME_STRING_BUFLEN)

For each of these there is also a version without the Raw postfix
which raises a full libvirt error. These versions are not async
signal safe

* src/Makefile.am, src/util/virtime.c, src/util/virtime.h: New files
* src/libvirt_private.syms: New APis
* configure.ac: Check for clock_gettime in -lrt
* tests/virtimetest.c, tests/Makefile.am: Test new APIs
(cherry picked from commit 3ec128989606278635a7c5dfbeee959692d12e15)

Conflicts:

src/Makefile.am

13 years agologging: Add date to log timestamp
Jiri Denemark [Wed, 28 Sep 2011 14:44:50 +0000 (16:44 +0200)] 
logging: Add date to log timestamp
(cherry picked from commit 11c6e094e4e8789174502bd52c1441caa5865276)

13 years agologging: Do not log timestamp through syslog
Jiri Denemark [Wed, 28 Sep 2011 13:20:07 +0000 (15:20 +0200)] 
logging: Do not log timestamp through syslog

Syslog puts the timestamp to every message anyway so this removes
redundant data.
(cherry picked from commit 2a449549c1db0befef8a807bfe967a04af8b529b)

13 years agoqemu: make PCI multifunction support more manual
Laine Stump [Thu, 29 Sep 2011 17:00:32 +0000 (13:00 -0400)] 
qemu: make PCI multifunction support more manual

When support for was added for PCI multifunction cards (in commit
9f8baf, first included in libvirt 0.9.3), it was done by always
turning on the multifunction bit for all PCI devices. Since that time
it has been realized that this is not an ideal solution, and that the
multifunction bit must be selectively turned on. For example, see

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

and the discussion before and after

  https://www.redhat.com/archives/libvir-list/2011-September/msg01036.html

This patch modifies multifunction support so that the multifunction=on
option is only added to the qemu commandline for a device if its PCI
<address> definition has the attribute "multifunction='on'", e.g.:

  <address type='pci' domain='0x0000' bus='0x00'
           slot='0x04' function='0x0' multifunction='on'/>

In practice, the multifunction bit should only be turned on if
function='0' AND other functions will be used in the same slot - it
usually isn't needed for functions 1-7 (although there are apparently
some exceptions, e.g. the Intel X53 according to the QEMU source
code), and should never be set if only function 0 will be used in the
slot. The test cases have been changed accordingly to illustrate.

With this patch in place, if a user attempts to assign multiple
functions in a slot without setting the multifunction bit for function
0, libvirt will issue an error when the domain is defined, and the
define operation will fail. In the future, we may decide to detect
this situation and automatically add multifunction=on to avoid the
error; even then it will still be useful to have a manual method of
turning on multifunction since, as stated above, there are some
devices that excpect it to be turned on for all functions in a slot.

A side effect of this patch is that attempts to use the same PCI
address for two different devices will now log an error (previously
this would cause the domain define operation to fail, but there would
be no log message generated). Because the function doing this log was
almost completely rewritten, I didn't think it worthwhile to make a
separate patch for that fix (the entire patch would immediately be
obsoleted).
(cherry picked from commit c329db7180d77c8077b9f9cd167a71d7f347227a)

13 years agoconf: remove unused VIR_ENUM_DECL
Laine Stump [Wed, 28 Sep 2011 18:19:59 +0000 (14:19 -0400)] 
conf: remove unused VIR_ENUM_DECL

While adding a new enum, I noticed a VIR_ENUM_DECL for a type that
doesn't exist. There is also of course no matching VIR_ENUM_IMPL for
it.
(cherry picked from commit be7bc4d5ccb502c2da85d3b3db804fd53b70449e)

13 years agospec: F15 still uses cgconfig, RHEL lacks hyperv
Eric Blake [Mon, 26 Sep 2011 20:28:47 +0000 (14:28 -0600)] 
spec: F15 still uses cgconfig, RHEL lacks hyperv

Commit ecd8725c dropped attempts to probe the cgconfig service on
new enough Fedora where systemd took over that aspect of the system,
but mistakenly used F14 instead of F15 as the cutoff point.

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

Also, RHEL does not include HyperV support yet.

* libvirt.spec.in (with_cgconfig): Check cgconfig service in F15.
(%{?rhel}): Provide default for with_hyperv.
(cherry picked from commit ba6cbb182b49ca1f94a40285f40f342f84c0bd2a)

13 years agoRelease of libvirt-0.9.6 v0.9.6
Daniel Veillard [Thu, 22 Sep 2011 06:53:23 +0000 (14:53 +0800)] 
Release of libvirt-0.9.6

13 years agosnapshot: also delete empty directory
Eric Blake [Wed, 21 Sep 2011 22:08:42 +0000 (16:08 -0600)] 
snapshot: also delete empty directory

The previous patch removed all snapshots, but not the directory
where the snapshots lived, which is still a form of stale data.

* src/qemu/qemu_domain.c (qemuDomainRemoveInactive): Wipe any
snapshot directory.

13 years agosnapshot: remove snapshot metadata on transient exit
Eric Blake [Thu, 22 Sep 2011 06:02:03 +0000 (14:02 +0800)] 
snapshot: remove snapshot metadata on transient exit

Commit 282fe1f0 documented that transient domains will auto-delete
any snapshot metadata when the last reference to the domain is
removed, and that management apps are in charge of grabbing any
snapshot metadata prior to that point.  However, this was not
actually implemented for qemu until now.

* src/qemu/qemu_driver.c (qemudDomainCreate)
(qemuDomainDestroyFlags, qemuDomainSaveInternal)
(qemudDomainCoreDump, qemuDomainRestoreFlags, qemudDomainDefine)
(qemuDomainUndefineFlags, qemuDomainMigrateConfirm3)
(qemuDomainRevertToSnapshot): Clean up snapshot metadata.
* src/qemu/qemu_migration.c (qemuMigrationPrepareAny)
(qemuMigrationPerformJob, qemuMigrationPerformPhase)
(qemuMigrationFinish): Likewise.
* src/qemu/qemu_process.c (qemuProcessHandleMonitorEOF)
(qemuProcessReconnect, qemuProcessReconnectHelper)
(qemuProcessAutoDestroyDom): Likewise.

13 years agosnapshot: prepare to remove transient snapshot metadata
Eric Blake [Wed, 21 Sep 2011 19:08:51 +0000 (13:08 -0600)] 
snapshot: prepare to remove transient snapshot metadata

This patch is mostly code motion - moving some functions out
of qemu_driver and into qemu_domain so they can be reused by
multiple qemu_* files (since qemu_driver.h must not grow).
It also adds a new helper function, qemuDomainRemoveInactive,
which will be used in the next patch.

* src/qemu/qemu_domain.h (qemuFindQemuImgBinary)
(qemuDomainSnapshotWriteMetadata, qemuDomainSnapshotForEachQcow2)
(qemuDomainSnapshotDiscard, qemuDomainSnapshotDiscardAll)
(qemuDomainRemoveInactive): New prototypes.
(struct qemu_snap_remove): New struct.
* src/qemu/qemu_domain.c (qemuDomainRemoveInactive)
(qemuDomainSnapshotDiscardAllMetadata): New functions.
(qemuFindQemuImgBinary, qemuDomainSnapshotWriteMetadata)
(qemuDomainSnapshotForEachQcow2, qemuDomainSnapshotDiscard)
(qemuDomainSnapshotDiscardAll): Move here...
* src/qemu/qemu_driver.c (qemuFindQemuImgBinary)
(qemuDomainSnapshotWriteMetadata, qemuDomainSnapshotForEachQcow2)
(qemuDomainSnapshotDiscard, qemuDomainSnapshotDiscardAll): ...from
here.
(qemuDomainUndefineFlags): Update caller.
* src/conf/domain_conf.c (virDomainRemoveInactive): Doc fixes.

13 years agosnapshot: fix logic bug in qemu undefine
Eric Blake [Wed, 21 Sep 2011 19:08:50 +0000 (13:08 -0600)] 
snapshot: fix logic bug in qemu undefine

Commit 19f8c98 introduced VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA,
with the intent that omitting the flag makes undefine fail, and
including the flag deletes metadata.  But it used the wrong logic.
Also, hoist the transient domain sooner, so that we don't
accidentally remove metadata of a transient domain.

* src/qemu/qemu_driver.c (qemuDomainUndefineFlags): Check correct
flag value.

13 years agosanlock: fix memory leak
Eric Blake [Wed, 21 Sep 2011 20:22:57 +0000 (14:22 -0600)] 
sanlock: fix memory leak

Detected by Coverity.  The only way to get to error_unlink is if
path was successfully assigned, so the if was useless.  Meanwhile,
there was a return statement that did not free path.

* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace): Fix mem-leak, and drop
useless if.

13 years agovirsh: fix regression in argv parsing
Eric Blake [Wed, 21 Sep 2011 14:54:47 +0000 (08:54 -0600)] 
virsh: fix regression in argv parsing

Prior to commit 85d2810, we had an issue where:

snapshot-create-as dom name --diskspec spec --diskspec spec

failed to parse the second spec, because the first spec had marked
that option as no longer requiring an argument.

In commit 85d2810, I fixed it by making argv options no longer mark
the option as seen.  But this in turn breaks mandatory argv options,
which now complain that the argv option is missing.

This patch reverts that part of 85d2810, and instead replaces it with
fixes to no longer clear opts_need_arg of an argv argument.

* tools/virsh.c (vshCmddefGetOption, vshCmddefGetData)
(vshCommandParse): Fix option parsing for required argv option.
(vshCmddefOptParse): Check that argv option is last.
* tests/virsh-optparse: Enhance test.

13 years agovirsh: More friendly err if no pool is specified for looking up a vol
Osier Yang [Wed, 21 Sep 2011 06:29:49 +0000 (14:29 +0800)] 
virsh: More friendly err if no pool is specified for looking up a vol

There are 3 ways to lookup a volume, only virStorageVolLookupByName
needs pool object. So if no --pool is specified, it will tries to
get the volume via virStorageVolLookupByPath/virStorageVolLookupByKey.

But if all 3 ways fails, and no --pool is specified, a friendly
error might help the user get right way quickly.

13 years agostorage: Wait udev events are handled before removing lvm vol
Osier Yang [Wed, 21 Sep 2011 06:02:30 +0000 (14:02 +0800)] 
storage: Wait udev events are handled before removing lvm vol

Related #BZ: https://bugzilla.redhat.com/show_bug.cgi?id=702260.

There are two problems described in the BZ:
1) "Can't remove open logical volume".
2) "Unable to deactivate logical volume "foo""

This patch just intends to fix 2), as 1) is expected if the vol
is still used by something, and you never known if "lvchange -an"
will fail or not either (sometime, it will succeed, sometimes not).
We'd better not look for trouble, :-)

For 2), that's caused by race between lvremove and udev event handling,
the only workable way now is to wait the events handling are finished,
though it might introduce latencies, as "udevadmin settle" exits
after *all* events are handled, it's the only way we can fix
the racing in libvirt layer.

See https://bugzilla.redhat.com/show_bug.cgi?id=570359 for more
details.

13 years agoqemu: avoid dereferencing a NULL pointer
Alex Jia [Wed, 21 Sep 2011 19:02:44 +0000 (03:02 +0800)] 
qemu: avoid dereferencing a NULL pointer

* src/qemu/qemu_process.c: Taking if (qemuDomainObjEndJob(driver, obj) == 0)
  true branch then 'obj' is NULL, virDomainObjIsActive(obj) and
  virDomainObjUnref(obj) will dereference NULL pointer.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agotests: improve test failure diagnosis
Oskari Saarenmaa [Wed, 21 Sep 2011 16:29:31 +0000 (19:29 +0300)] 
tests: improve test failure diagnosis

  * qemuhelptest prints test case name on failure.

13 years agoqemu: Avoid loop of fake reboots
Jiri Denemark [Wed, 21 Sep 2011 14:03:22 +0000 (16:03 +0200)] 
qemu: Avoid loop of fake reboots

Once virDomainReboot is called for a domain, guest OS initiated shutdown
would always result in reboot instead of shutdown. Only
virDomainShutdown would actually shutd such domain down. That's because
we forgot to reset fakeReboot flag once we asked the domain to reboot.

13 years agoqemu: Fix shutdown regression with buggy qemu
Jiri Denemark [Wed, 21 Sep 2011 08:25:29 +0000 (10:25 +0200)] 
qemu: Fix shutdown regression with buggy qemu

The commit that prevents disk corruption on domain shutdown
(96fc4784177ecb70357518fa863442455e45ad0e) causes regression with QEMU
0.14.* and 0.15.* because of a regression bug in QEMU that was fixed
only recently in QEMU git. The affected versions of QEMU do not quit on
SIGTERM if started with -no-shutdown, which we use to implement fake
reboot. Since -no-shutdown tells QEMU not to quit automatically on guest
shutdown, domains started using the affected QEMU cannot be shutdown
properly and stay in a paused state.

This patch disables fake reboot feature on such QEMU by not using
-no-shutdown, which makes shutdown work as expected. However,
virDomainReboot will not work in this case and it will report "Requested
operation is not valid: Reboot is not supported with this QEMU binary".

13 years agoAPI: prefer to use NULLSTR macro
Osier Yang [Wed, 21 Sep 2011 09:03:43 +0000 (17:03 +0800)] 
API: prefer to use NULLSTR macro

13 years agoremote: fix crash on OOM
Eric Blake [Tue, 20 Sep 2011 18:11:32 +0000 (12:11 -0600)] 
remote: fix crash on OOM

Bug introduced in commit 675464b.  On an OOM, this would try to
dereference a char* and free the contents as a pointer, which is
doomed to failure.

Adding a syntax check will prevent mistakes like this in the future.

* cfg.mk (sc_prohibit_internal_functions): New syntax check.
(exclude_file_name_regexp--sc_prohibit_internal_functions): Add
exemptions.
* daemon/remote.c (remoteRelayDomainEventIOError)
(remoteRelayDomainEventIOErrorReason)
(remoteRelayDomainEventGraphics, remoteRelayDomainEventBlockJob):
Use correct free function.

13 years agoxen: use typical allocations
Eric Blake [Tue, 20 Sep 2011 18:11:31 +0000 (12:11 -0600)] 
xen: use typical allocations

The next patch will add a syntax check that flags this usage in xen
as awkward - while it was valid memory management, it was very hard
to maintain.  Swapping to a more traditional allocation may be a bit
slower, but easier to understand.

* src/xen/xend_internal.c (xenDaemonListDomainsOld): Use two-level
allocation, rather than abusing allocation function.
(xenDaemonLookupByUUID): Update caller.

13 years agovirsh: Remove useless codes of cmdVolPath
Osier Yang [Tue, 20 Sep 2011 08:33:30 +0000 (16:33 +0800)] 
virsh: Remove useless codes of cmdVolPath

Variable "name" is never used in the codes, it's useless.

13 years agobuild: silence warning on 32-bit build
Eric Blake [Tue, 20 Sep 2011 22:53:58 +0000 (16:53 -0600)] 
build: silence warning on 32-bit build

gcc warns when building libvirt 0.9.5 on a 32-bit machine:

qemu/qemu_migration.c: In function 'qemuMigrationToFile':
qemu/qemu_migration.c:2727:38: error: large integer implicitly truncated to unsigned type [-Woverflow]

* src/qemu/qemu_domain.h (QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX): Cap
to long when building for 32-bit platform.

13 years agoRelease of libvirt-0.9.5 v0.9.5
Daniel Veillard [Tue, 20 Sep 2011 06:17:47 +0000 (14:17 +0800)] 
Release of libvirt-0.9.5

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: fetch updated translations from transifex and rebuilt