]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
11 years agomaint: this branch is now dead v0.9.11-maint
Eric Blake [Wed, 22 Jan 2014 18:57:37 +0000 (11:57 -0700)] 
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 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)
(cherry picked from commit ec5190af86487aca90ecc68df3153a7775f2ff4f)

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 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 agospec: Fix script warning when uninstalling libvirt-client
Cole Robinson [Mon, 17 Dec 2012 23:34:25 +0000 (18:34 -0500)] 
spec: Fix script warning when uninstalling libvirt-client

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

11 years agoDon't install legacy initscripts at same time as systemd ones
Daniel P. Berrange [Fri, 21 Sep 2012 10:24:31 +0000 (11:24 +0100)] 
Don't install legacy initscripts at same time as systemd ones

The Fedora policies don't want us installing the legacy initscripts
in parallel with the systemd ones, so switch to only install the
systemd unit

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

11 years agoMerge commit 'v0.9.11.6' into v0.9.11-maint
Eric Blake [Fri, 4 Oct 2013 12:31:01 +0000 (06:31 -0600)] 
Merge commit 'v0.9.11.6' into v0.9.11-maint

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

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoPrep for release 0.9.11.10 v0.9.11.10
Cole Robinson [Wed, 12 Jun 2013 22:19:35 +0000 (18:19 -0400)] 
Prep for release 0.9.11.10

12 years agostorage: Ensure 'qemu-img resize' size arg is a 512 multiple
Christophe Fergeau [Tue, 14 May 2013 13:48:21 +0000 (15:48 +0200)] 
storage: Ensure 'qemu-img resize' size arg is a 512 multiple

qemu-img resize will fail with "The new size must be a multiple of 512"
if libvirt doesn't round it first.
This fixes rhbz#951495

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
(cherry picked from commit 9a8f39d097448b2b43c4a05d0edc213eacfc9ea6)

12 years agosmartcard: spell ccid-card-emulated qemu property correctly
Eric Blake [Mon, 1 Apr 2013 22:54:31 +0000 (16:54 -0600)] 
smartcard: spell ccid-card-emulated qemu property correctly

Reported by Anthony Messina in
https://bugzilla.redhat.com/show_bug.cgi?id=904692
Present since introduction of smartcard support in commit f5fd9baa

* src/qemu/qemu_command.c (qemuBuildCommandLine): Match qemu spelling.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args:
Fix broken test.
(cherry picked from commit 6f7e4ea359323f9bc413dfb738a5c544d4f9c4f8)

12 years agoRevert "build: work around broken kernel header"
Cole Robinson [Wed, 8 May 2013 23:26:48 +0000 (19:26 -0400)] 
Revert "build: work around broken kernel header"

This reverts commit 71e88fc577b5b88215a43edb4f80c2cb0b3edce0.

Accidental double commit.

12 years agoRevert "build: further fixes for broken if_bridge.h"
Cole Robinson [Wed, 8 May 2013 23:26:30 +0000 (19:26 -0400)] 
Revert "build: further fixes for broken if_bridge.h"

This reverts commit d23e735fb40184a820f0103a0a69d06dc2266cc0.

Accidental double commit.

12 years agobuild: further fixes for broken if_bridge.h
Eric Blake [Mon, 14 Jan 2013 17:47:41 +0000 (10:47 -0700)] 
build: further fixes for broken if_bridge.h

Commit c308a9ae was incomplete; it resolved the configure failure,
but not a later build failure.

* src/util/virnetdevbridge.c: Include pre-req header.
* configure.ac (AC_CHECK_HEADERS): Prefer standard in.h over
non-standard ip6.h.
(cherry picked from commit 1bf661caf4e926efcad6e85151a587cea5fd29f4)
(cherry picked from commit 2c7638fdb4e13987cc2229d547531d2c4383ba24)

Conflicts:
src/util/virnetdevbridge.c

12 years agobuild: work around broken kernel header
Cole Robinson [Tue, 26 Mar 2013 21:53:54 +0000 (17:53 -0400)] 
build: work around broken kernel header

I got this scary warning during ./configure on rawhide:

checking linux/if_bridge.h usability... no
checking linux/if_bridge.h presence... yes
configure: WARNING: linux/if_bridge.h: present but cannot be compiled
configure: WARNING: linux/if_bridge.h:     check for missing prerequisite headers?
configure: WARNING: linux/if_bridge.h: see the Autoconf documentation
configure: WARNING: linux/if_bridge.h:     section "Present But Cannot Be Compiled"
configure: WARNING: linux/if_bridge.h: proceeding with the compiler's result
configure: WARNING:     ## ------------------------------------- ##
configure: WARNING:     ## Report this to libvir-list@redhat.com ##
configure: WARNING:     ## ------------------------------------- ##
checking for linux/if_bridge.h... no

* configure.ac (AC_CHECK_HEADERS): Provide struct in6_addr, since
linux/if_bridge.h uses it without declaring it.
(cherry picked from commit c308a9ae153db619fc0366bad9fd8f6c49cfac58)
(cherry picked from commit 7ae53f15936277dfc777539ce13970293fdb03d0)
(cherry picked from commit 879f28a9f33be343c848e78923e9c4afe40f12ae)

Conflicts:
configure.ac

12 years agobuild: avoid infinite autogen loop
Eric Blake [Mon, 1 Oct 2012 15:10:20 +0000 (09:10 -0600)] 
build: avoid infinite autogen loop

Several people have reported that if the .gnulib submodule is dirty,
then 'make' will go into an infinite loop attempting to rerun bootstrap,
because that never cleans up the dirty submodule.  By default, we
should halt and make the user investigate, but if the user doesn't
know why or care that the submodule is dirty, I also added the ability
to 'make CLEAN_SUBMODULE=1' to get things going again.

Also, while testing this, I noticed that when a submodule update was
needed, 'make' would first run autoreconf, then bootstrap (which
reruns autoreconf); adding a strategic dependency allows for less work.

* .gnulib: Update to latest, for maint.mk improvements.
* cfg.mk (_autogen): Also hook maint.mk, to run before autoreconf.
* autogen.sh (bootstrap): Refuse to run if gnulib is dirty, unless
user requests discarding gnulib changes.
(cherry picked from commit c5f162200c32a078fd68507f26a15f84f7d65e9e)

Conflicts:
.gnulib

12 years agonetlink: Fix build with libnl-3
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.
(cherry picked from commit d9d39e620989d2439b0c48e22acf0c4bc6ef83dc)

12 years agobuild: fix detection of netcf linked with libnl1
Christophe Fergeau [Wed, 19 Sep 2012 15:00:55 +0000 (17:00 +0200)] 
build: fix detection of netcf linked with libnl1

Commit 9298bfbcb introduced code to detect if netcf is linked with
libnl1, and to prefer libnl1 over libnl3 when this is the case.
This behaviour can be disabled by setting LIBNL_CFLAGS to any value,
including the empty string.
However, configure.ac sets LIBNL_CFLAGS to "" before attempting
libnl detection, so the libnl1 detection code is always disabled.
This caused issues on my f17 system where netcf is linked with libnl1
but libvirt got built with libnl3.

This commit removes the setting of the LIBNL_* variables to "" as
this does not appear to be needed. After this change, libnl1 is
used when building libvirt on my f17 system.
(cherry picked from commit f6c295156672fe15b32d2baddb68957bb7bddd8e)

12 years agobuild: force libnl1 if netcf also used libnl1
Eric Blake [Fri, 7 Sep 2012 22:38:52 +0000 (16:38 -0600)] 
build: force libnl1 if netcf also used libnl1

Recent spec file changes ensure that in distro situations, netcf
and libvirt will link against the same libnl in order to avoid
dumping core.  But for every-day development, if you use F17 and
have the libnl3-devel headers available, libvirt was blindly
linking against libnl3 even though F17 netcf still links against
libnl1, making testing a self-built binary on F17 impossible.

By making configure a little bit smarter, we can avoid this
situation - we merely skip the probe of libnl-3 if we can prove
that netcf is still using libnl-1.  I intentionally wrote the
test so that we still favor libnl-3 if netcf is not installed or
if we couldn't use ldd to determine things.

Defaults being what they are, someone will invariably complain
that our smarts were wrong.  Never fear - in that case, just run
./configure LIBNL_CFLAGS=..., where the fact that you set
LIBNL_CFLAGS (even to the empty string) will go back to probing
for libnl-3, regardless of netcf's choice.

* configure.ac (LIBNL): Don't probe libnl3 if netcf doesn't use it.
(cherry picked from commit 9298bfbcb483e2ad4023705c7cf718495bf8cd0c)

12 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>
(cherry picked from commit 60fb8a22ee63481b6574a04304f740f50a133754)

Conflicts:
src/Makefile.am - dbus changes not backported

12 years agoSkip libxl driver on Xen 4.2
Eric Blake [Mon, 6 May 2013 14:18:39 +0000 (08:18 -0600)] 
Skip libxl driver on Xen 4.2

Specific to v0.9.11.  This is the opposite of commit dfa1e1dd,
and done for the purposes of minimal code changes to allow
compilation of libxl on Fedora 17 which still has experimental
libxl 4.1, while still being able to compile the branch (minus
libxl code) on Fedora 18 and later.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoFix compilation of legacy xen driver with Xen 4.2
Jim Fehlig [Wed, 26 Sep 2012 21:20:35 +0000 (15:20 -0600)] 
Fix compilation of legacy xen driver with Xen 4.2

In Xen 4.2, xs.h is deprecated in favor of xenstore.h.  xs.h now
contains

#warning xs.h is deprecated use xenstore.h instead
#include <xenstore.h>

which fails compilation when warnings are treated as errors.

Introduce a configure-time check for xenstore.h and if found,
use it instead of xs.h.
(cherry picked from commit 416eca189b1934cfa8575ab72d142ec77600fcf9)

12 years agoqemu: Set migration FD blocking
Michal Privoznik [Tue, 26 Mar 2013 14:45:16 +0000 (15:45 +0100)] 
qemu: Set migration FD blocking

Since we switched from direct host migration scheme to the one,
where we connect to the destination and then just pass a FD to a
qemu, we have uncovered a qemu bug. Qemu expects migration FD to
block. However, we are passing a nonblocking one which results in
cryptic error messages like:

  qemu: warning: error while loading state section id 2
  load of migration failed

The bug is already known to Qemu folks, but we should workaround
already released Qemus. Patch has been originally proposed by Stefan
Hajnoczi <stefanha@gmail.com>
(cherry picked from commit ceb31795af40f6127a541076b905935ff83e5b11)

12 years agobuild: further fixes for broken if_bridge.h
Eric Blake [Mon, 14 Jan 2013 17:47:41 +0000 (10:47 -0700)] 
build: further fixes for broken if_bridge.h

Commit c308a9ae was incomplete; it resolved the configure failure,
but not a later build failure.

* src/util/virnetdevbridge.c: Include pre-req header.
* configure.ac (AC_CHECK_HEADERS): Prefer standard in.h over
non-standard ip6.h.
(cherry picked from commit 1bf661caf4e926efcad6e85151a587cea5fd29f4)

Conflicts:
src/util/virnetdevbridge.c

12 years agobuild: work around broken kernel header
Cole Robinson [Tue, 26 Mar 2013 21:53:54 +0000 (17:53 -0400)] 
build: work around broken kernel header

I got this scary warning during ./configure on rawhide:

checking linux/if_bridge.h usability... no
checking linux/if_bridge.h presence... yes
configure: WARNING: linux/if_bridge.h: present but cannot be compiled
configure: WARNING: linux/if_bridge.h:     check for missing prerequisite headers?
configure: WARNING: linux/if_bridge.h: see the Autoconf documentation
configure: WARNING: linux/if_bridge.h:     section "Present But Cannot Be Compiled"
configure: WARNING: linux/if_bridge.h: proceeding with the compiler's result
configure: WARNING:     ## ------------------------------------- ##
configure: WARNING:     ## Report this to libvir-list@redhat.com ##
configure: WARNING:     ## ------------------------------------- ##
checking for linux/if_bridge.h... no

* configure.ac (AC_CHECK_HEADERS): Provide struct in6_addr, since
linux/if_bridge.h uses it without declaring it.
(cherry picked from commit c308a9ae153db619fc0366bad9fd8f6c49cfac58)

12 years agoPrep for release 0.9.11.9 v0.9.11.9
Cole Robinson [Mon, 28 Jan 2013 19:17:11 +0000 (14:17 -0500)] 
Prep for release 0.9.11.9

12 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

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)

12 years agoutil: fix botched check for new netlink request filters
Laine Stump [Fri, 21 Dec 2012 20:09:33 +0000 (15:09 -0500)] 
util: fix botched check for new netlink request filters

This is an adjustment to the fix for

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

to account for two bonehead mistakes I made.

commit ac2797cf2af2fd0e64c58a48409a8175d24d6f86 attempted to fix a
problem with netlink in newer kernels requiring an extra attribute
with a filter flag set in order to receive an IFLA_VFINFO_LIST from
netlink. Unfortunately, the #ifdef that protected against compiling it
in on systems without the new flag went a bit too far, assuring that
the new code would *never* be compiled, and even if it had, the code
was incorrect.

The first problem was that, while some IFLA_* enum values are also
their existence at compile time, IFLA_EXT_MASK *isn't* #defined, so
checking to see if it's #defined is not a valid method of determining
whether or not to add the attribute. Fortunately, the flag that is
being set (RTEXT_FILTER_VF) *is* #defined, and it is never present if
IFLA_EXT_MASK isn't, so it's sufficient to just check for that flag.

And to top it off, due to the code not actually compiling when I
thought it did, I didn't realize that I'd been given the wrong arglist
to nla_put() - you can't just send a const value to nla_put, you have
to send it a pointer to memory containing what you want to add to the
message, along with the length of that memory.

This time I've actually sent the patch over to the other machine
that's experiencing the problem, applied it to the branch being used
(0.10.2) and verified that it works properly, i.e. it does fix the
problem it's supposed to fix. :-/
(cherry picked from commit 7c36650699f33e54361720f824efdf164bc6e65d)

12 years agoutil: add missing error log messages when failing to get netlink VFINFO
Laine Stump [Thu, 20 Dec 2012 19:52:41 +0000 (14:52 -0500)] 
util: add missing error log messages when failing to get netlink VFINFO

This patch fixes the lack of error messages when libvirt fails to find
VFINFO in a returned netlinke response message.

https://bugzilla.redhat.com/show_bug.cgi?id=827519#c10 is an example
of the error message that was previously logged when the
IFLA_VFINFO_LIST object was missing from the netlink response. The
reason for this failure is detailed in

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

Even though that root problem has been fixed, the experience of
finding the root cause shows us how important it is to properly log an
error message in these cases. This patch *seems* to replace the entire
function, but really most of the changes are due to moving code that
was previously inside an if() statement out to the top level of the
function (the original if() was reversed and made to log an error and
return).
(cherry picked from commit 846770e5ff959f7819e2c32857598cb88e2e2f0e)

Conflicts:
  src/util/virnetdev.c: virNetDevError was replaced with virReportError
                        post-0.9.11. Also memcpy of mac addr was replaced
                        with a call to virMacAddrSetRaw.

12 years agoutil: fix functions that retrieve SRIOV VF info
Laine Stump [Thu, 20 Dec 2012 18:22:17 +0000 (13:22 -0500)] 
util: fix functions that retrieve SRIOV VF info

This patch resolves:

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

When assigning an SRIOV virtual function to a guest using "intelligent
PCI passthrough" (<interface type='hostdev'>, which sets the MAC
address and vlan tag of the VF before passing its info to qemu),
libvirt first learns the current MAC address and vlan tag by sending
an NLM_F_REQUEST message for the VF's PF (physical function) to the
kernel via a NETLINK_ROUTE socket (see virNetDevLinkDump()); the
response message's IFLA_VFINFO_LIST section is examined to extract the
info for the particular VF being assigned.

This worked fine with kernels up until kernel commit
115c9b81928360d769a76c632bae62d15206a94a (first appearing in upstream
kernel 3.3) which changed the ABI to not return IFLA_VFINFO_LIST in
the response until a newly introduced IFLA_EXT_MASK field was included
in the request, with the (newly introduced, of course) RTEXT_FILTER_VF
flag set.

The justification for this ABI change was that new fields had been
added to the VFINFO, causing NLM_F_REQUEST messages to fail on systems
with large numbers of VFs if the requesting application didn't have a
large enough buffer for all the info. The idea is that most
applications doing an NLM_F_REQUEST don't care about VFINFO anyway, so
eliminating it from the response would lower the requirements on
buffer size. Apparently, the people who pushed this patch made the
mistaken assumption that iproute2 (the "ip" command) was the only
package that used IFLA_VFINFO_LIST, so it wouldn't break anything else
(and they made sure that iproute2 was fixed.

The logic of this "fix" is debatable at best (one could claim that the
proper fix would be for the applications in question to be fixed so
that they properly sized the buffer, which is what libvirt does
(purely by virtue of using libnl), but it is what it is and we have to
deal with it.

In order for <interface type='hostdev'> to work properly on systems
with a kernel 3.3 or later, libvirt needs to add the afore-mentioned
IFLA_EXT_MASK field with RTEXT_FILTER_VF set.

Of course we also need to continue working on systems with older
kernels, so that one bit of code is compiled conditionally. The one
time this could cause problems is if the libvirt binary was built on a
system without IFLA_EXT_MASK which was subsequently updated to a
kernel that *did* have it. That could be solved by manually providing
the values of IFLA_EXT_MASK and RTEXT_FILTER_VF and adding it to the
message anyway, but I'm uncertain what that might actually do on a
system that didn't support the message, so for the time being we'll
just fail in that case (which will very likely never happen anyway).
(cherry picked from commit ac2797cf2af2fd0e64c58a48409a8175d24d6f86)

Conflicts:

 src/util/virnetdev.c: parameters of virNetlinkCommand were changed
                       post 0.9.11.

12 years agonetwork: prevent dnsmasq from listening on localhost
Laine Stump [Thu, 13 Dec 2012 06:46:40 +0000 (01:46 -0500)] 
network: prevent dnsmasq from listening on localhost

This patch resolves the problem reported in:

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

The source of the problem was the fix for CVE 2011-3411:

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

which was originally committed upstream in commit
753ff83a50263d6975f88d6605d4b5ddfcc97560. That commit improperly
removed the "--except-interface lo" from dnsmasq commandlines when
--bind-dynamic was used (based on comments in the latter bug).

It turns out that the problem reported in the CVE could be eliminated
without removing "--except-interface lo", and removing it actually
caused each instance of dnsmasq to listen on localhost on port 53,
which created a new problem:

If another instance of dnsmasq using "bind-interfaces" (instead of
"bind-dynamic") had already been started (or if another instance
started later used "bind-dynamic"), this wouldn't have any immediately
visible ill effects, but if you tried to start another dnsmasq
instance using "bind-interfaces" *after* starting any libvirt
networks, the new dnsmasq would fail to start, because there was
already another process listening on port 53.

This patch changes the network driver to *always* add
"except-interface=lo" to dnsmasq conf files, regardless of whether we use
bind-dynamic or bind-interfaces. This way no libvirt dnsmasq instances
are listening on localhost (and the CVE is still fixed).

The actual code change is miniscule, but must be propogated through all
of the test files as well.

(This is *not* a cherry-pick of the upstream commit that fixes the bug
(commit d66eb7866757dd371560c288dc6201fb9348792a), because subsequent
to the CVE fix, another patch changed the network driver to put
dnsmasq options in a conf file rather than directly on the dnsmasq
commandline preserving the same options), so a cherry-pick is just one
very large conflict.)

12 years agoPrep for release 0.9.11.8 v0.9.11.8
Cole Robinson [Sun, 9 Dec 2012 23:20:39 +0000 (18:20 -0500)] 
Prep for release 0.9.11.8

12 years agoqemu: pass -usb and usb hubs earlier, so USB disks with static address are handled...
Vladislav Bogdanov [Fri, 26 Oct 2012 09:09:22 +0000 (09:09 +0000)] 
qemu: pass -usb and usb hubs earlier, so USB disks with static address are handled properly
(cherry picked from commit 81af5336acf4c765ef1201e7762d003ae0b0011e)

Conflicts:
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-bios.args
tests/qemuxml2argvdata/qemuxml2argv-blkiotune-device.args
tests/qemuxml2argvdata/qemuxml2argv-blkiotune.args
tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive-bootindex.args
tests/qemuxml2argvdata/qemuxml2argv-console-virtio-s390.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-disabled.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.args
tests/qemuxml2argvdata/qemuxml2argv-cputune.args
tests/qemuxml2argvdata/qemuxml2argv-disk-blockio.args
tests/qemuxml2argvdata/qemuxml2argv-disk-copy_on_read.args
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args
tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args
tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
tests/qemuxml2argvdata/qemuxml2argv-disk-ioeventfd.args
tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.args
tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-s390.args
tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.args
tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.args
tests/qemuxml2argvdata/qemuxml2argv-event_idx.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args
tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
tests/qemuxml2argvdata/qemuxml2argv-kvmclock+eoi-disabled.args
tests/qemuxml2argvdata/qemuxml2argv-machine-core-off.args
tests/qemuxml2argvdata/qemuxml2argv-machine-core-on.args
tests/qemuxml2argvdata/qemuxml2argv-memtune.args
tests/qemuxml2argvdata/qemuxml2argv-metadata.args
tests/qemuxml2argvdata/qemuxml2argv-minimal-s390.args
tests/qemuxml2argvdata/qemuxml2argv-minimal.args
tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.args
tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args
tests/qemuxml2argvdata/qemuxml2argv-net-virtio-s390.args
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-cpuset.args
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-memory-vcpu-no-cpuset-and-placement.args
tests/qemuxml2argvdata/qemuxml2argv-numad-auto-vcpu-static-numatune.args
tests/qemuxml2argvdata/qemuxml2argv-numad-static-memory-auto-vcpu.args
tests/qemuxml2argvdata/qemuxml2argv-numad.args
tests/qemuxml2argvdata/qemuxml2argv-reboot-timeout-disabled.args
tests/qemuxml2argvdata/qemuxml2argv-reboot-timeout-enabled.args
tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-baselabel.args
tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.args
tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic.args
tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.args
tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-relabel.args
tests/qemuxml2argvdata/qemuxml2argv-seclabel-static.args
tests/qemuxml2argvdata/qemuxml2argv-smbios.args
tests/qemuxml2argvdata/qemuxml2argv-virtio-lun.args

12 years agoqemu: Do not ignore address for USB disks
Vladislav Bogdanov [Fri, 26 Oct 2012 09:09:21 +0000 (09:09 +0000)] 
qemu: Do not ignore address for USB disks
(cherry picked from commit 8f708761c0d0e4eaf36bcb274d4f49fc3e0c3874)

12 years agoqemu: Fix name comparison in qemuMonitorJSONBlockIoThrottleInfo()
Stefan Hajnoczi [Thu, 1 Nov 2012 17:20:56 +0000 (18:20 +0100)] 
qemu: Fix name comparison in qemuMonitorJSONBlockIoThrottleInfo()

The string comparison logic was inverted and matched the first drive
that does *not* have the name we search for.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 23d47b33a2f8b524c32d556d6d55a7ccb0c5903a)

12 years agoqemu: Keep QEMU host drive prefix in BlkIoTune
Stefan Hajnoczi [Thu, 1 Nov 2012 17:20:55 +0000 (18:20 +0100)] 
qemu: Keep QEMU host drive prefix in BlkIoTune

The QEMU -drive id= begins with libvirt's QEMU host drive prefix
("drive-"), which is stripped off in several places two convert between
host ("-drive") and guest ("-device") device names.

In the case of BlkIoTune it is unnecessary to strip the QEMU host drive
prefix because we operate on "info block"/"query-block" output that uses
host drive names.

Stripping the prefix incorrectly caused string comparisons to fail since
we were comparing the guest device name against the host device name.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 04ee70bfda21bfdb48b55f074aed25fc75bb9226)

12 years agodnsmasq: Fix parsing of the version number
Michal Privoznik [Thu, 6 Dec 2012 12:48:11 +0000 (13:48 +0100)] 
dnsmasq: Fix parsing of the version number

If debugging is enabled, the debug messages are sent to stderr.
Moreover, if a command has catching of stderr set, the messages
gets mixed with stdout output (assuming both outputs are stored
in the same variable). The resulting string then doesn't
necessarily have to start with desired prefix then. This bug
exposes itself when parsing dnsmasq output:

2012-12-06 11:18:11.445+0000: 18491: error :
dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
/usr/sbin/dnsmasq version number in '2012-12-06
11:11:02.232+0000: 18492: debug : virFileClose:72 : Closed fd 22'

We can clearly see that the output of dnsmasq --version doesn't
start with expected "Dnsmasq version " string but a libvirt debug
output.
(cherry picked from commit ff33f807739dc2950e4df8c1d4007ce9f8b290c0)

12 years agodnsmasq: Fix parsing of the version number
Michal Privoznik [Thu, 6 Dec 2012 11:25:50 +0000 (12:25 +0100)] 
dnsmasq: Fix parsing of the version number

If the debugging is enabled, the virCommand subsystem catches debug
messages in the command output as well. In that case, we can't assume
the string corresponding to command's stdout will start with specific
prefix. But the prefix can be moved deeper in the string. This bug
shows itself when parsing dnsmasq output:

2012-12-06 11:18:11.445+0000: 18491: error :
dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
/usr/sbin/dnsmasq version number in '2012-12-06 11:11:02.232+0000:
18492: debug : virFileClose:72 : Closed fd 22'

We can clearly see that the output of dnsmasq --version
doesn't start with expected "Dnsmasq version " string but a libvirt
debug output.
(cherry picked from commit 5114431396fd125b6ebe4d1a20a981111f948ee7)

12 years agoconf: fix virDomainNetGetActualDirect*() and BridgeName()
Laine Stump [Mon, 3 Dec 2012 17:24:46 +0000 (12:24 -0500)] 
conf: fix virDomainNetGetActualDirect*() and BridgeName()

This resolves:

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

These three functions:

  virDomainNetGetActualBridgeName
  virDomainNetGetActualDirectDev
  virDomainNetGetActualDirectMode

return attributes that are in a union whose contents are interpreted
differently depending on the actual->type and so they should only
return non-0 when actual->type is 'bridge' (in the first case) or
'direct' (in the other two cases, but I had neglected to do that, so
...DirectDev() was returning bridge.brname (which happens to share the
same spot in the union with direct.linkdev) if actual->type was
'bridge', and ...BridgeName was returning direct.linkdev when
actual->type was 'direct'.

How does this involve Bug 881480 (which was about the inability to
switch between two networks that both have "<forward mode='bridge'/>
<bridge name='xxx'/>"? Whenever the return value of
virDomainNetGetActualDirectDev() for the new and old network
definitions doesn't match, qemuDomainChangeNet() requires a "complete
reconnect" of the device, which qemu currently doesn't
support. ...DirectDev() *should* have been returning NULL for old and
new, but was instead returning the old and new bridge names, which
differ.

(The other two functions weren't causing any behavioral problems in
virDomainChangeNet(), but their problem and fix was identical, so I
included them in this same patch).

12 years agonetwork: use dnsmasq --bind-dynamic when available
Laine Stump [Thu, 22 Nov 2012 02:21:02 +0000 (21:21 -0500)] 
network: use dnsmasq --bind-dynamic when available

This bug resolves CVE-2012-3411, which is described in the following
bugzilla report:

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

The following report is specifically for libvirt on Fedora:

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

In short, a dnsmasq instance run with the intention of listening for
DHCP/DNS requests only on a libvirt virtual network (which is
constructed using a Linux host bridge) would also answer queries sent
from outside the virtualization host.

This patch takes advantage of a new dnsmasq option "--bind-dynamic",
which will cause the listening socket to be setup such that it will
only receive those requests that actually come in via the bridge
interface. In order for this behavior to actually occur, not only must
"--bind-interfaces" be replaced with "--bind-dynamic", but also all
"--listen-address" options must be replaced with a single
"--interface" option. Fully:

   --bind-interfaces --except-interface lo --listen-address x.x.x.x ...

(with --listen-address possibly repeated) is replaced with:

   --bind-dynamic --interface virbrX

Of course libvirt can't use this new option if the host's dnsmasq
doesn't have it, but we still want libvirt to function (because the
great majority of libvirt installations, which only have mode='nat'
networks using RFC1918 private address ranges (e.g. 192.168.122.0/24),
are immune to this vulnerability from anywhere beyond the local subnet
of the host), so we use the new dnsmasqCaps API to check if dnsmasq
supports the new option and, if not, we use the "old" option style
instead. In order to assure that this permissiveness doesn't lead to a
vulnerable system, we do check for non-private addresses in this case,
and refuse to start the network if both a) we are using the old-style
options, and b) the network has a publicly routable IP
address. Hopefully this will provide the proper balance of not being
disruptive to those not practically affected, and making sure that
those who *are* affected get their dnsmasq upgraded.

(--bind-dynamic was added to dnsmasq in upstream commit
54dd393f3938fc0c19088fbd319b95e37d81a2b0, which was included in
dnsmasq-2.63)

(cherry picked from commit 753ff83a50263d6975f88d6605d4b5ddfcc97560)
Conflicts:
        src/network/bridge_driver.c
        * needed to change virReportError() to the older
          networkReportError()

tests/networkxml2argvdata/nat-network-dns-txt-record.argv
        * this test file has an example of an arg with embedded space,
          which gets sorrounded by '' in newer releases. Other
          items on the same line had been modified.

tests/networkxml2argvdata/routed-network.argv
        * in the newer releases, this test file had an --addn-hosts
          arg that didn't exist on this branch. Again, it was in the
          surrounding context of the changes that had been made on
          master.

12 years agoutil: new virSocketAddrIsPrivate function
Laine Stump [Thu, 22 Nov 2012 02:17:30 +0000 (21:17 -0500)] 
util: new virSocketAddrIsPrivate function

This new function returns true if the given address is in the range of
any "private" or "local" networks as defined in RFC1918 (IPv4) or
RFC3484/RFC4193 (IPv6), otherwise they return false.

These ranges are:

   192.168.0.0/16
   172.16.0.0/16
   10.0.0.0/24
   FC00::/7
   FEC0::/10

(cherry picked from commit bf402e77b6d53a4e569b3aa76aef9c7d589c0cf2)
Conflicts:
    src/util/virsocketaddr.c
    src/util/virsocketaddr.h
     * both of these files had new functions that had been added
       at the same place virSocketAddrIsPrivate was being added,
       so the context on the branch didn't match.

12 years agoutil: capabilities detection for dnsmasq
Laine Stump [Tue, 20 Nov 2012 17:22:15 +0000 (12:22 -0500)] 
util: capabilities detection for dnsmasq

In order to optionally take advantage of new features in dnsmasq when
the host's version of dnsmasq supports them, but still be able to run
on hosts that don't support the new features, we need to be able to
detect the version of dnsmasq running on the host, and possibly
determine from the help output what options are in this dnsmasq.

This patch implements a greatly simplified version of the capabilities
code we already have for qemu. A dnsmasqCaps device can be created and
populated either from running a program on disk, reading a file with
the concatenated output of "dnsmasq --version; dnsmasq --help", or
examining a buffer in memory that contains the concatenated output of
those two commands. Simple functions to retrieve capabilities flags,
the version number, and the path of the binary are also included.

bridge_driver.c creates a single dnsmasqCaps object at driver startup,
and disposes of it at driver shutdown. Any time it must be used, the
dnsmasqCapsRefresh method is called - it checks the mtime of the
binary, and re-runs the checks if the binary has changed.

networkxml2argvtest.c creates 2 "artificial" dnsmasqCaps objects at
startup - one "restricted" (doesn't support --bind-dynamic) and one
"full" (does support --bind-dynamic). Some of the test cases use one
and some the other, to make sure both code pathes are tested.

(cherry picked from commit 719c2c7665e5826a8cf05531080fe20354b39de1)

Conflicts:
  src/network/bridge_driver.c
  * some new functions are missing in the backport, so they don't need
    to be modified.
  * Use dnsmasqCapsFree() instead of virObjectUnref()
  src/util/dnsmasq.c
  * eliminate use of virObject, since this version of libvirt
    doesn't yet have it
  * use networkReportError() instead of virReportError()
  * virBitmapAlloc() instead of virBitmapNew()
  src/util/dnsmasq.h
  * don't #include virobject.h
  * add prototype for dnsmasqCapsFree()
  src/libvirt_private.syms
  * export dnsmasqCapsFree

12 years agospec: don't enable cgconfig under systemd
Eric Blake [Mon, 5 Nov 2012 16:48:28 +0000 (09:48 -0700)] 
spec: don't enable cgconfig under systemd

In Fedora 16, we quit enabling cgconfig because systemd set up
default cgroups that were good enough for our use.  But in F17,
when we switched to systemd, we reverted and started up cgconfig
again.  See also the tail of this thread:
https://www.redhat.com/archives/libvir-list/2012-October/msg01657.html

* libvirt.spec.in (with_systemd): Rely on systemd for cgroups.
(cherry picked from commit b61eadf3c62be4dfa452e04bf851aa5f2e0acb4b)

12 years agoPrep for release 0.9.11.7 v0.9.11.7
Cole Robinson [Sat, 27 Oct 2012 20:54:51 +0000 (16:54 -0400)] 
Prep for release 0.9.11.7

12 years agoqemu: Fix domxml-to-native network model conversion
Cole Robinson [Sun, 21 Oct 2012 02:28:34 +0000 (22:28 -0400)] 
qemu: Fix domxml-to-native network model conversion

https://bugzilla.redhat.com/show_bug.cgi?id=636832
(cherry picked from commit 9a2975786b74aa0fe75e3eadb39aa0f9b37e57bb)

Conflicts:
src/qemu/qemu_driver.c

12 years agoselinux: Don't fail RestoreAll if file doesn't have a default label
Cole Robinson [Sat, 20 Oct 2012 19:57:28 +0000 (15:57 -0400)] 
selinux: Don't fail RestoreAll if file doesn't have a default label

When restoring selinux labels after a VM is stopped, any non-standard
path that doesn't have a default selinux label causes the process
to stop and exit early. This isn't really an error condition IMO.

Of course the selinux API could be erroring for some other reason
but hopefully that's rare enough to not need explicit handling.

Common example here is storing disk images in a non-standard location
like under /mnt.
(cherry picked from commit 767be8be7226abe9a242c812ba5ff28108d2955c)

12 years agospec: Fix multilib issue with systemtap tapsets
Cole Robinson [Sun, 21 Oct 2012 02:46:58 +0000 (22:46 -0400)] 
spec: Fix multilib issue with systemtap tapsets

If building on a 64bit host, rename the affected tapsets to <name>-64.stp.
This is similar to what the python package does in fedora.

https://bugzilla.redhat.com/show_bug.cgi?id=831425
(cherry picked from commit 18d0632dc7c4b7c0930da32ed5a64f971c028452)

Conflicts:
libvirt.spec.in

12 years agodocs: Fix installation of internals/*.html
Cole Robinson [Sun, 21 Oct 2012 00:29:47 +0000 (20:29 -0400)] 
docs: Fix installation of internals/*.html

We were just installing them in the top level html directory, which
broke navigation and overwrote other pages.

https://bugzilla.redhat.com/show_bug.cgi?id=837825
(cherry picked from commit 7146d41634b5a13ce148c2dc94838ff62bc7c1ed)

Conflicts:
docs/Makefile.am

12 years agodocs: virsh: clarify behavior of send-key
Cole Robinson [Sat, 20 Oct 2012 23:55:24 +0000 (19:55 -0400)] 
docs: virsh: clarify behavior of send-key

https://bugzilla.redhat.com/show_bug.cgi?id=860004
(cherry picked from commit 2143ced7f557db6486623c8ce0ca296aeb7b8392)

12 years agodaemon: Avoid 'Could not find keytab file' in syslog
Cole Robinson [Sat, 20 Oct 2012 18:10:03 +0000 (14:10 -0400)] 
daemon: Avoid 'Could not find keytab file' in syslog

On F17 at least, every time libvirtd starts we get this in syslog:

libvirtd: Could not find keytab file: /etc/libvirt/krb5.tab: No such file or directory

This comes from cyrus-sasl, and happens regardless of whether the
gssapi plugin is requested, which is what actually uses
/etc/libvirt/krb5.tab.

While cyrus-sasl shouldn't complain, we can easily make it shut up by
commenting out the keytab value by default.

Also update the keytab comment to the more modern one from qemu's
sasl config file.
(cherry picked from commit fe772f24a6809b3d937ed6547cbaa9d820e514b6)

12 years agostorage: lvm: Don't overwrite lvcreate errors
Cole Robinson [Wed, 17 Oct 2012 00:25:41 +0000 (20:25 -0400)] 
storage: lvm: Don't overwrite lvcreate errors

Before:
$ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0
error: Failed to create vol sparsetest
error: internal error Child process (/usr/sbin/lvchange -aln vgvirt/sparsetest) unexpected exit status 5:   One or more specified logical volume(s) not found.

After:
$ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0
error: Failed to create vol sparsetest
error: internal error Child process (/usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt) unexpected exit status 5:   Unable to create new logical volume with no extents
(cherry picked from commit 01df6f2bff98d8fc68350ab90c212780ef9db67a)

Conflicts:
src/storage/storage_backend_logical.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.

12 years agoRevert "build: fix compilation without struct ifreq"
Eric Blake [Tue, 9 Oct 2012 15:52:14 +0000 (09:52 -0600)] 
Revert "build: fix compilation without struct ifreq"

This reverts commit d4ffc36fbcefbc9365b84dc9a610180c5636b6d1.
That commit cherry-picked from 68a97bd in isolation, but should
really only be needed if we had also cherry-picked 387117ad.

12 years agoPrep for release 0.9.11.6
Cole Robinson [Sun, 7 Oct 2012 21:50:04 +0000 (17:50 -0400)] 
Prep for release 0.9.11.6

12 years agoPrep for release 0.9.11.6 v0.9.11.6
Cole Robinson [Sun, 7 Oct 2012 21:50:04 +0000 (17:50 -0400)] 
Prep for release 0.9.11.6

12 years agoDon't install legacy initscripts at same time as systemd ones
Daniel P. Berrange [Fri, 21 Sep 2012 10:24:31 +0000 (11:24 +0100)] 
Don't install legacy initscripts at same time as systemd ones

The Fedora policies don't want us installing the legacy initscripts
in parallel with the systemd ones, so switch to only install the
systemd unit

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

12 years agoremove dnsmasq command line parameter "--filterwin2k"
Gene Czarcinski [Thu, 6 Sep 2012 16:08:22 +0000 (12:08 -0400)] 
remove dnsmasq command line parameter "--filterwin2k"

This patch removed the "--filterwin2k" dnsmasq command line
parameter which was unnecessary for domain specification,
possibly blocked some usage, and was command line clutter.

Gene Czarcinski <gene@czarc.net>
(cherry picked from commit f20b7dbe633acf7df9921027c6ca4f0b97918c8c)

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

12 years agodnsmasq: avoid forwarding queries without a domain
Gene Czarcinski [Wed, 22 Aug 2012 16:59:24 +0000 (12:59 -0400)] 
dnsmasq: avoid forwarding queries without a domain

dnsmasq is forwarding a number of queries upstream that should not
be done.  There still remains an MX query for a plain name with no
domain specified that will be forwarded is dnsmasq has --domain=xxx
--local=/xxx/ specified. This does not happen with no domain name
and --local=// ... not a libvirt problem.

BTW, thanks again to Claudio Bley!
(cherry picked from commit f3868259ca0517212e439a65c9060868f673b6c9)

Conflicts:
AUTHORS

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.11.5 v0.9.11.5
Cole Robinson [Mon, 13 Aug 2012 22:22:43 +0000 (18:22 -0400)] 
Prep for release 0.9.11.5

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 agoclient rpc: Fix error checking after poll()
Daniel P. Berrange [Wed, 13 Jun 2012 09:54:02 +0000 (10:54 +0100)] 
client rpc: Fix error checking after poll()

First 'poll' can't return EWOULDBLOCK, and second, we're checking errno
so far away from the poll() call that we've probably already trashed the
original errno value.
(cherry picked from commit 5d490603a6d60298162cbd32ec45f736b58929fb)

12 years agoclient rpc: Send keepalive requests from IO event loop
Jiri Denemark [Tue, 12 Jun 2012 12:32:27 +0000 (14:32 +0200)] 
client rpc: Send keepalive requests from IO event loop

In addition to keepalive responses, we also need to send keepalive
requests from client IO loop to properly detect dead connection in case
a libvirt API is called from the main loop, which prevents any timers to
be called.
(cherry picked from commit 4d971dc7ef1a9d0dc830c243b5731e862ad0eb5c)

12 years agoserver rpc: Remove APIs for manipulating filters on locked client
Jiri Denemark [Tue, 12 Jun 2012 07:02:38 +0000 (09:02 +0200)] 
server rpc: Remove APIs for manipulating filters on locked client

We don't need to add or remove filters when client object is already
locked anymore. There's no reason to keep the *Locked variants of those
APIs.
(cherry picked from commit d9ad41669828e33623ba8177f260b9f313c1963d)

12 years agorpc: Remove unused parameter in virKeepAliveStopInternal
Jiri Denemark [Tue, 12 Jun 2012 06:58:04 +0000 (08:58 +0200)] 
rpc: Remove unused parameter in virKeepAliveStopInternal

The previous commit removed the only usage of ``all'' parameter in
virKeepAliveStopInternal, which was actually the only reason for having
virKeepAliveStopInternal. This effectively reverts most of commit
6446a9e20cc65561ce6061742baf35a3a63d5ba1.
(cherry picked from commit 0ec514b359c88468d2279a43f7577b0fc3a78e08)

12 years agorpc: Do not use timer for sending keepalive responses
Jiri Denemark [Tue, 12 Jun 2012 07:01:49 +0000 (09:01 +0200)] 
rpc: Do not use timer for sending keepalive responses

When a libvirt API is called from the main event loop (which seems to be
common in event-based glib apps), the client IO loop would properly
handle keepalive requests sent by a server but will not actually send
them because the main event loop is blocked with the API. This patch
gets rid of response timer and the thread which is processing keepalive
requests is also responsible for queueing responses for delivery.
(cherry picked from commit bb85f2298e63b55b0465cb9e1f790019e99611dd)

12 years agoclient rpc: Separate call creation from running IO loop
Jiri Denemark [Tue, 12 Jun 2012 06:47:13 +0000 (08:47 +0200)] 
client rpc: Separate call creation from running IO loop

This makes it possible to create and queue new calls while we are
running IO loop.
(cherry picked from commit c57103e567b0fa09f2995cdd5a25015c48f7e017)

12 years agorpc: Add APIs for direct triggering of keepalive timer
Jiri Denemark [Tue, 12 Jun 2012 21:42:32 +0000 (23:42 +0200)] 
rpc: Add APIs for direct triggering of keepalive timer

Add virKeepAliveTimeout and virKeepAliveTrigger APIs that can be used to
set poll timeouts and trigger keepalive timer. virKeepAliveTrigger
checks if it is called to early and does nothing in that case.
(cherry picked from commit 28c75382b00d75b129245dedc1ce92596b96ddf9)

12 years agorpc: Refactor keepalive timer code
Jiri Denemark [Tue, 12 Jun 2012 21:41:25 +0000 (23:41 +0200)] 
rpc: Refactor keepalive timer code

The code that needs to be run every keepalive interval of inactivity was
only called from a timer and thus from the main event loop. We will need
to call the code directly from another place.
(cherry picked from commit a2ba8686325c8ba61c95f3f1152ef4420a029c15)

12 years agoclient rpc: Drop unused return value of virNetClientSendNonBlock
Jiri Denemark [Fri, 8 Jun 2012 13:24:06 +0000 (15:24 +0200)] 
client rpc: Drop unused return value of virNetClientSendNonBlock

As we never drop non-blocking calls, the return value that used to
indicate a call was dropped is no longer needed.
(cherry picked from commit ca9b13e3733195d400effaca0ef13e4545a3b608)

12 years agoclient rpc: Just queue non-blocking call if another thread has the buck
Jiri Denemark [Mon, 11 Jun 2012 12:24:06 +0000 (14:24 +0200)] 
client rpc: Just queue non-blocking call if another thread has the buck

As non-blocking calls are no longer dropped, we don't really need to
care that much about their fate and wait for the thread with the buck
to process them. If another thread has the buck, we can just push a
non-blocking call to the queue and be done with it.
(cherry picked from commit ef392614aa585d168e618ffaf2c83545d81f0113)

12 years agoclient rpc: Don't drop non-blocking calls
Jiri Denemark [Fri, 8 Jun 2012 12:21:00 +0000 (14:21 +0200)] 
client rpc: Don't drop non-blocking calls

So far, we were dropping non-blocking calls whenever sending them would
block. In case a client is sending lots of stream calls (which are not
supposed to generate any reply), the assumption that having other calls
in a queue is sufficient to get a reply from the server doesn't work. I
tried to fix this in b1e374a7ac56927cfe62435179bf0bba1e08b372 but
failed and reverted that commit.

With this patch, non-blocking calls are never dropped (unless the
connection is being closed) and will always be sent.
(cherry picked from commit 78602c4e83bbf51f89c24a0be14074e71d01bf60)

12 years agoclient rpc: Use event loop for writing
Jiri Denemark [Tue, 12 Jun 2012 06:41:59 +0000 (08:41 +0200)] 
client rpc: Use event loop for writing

Normally, when every call has a thread associated with it, the thread
may get the buck and be in charge of sending all calls until its own
call is done. When we introduced non-blocking calls, we had to add
special handling of new non-blocking calls. This patch uses event loop
to send data if there is no thread to get the buck so that any
non-blocking calls left in the queue are properly sent without having to
handle them specially. It also avoids adding even more cruft to client
IO loop in the following patches.

With this change in, non-blocking calls may see unpredictable delays in
delivery when the client has no event loop registered. However, the only
non-blocking calls we have are keepalives and we already require event
loop for them, which makes this a non-issue until someone introduces new
non-blocking calls.
(cherry picked from commit 9e747e5c5079a5aead2f248fc22ff658bd0180be)

12 years agoclient rpc: Improve debug messages in virNetClientIO
Jiri Denemark [Fri, 8 Jun 2012 11:41:25 +0000 (13:41 +0200)] 
client rpc: Improve debug messages in virNetClientIO

When analyzing our debug log, I'm always confused about what each of the
pointers mean. Let's be explicit.
(cherry picked from commit 71689f95ceedbc63953a0b06aa2c2cee7fabfa2b)

12 years agokeepalive: Add ability to disable keepalive messages
Peter Krempa [Tue, 24 Apr 2012 14:38:41 +0000 (16:38 +0200)] 
keepalive: Add ability to disable keepalive messages

The docs for virConnectSetKeepAlive() advertise that this function
should be able to disable keepalives on negative or zero interval time.

This patch removes the check that prohibited this and adds code to
disable keepalives on negative/zero interval.

* src/libvirt.c: virConnectSetKeepAlive(): - remove check for negative
                                             values
* src/rpc/virnetclient.c
* src/rpc/virnetclient.h: - add virNetClientKeepAliveStop() to disable
                            keepalive messages
* src/remote/remote_driver.c: remoteSetKeepAlive(): -add ability to
                                                     disable keepalives
(cherry picked from commit 6446a9e20cc65561ce6061742baf35a3a63d5ba1)

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

12 years agoFix typo s/AM_CLFAGS/AM_CFLAGS/ in sanlock link
Daniel P. Berrange [Thu, 2 Aug 2012 19:10:13 +0000 (20:10 +0100)] 
Fix typo s/AM_CLFAGS/AM_CFLAGS/ in sanlock link
(cherry picked from commit 7de158cf68cae7ab55d3cae1a01744b374810840)

12 years agovirsh: console: Avoid using stream after being freed.
Peter Krempa [Fri, 3 Aug 2012 11:16:24 +0000 (13:16 +0200)] 
virsh: console: Avoid using stream after being freed.

The stream object wasn't set to NULL after freeing causing a double free
attempt on the cleanup path.
(cherry picked from commit e3b8808ba764e06f68785a2bbdd8b7ab00b71fa4)

12 years agoqemu: syntax fix
Marc-André Lureau [Tue, 31 Jul 2012 17:51:41 +0000 (19:51 +0200)] 
qemu: syntax fix

Pushed without ack, under the trivial rule.
(cherry picked from commit 2beed2daaf6539a13e915073343a82384e3a135d)

12 years agoqemu: fix use after free
Eric Blake [Tue, 31 Jul 2012 14:05:14 +0000 (08:05 -0600)] 
qemu: fix use after free

Detected by Coverity.

* src/qemu/qemu_hotplug.c (qemuDomainAttachHostDevice): Avoid
double free of usb on failure.
(cherry picked from commit 665c8cdecc2d91a83f08a6ec95531b0de57c0e0a)

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

12 years agosecurity: Skip labeling resources when seclabel defaults to none
Jiri Denemark [Wed, 25 Jul 2012 12:38:27 +0000 (14:38 +0200)] 
security: Skip labeling resources when seclabel defaults to none

If a domain is explicitly configured with <seclabel type="none"/> we
correctly ensure that no labeling will be done by setting
norelabel=true. However, if no seclabel element is present in domain XML
and hypervisor is configured not to confine domains by default, we only
set type to "none" without turning off relabeling. Thus if such a domain
is being started, security driver wants to relabel resources with
default label, which doesn't make any sense.

Moreover, with SELinux security driver, the generated image label lacks
"s0" sensitivity, which causes setfilecon() fail with EINVAL in
enforcing mode.
(cherry picked from commit ce53382ba28179d3a504b29b4f888b6e130d53f0)

12 years agofixed SegFault in virauth
Martin Kletzander [Tue, 24 Jul 2012 14:08:46 +0000 (16:08 +0200)] 
fixed SegFault in virauth

No check for conn->uri being NULL in virAuthGetConfigFilePath (valid
state) made the client segfault. This happens for example with these
settings:
 - no virtualbox driver installed (modifies conn->uri)
 - no default URI set (VIRSH_DEFAULT_CONNECT_URI="",
   LIBVIRT_DEFAULT_URI="", uri_default="")
 - auth_sock_rw="sasl"
 - virsh run as root

That are unfortunately the settings with fresh Fedora 17 installation
with VDSM.

The check ought to be enough as conn->uri being NULL is valid in later
code and is handled properly.
(cherry picked from commit 5eef74320b0bb9e604400168e0896c5ac527abef)

12 years agoadding handling EINTR to poll to make it more robust
Royce Lv [Thu, 19 Jul 2012 01:49:41 +0000 (09:49 +0800)] 
adding handling EINTR to poll to make it more robust

some system call and signal will interrupt poll,
making event loop stops and fails to react events and keepalive message
from libvirt.
adding handling EINTR to poll to make it more robust

Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com>
(cherry picked from commit 5e62ba3428b377d47f5ddbee705ee33027354824)

12 years agodoc: Fix time keeping example for the guest clock
Doug Goldstein [Sat, 21 Jul 2012 13:14:44 +0000 (08:14 -0500)] 
doc: Fix time keeping example for the guest clock

The time keeping example was missing quotes which resulted in an error
if you copied and pasted the example into a domain's XML. Additionally
the rest of the examples use single quotes (') instead of double quotes
(") so standardized that.
(cherry picked from commit d57e17d58300589e4b53c52360d9fcd7592f53b2)

12 years agoFix test failure when no IPv6 is avail
Doug Goldstein [Sun, 22 Jul 2012 17:04:16 +0000 (12:04 -0500)] 
Fix test failure when no IPv6 is avail

When the system doesn't have IPv6 available (e.g. not built into the
kernel or the module isn't loaded), you can not create an IPv6 socket.
The test determines earlier on that IPv6 isn't available then goes and
creates a socket. This makes socket creation conditional on IPv6
availability.
(cherry picked from commit faffe26909d8e5cde7e80e5a8f33296ed56dcfc7)

12 years agoEnsure failure to talk to Xen hypervisor is fatal when privileged
Daniel P. Berrange [Fri, 20 Jul 2012 13:52:44 +0000 (14:52 +0100)] 
Ensure failure to talk to Xen hypervisor is fatal when privileged

As per the comment, the Xen hypervisor driver is considered to
be mandatory when running privileged. When it fails to open,
we should thus return an error, not ignore it.
(cherry picked from commit 489900e3de9de74ce4197807935ffc3ef8a68bca)

12 years agoDon't autostart domains when reloading config
Daniel P. Berrange [Fri, 13 Jul 2012 11:49:55 +0000 (12:49 +0100)] 
Don't autostart domains when reloading config

When sending SIGHUP to libvirtd, it will trigger the virStateDriver
reload operation. This is intended to reload the configuration files
for guests. For unknown historical reasons this is also triggering
autostart of all guests. Autostart is generally expected to be
something that happens on OS startup. Starting VMs on SIGHUP will
violate that expectation and potentially cause dangerous scenarios
if the admin has explicitly shutdown a misbehaving VM that has
been marked as autostart

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

12 years agobuild: fix compilation without struct ifreq
Eric Blake [Wed, 18 Jul 2012 22:46:05 +0000 (16:46 -0600)] 
build: fix compilation without struct ifreq

Detected on Cygwin.  Broken in commit 387117ad.

* src/util/virnetdev.c (virNetDevValidateConfig)
(virNetDevReplaceNetConfig): Fix prototypes.
* src/util/virnetlink.c (virNetlinkEventAddClient)
(virNetlinkEventRemoveClient): Likewise.
(cherry picked from commit 68a97bd85fffca4494bc5620c06c8e35f5c0af64)

12 years agoremote: Fix locking in stream APIs
Jiri Denemark [Tue, 17 Jul 2012 14:36:23 +0000 (16:36 +0200)] 
remote: Fix locking in stream APIs

Remote driver needs to make sure the driver lock is released before
entering client IO loop as that may block indefinitely in poll(). As a
direct consequence of not following this in stream APIs, tunneled
migration to a destination host which becomes non-responding may block
qemu driver. Luckily, if keepalive is turned for p2p migrations, both
remote and qemu drivers will get automagically unblocked after keepalive
timeout.
(cherry picked from commit 17f3be079c3c421eff203fcd311b0357ec42d801)

12 years agoqemu: Do not fail virConnectCompareCPU if host CPU is not known
Jiri Denemark [Thu, 12 Jul 2012 09:49:15 +0000 (11:49 +0200)] 
qemu: Do not fail virConnectCompareCPU if host CPU is not known

When host CPU could not be properly detected, virConnectCompareCPU will
just report that any CPU is incompatible with host CPU instead of
failing.
(cherry picked from commit 87c8623161f19c4f37844991deb1477e53c2b310)

12 years agoClarify direct migration
Jiri Denemark [Thu, 12 Jul 2012 13:27:18 +0000 (15:27 +0200)] 
Clarify direct migration

When --direct is used when migrating a domain running on a hypervisor
that does not support direct migration (such as QEMU), the caller would
get the following error message:

    this function is not supported by the connection driver:
    virDomainMigrateToURI2

which is a complete nonsense since qemu driver implements
virDomainMigrateToURI2. This patch would emit a more sensible error in
this case:

    Requested operation is not valid: direct migration is not supported
    by the connection driver
(cherry picked from commit 3189dfb1636da22d426d2fc07cc9f60304b16c5c)

12 years agoFix daemon auto-spawning
Christophe Fergeau [Thu, 12 Jul 2012 11:52:36 +0000 (13:52 +0200)] 
Fix daemon auto-spawning

Commit 32a9aac switched libvirt to use the XDG base directories
to locate most of its data/config. In particular, the per-user socket
for qemu:///session is now stored in the XDG runtime directory.
This directory is located by looking at the XDG_RUNTIME_DIR environment
variable, with a fallback to ~/.cache/libvirt if this variable is not
set.

When the daemon is autospawned because a client application wants
to use qemu:///session, the daemon is ran in a clean environment
which does not contain XDG_RUNTIME_DIR. It will create its socket
in ~/.cache/libvirt. If the client application has XDG_RUNTIME_DIR
set, it will not look for the socket in the fallback place, and will
fail to connect to the autospawned daemon.

This patch adds XDG_RUNTIME_DIR to the daemon environment before
auto-starting it. I've done this in virNetSocketForkDaemon rather
than in virCommandAddEnvPassCommon as I wasn't sure we want to pass
these variables to other commands libvirt spawns. XDG_CACHE_HOME
and XDG_CONFIG_HOME are also added to the daemon env as it makes use
of those as well.
(cherry picked from commit efe6c8021146d046846ead5b5efc9828d97c1ceb)

12 years agoopenvz: Handle domain obj hash map errors
Guido Günther [Mon, 9 Jul 2012 10:11:17 +0000 (12:11 +0200)] 
openvz: Handle domain obj hash map errors

This makes the driver fail with a clear error message in case of UUID
collisions (for example if somebody copied a container configuration
without updating the UUID) and also raises an error on other hash map
failures.

OpenVZ itself doesn't complain about duplicate UUIDs since this
parameter is only used by libvirt.
(cherry picked from commit 31351c316fee0487dcbc5ef6b630d75be6b212e5)

12 years agoFix /domain/features setting in qemuParseCommandLine
Christophe Fergeau [Tue, 10 Jul 2012 10:02:10 +0000 (12:02 +0200)] 
Fix /domain/features setting in qemuParseCommandLine

Commit 5e6ce1 moved down detection of the ACPI feature in
qemuParseCommandLine. However, when ACPI is detected, it clears
all feature flags in def->features to only set ACPI. This used to
be fine because this was the first place were def->features was set,
but after the move this is no longer necessarily true because this
block comes before the ACPI check:

if (strstr(def->emulator, "kvm")) {
    def->virtType = VIR_DOMAIN_VIRT_KVM;
    def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
}

Since def is allocated in qemuParseCommandLine using VIR_ALLOC, we
can always use |= when modifying def->features
(cherry picked from commit 626dd5180e472c0b4c0c5fb7072358743ca63653)

12 years agosystemd: start libvirtd after network
Jim Fehlig [Mon, 9 Jul 2012 15:52:55 +0000 (09:52 -0600)] 
systemd: start libvirtd after network

Domains configured with autostart may fail to start if the host
network stack has not been started.  E.g. when using bridged
networking autostarting a domain can fail with

libvirtd[1403]: 2012-06-20 13:23:49.833+0000: 1485: error :
qemuAutostartDomain:177 : Failed to autostart VM 'test': Cannot get
interface MTU on 'br0': No such device
(cherry picked from commit 4036aa91bff6482cf4c136c93277619fa8ec6f94)

12 years agoFix a string format bug in qemu_cgroup.c
tangchen [Fri, 6 Jul 2012 01:53:11 +0000 (09:53 +0800)] 
Fix a string format bug in qemu_cgroup.c

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
(cherry picked from commit 097da1abbd25da5876850785f6b9e742166b16d4)

12 years agovirsh: Clarify documentation for virsh dompmsuspend command
Peter Krempa [Thu, 21 Jun 2012 15:59:27 +0000 (17:59 +0200)] 
virsh: Clarify documentation for virsh dompmsuspend command

Clarify the docs to make more clear what this command does and that it
requires a guest agent running in the guest.
(cherry picked from commit e16d434da75430b05545f4d85d156f36b1ce51d1)

12 years agostorage_backend_fs: Don't free a part of a structure on error
Peter Krempa [Mon, 9 Jul 2012 12:10:05 +0000 (14:10 +0200)] 
storage_backend_fs: Don't free a part of a structure on error

As the storage pool sources are stored in a list of structs, the pointer
returned by virStoragePoolSourceListNewSource() shouldn't be freed as it
points in the middle of a memory block. This combined with a regression
that takes the error path every time on caused a double-free abort on
the src struct in question.
(cherry picked from commit ab9c72ae9e55e7190f52ad1550624630a5c7f78b)

12 years agoFix one test regression on auth Ceph support
Daniel Veillard [Thu, 5 Jul 2012 09:56:23 +0000 (17:56 +0800)] 
Fix one test regression on auth Ceph support

The extra data need to be added to one test case
(cherry picked from commit c47a8aec531714101dd1eb2088742c60296b852b)