]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
9 years agoPrep for release 1.2.18.4 v1.2.18-maint v1.2.18.4
Cole Robinson [Mon, 18 Jul 2016 22:35:23 +0000 (18:35 -0400)] 
Prep for release 1.2.18.4

9 years agoqemu: Let empty default VNC password work as documented
Jiri Denemark [Tue, 28 Jun 2016 12:39:58 +0000 (14:39 +0200)] 
qemu: Let empty default VNC password work as documented

CVE-2016-5008

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

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

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

9 years agospec: Fix error in last backport
Cole Robinson [Thu, 23 Jun 2016 20:23:11 +0000 (16:23 -0400)] 
spec: Fix error in last backport

9 years agospec: Advertise nvram paths of official fedora edk2 builds
Cole Robinson [Fri, 20 May 2016 19:50:16 +0000 (15:50 -0400)] 
spec: Advertise nvram paths of official fedora edk2 builds

Fedora now ships edk2 firmware in its official repos, so adapt
the nvram path list to match. Eventually we can remove the nightly
links as well once some integration kinks have been worked out,
and documentation updated.

Move the macro building into the %build target, which lets us
build up a shell variable and make things a bit more readable

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

9 years agoPrep for release 1.2.18.3 v1.2.18.3
Cole Robinson [Wed, 4 May 2016 23:50:48 +0000 (19:50 -0400)] 
Prep for release 1.2.18.3

9 years agospec: Use proper indentation
Andrea Bolognani [Tue, 26 Apr 2016 15:37:16 +0000 (17:37 +0200)] 
spec: Use proper indentation

Commit 1d4400082a02 added some code that was not indented properly
and broke syntax-check. Fix it.

(cherry picked from commit a528ae7fb7e24e448d2636012218109ae3ef82b6)

9 years agospec: If installing default network, restart libvirtd
Cole Robinson [Thu, 16 Apr 2015 19:42:05 +0000 (15:42 -0400)] 
spec: If installing default network, restart libvirtd

If libvirt-daemon-config-network is installed while libvirtd is already
running, the daemon doesn't notice the network. Users then have to
manually restart libvirtd (or reboot) to pick up the network.

Instead let's trigger a daemon restart when the package is first installed.
Then the default network is available immediately if libvirtd was already
running.

https://bugzilla.redhat.com/show_bug.cgi?id=867546
(cherry picked from commit 1d4400082a02c41b152cc9ab7b4cfc428cc527ee)

9 years agorpc: Don't leak fd via CreateXMLWithFiles
Ben Gray [Sat, 23 Apr 2016 22:38:21 +0000 (18:38 -0400)] 
rpc: Don't leak fd via CreateXMLWithFiles

FD passing APIs like CreateXMLWithFiles or OpenGraphicsFD will leak
file descriptors. The user passes in an fd, which is dup()'d in
virNetClientProgramCall. The new fd is what is transfered to the
server virNetClientIOWriteMessage.

Once all the fds have been written though, the parent msg->fds list
is immediately free'd, so the individual fds are never closed.

This closes each FD as its send to the server, so all fds have been
closed by the time msg->fds is free'd.

https://bugzilla.redhat.com/show_bug.cgi?id=1159766
(cherry picked from commit 5ba48584fbc5079c0ddbc9e9a52c96d7bcef0761)

9 years agolibvirt.spec: remove duplicate files from -docs package
Daniel P. Berrange [Wed, 4 May 2016 09:11:37 +0000 (10:11 +0100)] 
libvirt.spec: remove duplicate files from -docs package

Previous commit moved some lists out of the -devel package
and into the -docs package

  commit feffcc03a0d3690dcffd860682dcbaa61d726b39
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Wed Apr 13 10:37:42 2016 -0400

    spec: Only pull in API docs with -devel package

What was not realized is that the rule 'libvirt-docs/*'
and ' docs/*.html docs/html docs/*.gif' actually point
to the exact same content. ie, we had previously included
the website HTML in *both* the -docs and -devel packages.

So this change ended up listing the files twice, which
caused RPM to print a load of warnings:

warning: File listed twice: /usr/share/doc/libvirt-docs/html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/32favicon.png
warning: File listed twice: /usr/share/doc/libvirt-docs/html/404.html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/acl.html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/aclpolkit.html

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

9 years agowireshark: Fix header of get_message_len()
Michal Privoznik [Sun, 27 Dec 2015 10:00:22 +0000 (11:00 +0100)] 
wireshark: Fix header of get_message_len()

In wireshark commit ceb8d954 (v1.99.2) they have changed the
signature of a function that determines how long a libvirt packet
is. Now it accepts a void pointer for passing data into the
function. Well, this is nice, but we don't need it right now.
Anyway, we have to change our code.

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

9 years agowireshark: Replace WIRESHARK_COMPAT with actual version comparison
Michal Privoznik [Mon, 4 Jan 2016 10:26:03 +0000 (11:26 +0100)] 
wireshark: Replace WIRESHARK_COMPAT with actual version comparison

In the upcoming patch we will need yet another #ifdef code block
depending on wireshark version. Instead of defining
WIRESHARK_COMPAT2 or something lets just compare the version
right at the place so that we can clearly see what version broke
API.

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

9 years agowireshark: s/tvb_length/tvb_captured_length/
Michal Privoznik [Sun, 27 Dec 2015 09:55:29 +0000 (10:55 +0100)] 
wireshark: s/tvb_length/tvb_captured_length/

In wireshak commit 22149c55 (v.1.11.3) the API was renamed.
Follow the change in our code too. Since the wireshark change was
made in the very same version that we require at least we are
good to go.

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

9 years agowireshark: s/ep_alloc/wmem_alloc/
Michal Privoznik [Sun, 27 Dec 2015 09:49:10 +0000 (10:49 +0100)] 
wireshark: s/ep_alloc/wmem_alloc/

In wireshark, they have introduced their own memory allocator
wmem. This means that we need to adapt our code to that change
too. Notably 0ad15f88ccf434e8210ca is the wireshark commit you
want to look at. It's the one where they dropped the old API. The
new allocator has been introduced in 84cc3daa (v1.10.0), however,
was not exposed until 5c05c9e0 (v1.10.0). Since we already are
requiring 1.11.3 or higher no other change is needed.

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

9 years agowireshark: s/proto_tree_add_text/proto_tree_add_item/
Michal Privoznik [Sun, 27 Dec 2015 09:43:37 +0000 (10:43 +0100)] 
wireshark: s/proto_tree_add_text/proto_tree_add_item/

In the wireshark commit e2735ecfdd7a96c they dropped
proto_tree_add_text in favor of proto_tree_add_item. Adapt to
this change.

Moreover, the proto_tree_add_item API is around for ages and we
are already using it anyway. Therefore we don't need to change
required version of wireshark.

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

9 years agospec: Only pull in API docs with -devel package
Cole Robinson [Wed, 13 Apr 2016 14:37:42 +0000 (10:37 -0400)] 
spec: Only pull in API docs with -devel package

Move some API specific documentation out of -docs package and into
-devel, and some end user docs out of -devel and into -docs, then
drop the -devel dep on -docs. This is more in line with the suggested
Fedora guidelines.

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

9 years agobuild: accomodate selinux 2.5 header API change
Eric Blake [Wed, 24 Feb 2016 22:02:44 +0000 (15:02 -0700)] 
build: accomodate selinux 2.5 header API change

Yet again, selinux has been adding const-correctness; this change
is ABI-compatible, but breaks API, which affects us when we try to
override things in our testsuite:

../../tests/securityselinuxhelper.c:307:24: error: conflicting types for 'selabel_open'
 struct selabel_handle *selabel_open(unsigned int backend,
                        ^~~~~~~~~~~~
In file included from ../../tests/securityselinuxhelper.c:32:0:
/usr/include/selinux/label.h:73:24: note: previous declaration of 'selabel_open' was here

The problem is a new 'const' prior to the second parameter.

Fix it the same way we did in commit 292d3f2d: check for the new
const at configure time.

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

9 years agobuild: add GCC 6.0 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:22:20 +0000 (18:22 +0200)] 
build: add GCC 6.0 -Wlogical-op workaround

fdstream.c: In function 'virFDStreamWrite':
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
                            ^~

Fedora rawhide now uses gcc 6.0 and there is a bug with -Wlogical-op
producing false warnings.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602

Use GCC pragma push/pop and ignore -Wlogical-op for GCC that supports
push/pop pragma and also has this bug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit d713a6b120904c488170e7920c482b2fade70ae1)

9 years agobuild: cleanup GCC < 4.6 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:21:13 +0000 (18:21 +0200)] 
build: cleanup GCC < 4.6 -Wlogical-op workaround

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 7fb81831fc497aa4a34fdfc036be9c9ae4401084)

9 years agolxc: don't try to hide parent cgroups inside container
Daniel P. Berrange [Fri, 22 Jan 2016 16:07:18 +0000 (16:07 +0000)] 
lxc: don't try to hide parent cgroups inside container

On the host when we start a container, it will be
placed in a cgroup path of

   /machine.slice/machine-lxc\x2ddemo.scope

under /sys/fs/cgroup/*

Inside the containers' namespace we need to setup
/sys/fs/cgroup mounts, and currently will bind
mount /machine.slice/machine-lxc\x2ddemo.scope on
the host to appear as / in the container.

While this may sound nice, it confuses applications
dealing with cgroups, because /proc/$PID/cgroup
now does not match the directory in /sys/fs/cgroup

This particularly causes problems for systems and
will make it create repeated path components in
the cgroup for apps run in the container eg

  /machine.slice/machine-lxc\x2ddemo.scope/machine.slice/machine-lxc\x2ddemo.scope/user.slice/user-0.slice/session-61.scope

This also causes any systemd service that uses
sd-notify to fail to start, because when systemd
receives the notification it won't be able to
identify the corresponding unit it came from.
In particular this break rabbitmq-server startup

Future kernels will provide proper cgroup namespacing
which will handle this problem, but until that time
we should not try to play games with hiding parent
cgroups.

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

9 years agodriver: log missing modules as INFO, not WARN
Jovanka Gulicoska [Thu, 17 Mar 2016 19:02:20 +0000 (20:02 +0100)] 
driver: log missing modules as INFO, not WARN

Missing modules is a common expected scenario for most libvirt usage on
RPM distributions like Fedora, so it doesn't really warrant logging at
WARN level. Use INFO instead

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

9 years agorpc: wait longer for session daemon to start up
Cole Robinson [Tue, 15 Mar 2016 21:04:32 +0000 (17:04 -0400)] 
rpc: wait longer for session daemon to start up

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

We only wait 0.5 seconds for the session daemon to start up and present
its socket, which isn't sufficient for many users. Bump up the sleep
interval and retry amount so we wait for a total of 5.0 seconds.

(cherry picked from commit ca0c06f4008154de55e0b3109885facd0bf02d32)

9 years agoutil: virfile: Only setuid for virFileRemove if on NFS
Cole Robinson [Wed, 9 Mar 2016 17:20:37 +0000 (12:20 -0500)] 
util: virfile: Only setuid for virFileRemove if on NFS

NFS with root-squash is the only reason we need to do setuid/setgid
crazyness in virFileRemove, so limit that behavior to the NFS case.

(cherry picked from commit adefc561cc4c6a007529769c3df286f2ed461684)

9 years agoutil: virfile: Clarify setuid usage for virFileRemove
Cole Robinson [Wed, 9 Mar 2016 15:53:54 +0000 (10:53 -0500)] 
util: virfile: Clarify setuid usage for virFileRemove

Break these checks out into their own function, and clearly document
each one. This shouldn't change behavior

(cherry picked from commit 7cf5343709935694b76af7b134447a2c555400b6)

9 years agolxc: fuse: Stub out Slab bits in /proc/meminfo
Cole Robinson [Thu, 21 Jan 2016 18:33:50 +0000 (13:33 -0500)] 
lxc: fuse: Stub out Slab bits in /proc/meminfo

'free' on fedora23 wants to use the Slab field for calculated used
memory. The equation is:

used = MemTotal - MemFree - (Cached + Slab) - Buffers

We already set Cached and Buffers to 0, do the same for Slab and its
related values

https://bugzilla.redhat.com/show_bug.cgi?id=1300781
(cherry picked from commit 81da8bc73b6bc6777632b65a0df45335f7caebe4)

9 years agolxc: fuse: Fill in MemAvailable for /proc/meminfo
Cole Robinson [Thu, 21 Jan 2016 18:18:04 +0000 (13:18 -0500)] 
lxc: fuse: Fill in MemAvailable for /proc/meminfo

'free' on Fedora 23 will use MemAvailable to calculate its 'available'
field, but we are passing through the host's value. Set it to match
MemFree, which is what 'free' will do for older linux that don't have
MemAvailable

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

9 years agolxc: fuse: Fix /proc/meminfo size calculation
Cole Robinson [Thu, 21 Jan 2016 18:14:54 +0000 (13:14 -0500)] 
lxc: fuse: Fix /proc/meminfo size calculation

We virtualize bits of /proc/meminfo by replacing host values with
values specific to the container.

However for calculating the final size of the returned data, we are
using the size of the original file and not the altered copy, which
could give garbelled output.

(cherry picked from commit 8418245a7e00f873594f1000c9606d08265088e0)

9 years agolxc: fuse: Unindent meminfo logic
Cole Robinson [Thu, 21 Jan 2016 18:06:03 +0000 (13:06 -0500)] 
lxc: fuse: Unindent meminfo logic

Reverse the conditional at the start so we aren't stuffing all the logic
in an 'if' block

(cherry picked from commit f65dcfcd140d0a627aeab3fa0e9dc5f74da98e6d)

9 years agovirfile: Fix error path for forked virFileRemove
John Ferlan [Wed, 30 Sep 2015 21:37:27 +0000 (17:37 -0400)] 
virfile: Fix error path for forked virFileRemove

As it turns out the caller in this case expects a return < 0 for failure
and to get/use "errno" rather than using the negative of returned status.
Again different than the create path.

If someone "deleted" a file from the pool without using virsh vol-delete,
then the unlink/rmdir would return an error (-1) and set errno to ENOENT.
The caller checks errno for ENOENT when determining whether to throw an
error message indicating the failure.  Without the change, the error
message is:

error: Failed to delete vol $vol
error: cannot unlink file '/$pathto/$vol': Success

This patch thus allows the fork path to follow the non-fork path
where unlink/rmdir return -1 and errno.

(cherry picked from commit cb19cff468432e55366014658f405066ce06c2f2)

9 years agosecurity: Do not restore kernel and initrd labels
Jiri Denemark [Fri, 15 Jan 2016 09:55:58 +0000 (10:55 +0100)] 
security: Do not restore kernel and initrd labels

Kernel/initrd files are essentially read-only shareable images and thus
should be handled in the same way. We already use the appropriate label
for kernel/initrd files when starting a domain, but when a domain gets
destroyed we would remove the labels which would make other running
domains using the same files very unhappy.

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

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

9 years agorpc: socket: Don't repeatedly attempt to launch daemon
Cole Robinson [Tue, 12 Jan 2016 01:13:38 +0000 (20:13 -0500)] 
rpc: socket: Don't repeatedly attempt to launch daemon

On every socket connect(2) attempt we were re-launching session
libvirtd, up to 100 times in 5 seconds.

This understandably caused some weird load races and intermittent
qemu:///session startup failures

https://bugzilla.redhat.com/show_bug.cgi?id=1271183
(cherry picked from commit 2eb7a975756d05a5b54ab4acf60083beb6161ac6)

9 years agorpc: socket: Explicitly error if we exceed retry count
Cole Robinson [Tue, 12 Jan 2016 01:08:45 +0000 (20:08 -0500)] 
rpc: socket: Explicitly error if we exceed retry count

When we autolaunch libvirtd for session URIs, we spin in a retry
loop waiting for the daemon to start and the connect(2) to succeed.

However if we exceed the retry count, we don't explicitly raise an
error, which can yield a slew of different error messages elsewhere
in the code.

Explicitly raise the last connect(2) failure if we run out of retries.

(cherry picked from commit 8da02d528068942303923fc4f935e77cccac9c7c)

9 years agorpc: socket: Minor cleanups
Cole Robinson [Tue, 12 Jan 2016 01:01:24 +0000 (20:01 -0500)] 
rpc: socket: Minor cleanups

- Add some debugging
- Make the loop dependent only on retries
- Make it explicit that connect(2) success exits the loop
- Invert the error checking logic

(cherry picked from commit f102c7146ed7f6e04af0ad3bce302476239f2502)

9 years agobuild: predictably generate systemtap tapsets (bz 1173641)
Cole Robinson [Wed, 20 Jan 2016 03:19:56 +0000 (22:19 -0500)] 
build: predictably generate systemtap tapsets (bz 1173641)

The generated output is dependent on perl hashtable ordering, which
gives different results for i686 and x86_64. Fix this by sorting
the hash keys before iterating over them

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

9 years agoleaseshelper: fix crash when no mac is specified
Ján Tomko [Thu, 14 Jan 2016 13:31:17 +0000 (14:31 +0100)] 
leaseshelper: fix crash when no mac is specified

If dnsmasq specified DNSMASQ_IAID (so we're dealing with an IPv6
lease) but no DNSMASQ_MAC, we skip creation of the new lease object.

Also skip adding it to the leases array.

https://bugzilla.redhat.com/show_bug.cgi?id=1202350
(cherry picked from commit df9fe124d650bc438c531673492569da87523d20)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoschema: interleave domain name and uuid with other elements
Ján Tomko [Thu, 17 Dec 2015 12:43:58 +0000 (13:43 +0100)] 
schema: interleave domain name and uuid with other elements

Allow <name> and <uuid> anywhere under <domain>, not just at the top:

error:XML document failed to validate against schema: Unable to validate
doc against /usr/share/libvirt/schemas/domain.rng
Expecting an element name, got nothing
Invalid sequence in interleave
Element domain failed to validate content

Introduced with the first RelaxNG schema in commit c642103.

https://bugzilla.redhat.com/show_bug.cgi?id=1292131
(cherry picked from commit b4e0549febe416ffefc16f389423740d6d65fa74)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoPrep for release 1.2.18.2 v1.2.18.2
Cole Robinson [Thu, 24 Dec 2015 00:14:59 +0000 (19:14 -0500)] 
Prep for release 1.2.18.2

9 years agoFix a trailing space in spec file
Daniel Veillard [Mon, 3 Aug 2015 09:43:34 +0000 (17:43 +0800)] 
Fix a trailing space in spec file

(cherry picked from commit bd311d3a8a1771b1f06e4fdc7eeaccb6923b4c2d)

9 years agovirsh: report errors for empty strings
Ján Tomko [Thu, 3 Dec 2015 12:42:35 +0000 (13:42 +0100)] 
virsh: report errors for empty strings

Several callers were using vshCommandOptString without setting an error.
Use vshCommandOptStringReq which sets the error.

https://bugzilla.redhat.com/show_bug.cgi?id=1281707
(cherry picked from commit 45138725cf2a14575aa5204fe55efd6668b9b03a)

9 years agobridge: check for invalid MAC in networkGetDHCPLeases
Ján Tomko [Thu, 3 Dec 2015 08:47:23 +0000 (09:47 +0100)] 
bridge: check for invalid MAC in networkGetDHCPLeases

Instead of comparing garbage strings against real MAC addresses,
introduce an error mesage for unparsable ones:

$ virsh net-dhcp-leases default  --mac t12
error: Failed to get leases info for default
error: invalid MAC address: t12

https://bugzilla.redhat.com/show_bug.cgi?id=1261432
(cherry picked from commit 1e6d87bdfc801d2c006a17054bd19273430dce14)

9 years agoEnhance documentation of virDomainDetachDevice
Jiri Denemark [Wed, 25 Nov 2015 15:39:17 +0000 (16:39 +0100)] 
Enhance documentation of virDomainDetachDevice

Link it to virDomainDetachDeviceFlags.

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

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

9 years agoapparmor: add missing qemu binaries
Guido Günther [Tue, 24 Nov 2015 15:04:18 +0000 (16:04 +0100)] 
apparmor: add missing qemu binaries

This adds the qemu binaries as of 1.2.4 in Debian. It also removes a
duplicate sparc64 entry.

(cherry picked from commit d8ca0cbd4b01eed79d1845ca7d734b9196d28f9d)

9 years agoqemu: Use live autoNodeset when numatune placement is auto
Luyao Huang [Mon, 12 Oct 2015 09:28:15 +0000 (17:28 +0800)] 
qemu: Use live autoNodeset when numatune placement is auto

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

Commit id '9deb96f' removed the code to fetch the nodeset from the
CpusetMems cgroup for a running vm in favor of using the return from
virDomainNumatuneFormatNodeset introduced by commit id '43b67f2e7'.
However, that API will return the value of the passed 'auto_nodeset'
when placement is VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO, which happens
to be NULL.

Since commit id 'c74d58ad' started using priv->autoNodeset in order
to manage the auto placement value during qemuProcessStart, it should
be passed along in order to return the correct value if the domain
requests the auto placement.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit 4eac55238f856d29d07a60448adb2e0b2f8e28b5)

9 years agoClose the source fd if the destination qemu exits during tunnelled migration
Shivaprasad G Bhat [Thu, 8 Oct 2015 12:29:07 +0000 (17:59 +0530)] 
Close the source fd if the destination qemu exits during tunnelled migration

Tunnelled migration can hang if the destination qemu exits despite all the
ABI checks. This happens whenever the destination qemu exits before the
complete transfer is noticed by source qemu. The savevm state checks at
runtime can fail at destination and cause qemu to error out.
The source qemu cant notice it as the EPIPE is not propogated to it.
The qemuMigrationIOFunc() notices the stream being broken from virStreamSend()
and it cleans up the stream alone. The qemuMigrationWaitForCompletion() would
never get to 100% transfer completion.
The qemuMigrationWaitForCompletion() never breaks out as well since
the ssh connection to destination is healthy, and the source qemu also thinks
the migration is ongoing as the Fd to which it transfers, is never
closed or broken. So, the migration will hang forever. Even Ctrl-C on the
virsh migrate wouldn't be honoured. Close the source side FD when there is
an error in the stream. That way, the source qemu updates itself and
qemuMigrationWaitForCompletion() notices the failure.

Close the FD for all kinds of errors to be sure. The error message is not
copied for EPIPE so that the destination error is copied instead later.

Note:
Reproducible with repeated migrations between Power hosts running in different
subcores-per-core modes.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
(cherry picked from commit b39a1fe1656ee4be0d244466b474cad7ada100c8)

9 years agostorage: Fix incorrect format for <disk> <auth> XML
John Ferlan [Wed, 23 Sep 2015 20:28:30 +0000 (16:28 -0400)] 
storage: Fix incorrect format for <disk> <auth> XML

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

After creating a copy of the 'authdef' in a pool -> disk translation,
unconditionally clear the 'authType' in the resulting disk auth def
structure since that's used for a storage pool and not a disk.  This
ensures virStorageAuthDefFormat will properly format the <auth> XML
for a <disk> (e.g. it won't have a <auth type='%s'.../>).

(cherry picked from commit 5275c0f4a1267c630b5c3b77fac8cbe4fcaa3adb)

9 years agovirt-host-validate: distinguish exists vs accessible for devices
Daniel P. Berrange [Wed, 7 Oct 2015 16:02:31 +0000 (17:02 +0100)] 
virt-host-validate: distinguish exists vs accessible for devices

Currently we just check that various devices are accessible.
This leads to inaccurate errors reported for /dev/kvm and
/dev/vhost-net if they exist but an unprivileged user lacks
access. Switch existing checks to look for file existance,
and add a separate check for accessibility of /dev/kvm
since some distros don't grant users access by default.

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

9 years agospec: Delete .git after applying patches
Cole Robinson [Tue, 6 Oct 2015 19:54:47 +0000 (15:54 -0400)] 
spec: Delete .git after applying patches

I'm hitting this little annoyance in fedora's package repo:

$ fedpkg prep
Downloading libvirt-1.2.20.tar.gz
...
+ /usr/bin/gzip -dc /home/crobinso/src/fedora/libvirt/libvirt-1.2.20.tar.gz
$ git clean -xdf
Removing libvirt-1.2.20.tar.gz
Skipping repository libvirt-1.2.20/

We git-ify the libvirt directory as part of applying patches in the spec
file, but 'git clean' will ignore subfolders that appear to be standalone
git repos.

Let's just delete the .git directory after we're done with it.

(cherry picked from commit 62ff210e5d6542bda3f25ed5e96c5088a840ce1b)

9 years agoapparmor: differentiate between error and unconfined profiles
Cédric Bosdonnat [Tue, 6 Oct 2015 09:12:29 +0000 (11:12 +0200)] 
apparmor: differentiate between error and unconfined profiles

profile_status function was not making any difference between error
cases and unconfined profiles. The problem with this approach is that
dominfo was throwing an error on unconfined domains.

(cherry picked from commit a1bdf04b27f8f28b6e96ecd10de2a8e78d80271f)

9 years agostorage: Adjust calculation of alloc/capacity for disk
John Ferlan [Thu, 1 Oct 2015 15:37:17 +0000 (11:37 -0400)] 
storage: Adjust calculation of alloc/capacity for disk

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

Calculation of the extended and logical partition values for the disk
pool is complex. As the bz points out an extended partition should have
it's allocation initialized to 0 (zero) and keep the capacity as the size
dictated by the extents read.  Then for each logical partition found,
adjust the allocation of the extended partition.

Finally, previous logic tried to avoid recalculating things if a logical
partition was deleted; however, since we now have special logic to handle
the allocation of the extended partition, just make life easier by reading
the partition table again - rather than doing the reverse adjustment.

(cherry picked from commit 1895b42114c932495c2242d6847e47c054955998)

9 years agoqemu: Add conditions for qemu-kvm use on ppc64
Andrea Bolognani [Wed, 30 Sep 2015 15:58:58 +0000 (11:58 -0400)] 
qemu: Add conditions for qemu-kvm use on ppc64

qemu-kvm can be used to run ppc64 guests on ppc64le hosts and vice
versa, since the hardware is actually the same and the endianness
is chosen by the guest kernel.

Up until now, however, libvirt didn't allow the use of qemu-kvm
to run guests if their endianness didn't match the host's.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1267882
(cherry picked from commit 938368f8382ca94c5156c44ad85a06cf9e4f8f8f)

9 years agorpc: libssh2: Fix regression in ssh host key verification
Peter Krempa [Fri, 2 Oct 2015 13:49:01 +0000 (15:49 +0200)] 
rpc: libssh2: Fix regression in ssh host key verification

Commit 792f81a40e caused a regression in the libssh2 host key
verification code by changing the variable type of 'i' to unsigned.
Since one of the loops used -1 as a special value if the asking
callback was found the conversion made a subsequent test always fail.

The bug was stealth enough to pass review, compilers and coverity.

Refactor the condition to avoid problems.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1047861
(cherry picked from commit 9869f24d08af1f0d5f45175117953704064556c2)

9 years agorpc: libssh2: Add more debugging info
Peter Krempa [Fri, 2 Oct 2015 13:48:33 +0000 (15:48 +0200)] 
rpc: libssh2: Add more debugging info

(cherry picked from commit 387c316e11c0adcf7f8ed400019e044b47edf0f9)

9 years agoUpdate pool allocation with new values on volume creation
Ján Tomko [Thu, 24 Sep 2015 15:01:40 +0000 (17:01 +0200)] 
Update pool allocation with new values on volume creation

Since commit e0139e3, we update the pool allocation with
the user-provided allocation values.

For qcow2, the allocation is ignored for volume building,
but we still subtracted it from pool's allocation.
This can result in interesting values if the user-provided
allocation is large enough:

Capacity:       104.71 GiB
Allocation:     109.13 GiB
Available:      16.00 EiB

We already do a VolRefresh on volume creation. Also refresh
the volume after creating and use the new value to update the pool.

https://bugzilla.redhat.com/show_bug.cgi?id=1163091
(cherry picked from commit 56a4e9cb613aff9cd6f828c0a9283fba55ac5951)

9 years agoUse daemon log facility for journald
Guido Günther [Mon, 21 Sep 2015 18:06:55 +0000 (20:06 +0200)] 
Use daemon log facility for journald

otherwise messages end up in /var/log/kern.log if journald forwards to
syslog.

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=799633
(cherry picked from commit fd00f0e6c75b00c3d97be8670afcd9094b823855)

9 years agovirDomainCreateXML: Make domain definition transient
Michal Privoznik [Tue, 22 Sep 2015 14:57:52 +0000 (16:57 +0200)] 
virDomainCreateXML: Make domain definition transient

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

So, you want to create a domain from XML. The domain already
exists in libvirt's database of domains. It's okay, because name
and UUID matches. However, on domain startup, internal
representation of the domain is overwritten with your XML even
though we claim that the XML you've provided is a transient one.
The bug is to be found across nearly all the drivers.
Le sigh.

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

9 years agovirDomainCreateXML: Don't remove persistent domains on error
Michal Privoznik [Tue, 22 Sep 2015 14:52:03 +0000 (16:52 +0200)] 
virDomainCreateXML: Don't remove persistent domains on error

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

Okay, so we allow users to 'virsh create' an already existing
domain, providing completely different XML than the one stored in
Libvirt. Well, as long as name and UUID matches. However, in some
drivers the code that handles errors unconditionally removes the
domain that failed to start even though the domain might have
been persistent. Fortunately, the domain is removed just from the
internal list of domains and the config file is kept around.

Steps to reproduce:

1) virsh dumpxml $dom > /tmp/dom.xml
2) change XML so that it is still parse-able but won't boot, e.g.
change guest agent path to /foo/bar
3) virsh create /tmp/dom.xml
4) virsh dumpxml $dom
5) Observe "No such domain" error

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

9 years agoqemu: Refresh memory size only on fresh starts
Peter Krempa [Wed, 23 Sep 2015 12:19:06 +0000 (14:19 +0200)] 
qemu: Refresh memory size only on fresh starts

Qemu unfortunately doesn't update internal state right after migration
and so the actual balloon size as returned by 'query-balloon' are
invalid for a while after the CPUs are started after migration. If we'd
refresh our internal state at this point we would report invalid current
memory size until the next balloon event would arrive.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1242940
(cherry picked from commit d7a0386e229176ec67531aac1412b8a98914da8e)

9 years agodomain: Fix migratable XML with graphics/@listen
Jiri Denemark [Wed, 23 Sep 2015 12:48:06 +0000 (14:48 +0200)] 
domain: Fix migratable XML with graphics/@listen

As of commit 6992994, we set graphics/@listen attribute according to the
first listen child element even if that element is of type='network'.
This was done for backward compatibility with applications which only
support the original listen attribute. However, by doing so we broke
migration to older libvirt which tried to check that the listen
attribute matches one of the listen child elements but which did not
take type='network' elements into account.

We are not concerned about compatibility with old applications when
formatting domain XML for migration for two reasons. The XML is consumed
only by libvirtd and the IP address associated with type='network'
listen address on the source host is just useless on the destination
host. Thus, we can safely avoid propagating the type='network' IP
address to graphics/@listen attribute when creating migratable XML.

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

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

9 years agotpm: adapt sysfs cancel path for new TPM driver
Stefan Berger [Wed, 18 Nov 2015 00:44:13 +0000 (19:44 -0500)] 
tpm: adapt sysfs cancel path for new TPM driver

This patch addresses BZ 1244895.

Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths and check their availability.

Add a mockup for the test cases to avoid the testing for
availability of the cancel path.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
(cherry picked from commit 5ed7afa9de4e8d2b7e83fee334a0c3f2bddc6a48)

9 years agolibvirt-guests: Disable shutdown timeout
Guido Günther [Tue, 17 Nov 2015 07:39:46 +0000 (08:39 +0100)] 
libvirt-guests: Disable shutdown timeout

Since we can't know at service start how many VMs will be running we
can't calculate an apropriate shutdown timeout. So instead of killing
off the service just let it use it's own internal timeout mechanism.

References:
    http://bugs.debian.org/803714
    https://bugzilla.redhat.com/show_bug.cgi?id=1195544

(cherry picked from commit ba08d16d6cec81656b333435650aef36a012034c)

9 years agosystemd: Escape only needed characters for machined
Martin Kletzander [Fri, 27 Nov 2015 13:24:38 +0000 (14:24 +0100)] 
systemd: Escape only needed characters for machined

Machine name escaping follows the same rules as serice name escape,
except that '.' and '-' must not be escaped in machine names, due
to a bug in systemd-machined.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 0e0149ce91d84f40b98acf4c4bb0da6e29b9c15c)

9 years agosystemd: Escape machine name for machined
Martin Kletzander [Tue, 24 Nov 2015 14:56:12 +0000 (15:56 +0100)] 
systemd: Escape machine name for machined

According to the documentation, CreateMachine accepts only 7bit ASCII
characters in the machinename parameter, so let's make sure we can start
machines with unicode names with systemd.  We already have a function
for that, we just forgot to use it.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit e24eda48cfae84a9003456b68eaf753a26123639)

9 years agoCVE-2015-5313: storage: don't allow '/' in filesystem volume names
Eric Blake [Wed, 9 Dec 2015 00:46:31 +0000 (17:46 -0700)] 
CVE-2015-5313: storage: don't allow '/' in filesystem volume names

The libvirt file system storage driver determines what file to
act on by concatenating the pool location with the volume name.
If a user is able to pick names like "../../../etc/passwd", then
they can escape the bounds of the pool.  For that matter,
virStoragePoolListVolumes() doesn't descend into subdirectories,
so a user really shouldn't use a name with a slash.

Normally, only privileged users can coerce libvirt into creating
or opening existing files using the virStorageVol APIs; and such
users already have full privilege to create any domain XML (so it
is not an escalation of privilege).  But in the case of
fine-grained ACLs, it is feasible that a user can be granted
storage_vol:create but not domain:write, and it violates
assumptions if such a user can abuse libvirt to access files
outside of the storage pool.

Therefore, prevent all use of volume names that contain "/",
whether or not such a name is actually attempting to escape the
pool.

This changes things from:

$ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
Vol ../../../../../../etc/haha created
$ rm /etc/haha

to:

$ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
error: Failed to create vol ../../../../../../etc/haha
error: Requested operation is not valid: volume name '../../../../../../etc/haha' cannot contain '/'

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

9 years agodocs: event impl. registration before hypervisor connection
Dominik Perpeet [Fri, 25 Sep 2015 08:54:21 +0000 (10:54 +0200)] 
docs: event impl. registration before hypervisor connection

Event implementations need to be registered before a connection to the
Hypervisor is opened, otherwise event handling can be impaired (e.g.
delayed messages). This fact is referenced in an e-mail [1], but should
also be noted in the documentation of the registration functions.

[1] https://www.redhat.com/archives/libvirt-users/2014-April/msg00011.html

(cherry picked from commit 9bf1cef7371b119cf1ad1e83daaa9cd0da893352)

9 years agospec: Fix some warnings with latest rpmbuild
Cole Robinson [Tue, 22 Sep 2015 19:56:50 +0000 (15:56 -0400)] 
spec: Fix some warnings with latest rpmbuild

$ rpmbuild -ba libvirt.spec
warning: Macro expanded in comment on line 5: # If neither fedora nor rhel was defined, try to guess them from %{dist}

warning: Macro %enable_autotools defined but not used within scope
warning: Macro %client_only defined but not used within scope
...

(cherry picked from commit dae1250b24404f7f21e7bd8aeeb304565d175de4)

9 years agoqemu: Fix dynamic_ownership qemu.conf setting
Cole Robinson [Mon, 28 Sep 2015 23:47:09 +0000 (19:47 -0400)] 
qemu: Fix dynamic_ownership qemu.conf setting

Commit 307fb904 (Sep 10) added a 'privileged' variable when creating
the DAC driver:

@@ -153,6 +157,7 @@ virSecurityManagerNewDAC(const char *virtDriver,
                          bool defaultConfined,
                          bool requireConfined,
                          bool dynamicOwnership,
+                         bool privileged,
                          virSecurityManagerDACChownCallback chownCallback)

But argument order is mixed up at the caller, swapping dynamicOwnership
and privileged values. This corrects the argument order

https://bugzilla.redhat.com/show_bug.cgi?id=1266628
(cherry picked from commit 68572de8228e3971174a83c227fcb018d6f684c7)

9 years agoPrep for release 1.2.18.1 v1.2.18.1
Cole Robinson [Tue, 22 Sep 2015 00:54:37 +0000 (20:54 -0400)] 
Prep for release 1.2.18.1

9 years agotest driver: don't unlock pool after freeing it
David Mansfield [Thu, 17 Sep 2015 12:59:24 +0000 (08:59 -0400)] 
test driver: don't unlock pool after freeing it

 Invalid read of size 4
    at 0x945CA30: __pthread_mutex_unlock_full (in /lib64/libpthread-2.20.so)
    by 0x4F0404B: virMutexUnlock (virthread.c:94)
    by 0x4F7161B: virStoragePoolObjUnlock (storage_conf.c:2603)
    by 0x4FE0476: testStoragePoolUndefine (test_driver.c:4328)
    by 0x4FCF086: virStoragePoolUndefine (libvirt-storage.c:656)
    by 0x15A7F5: cmdPoolUndefine (virsh-pool.c:1721)
    by 0x12F48D: vshCommandRun (vsh.c:1212)
    by 0x132AA7: main (virsh.c:943)
  Address 0xfda56a0 is 16 bytes inside a block of size 104 free'd
    at 0x4C2BA6C: free (vg_replace_malloc.c:473)
    by 0x4EA5C96: virFree (viralloc.c:582)
    by 0x4F70B69: virStoragePoolObjFree (storage_conf.c:412)
    by 0x4F7167B: virStoragePoolObjRemove (storage_conf.c:437)
    by 0x4FE0468: testStoragePoolUndefine (test_driver.c:4323)
    by 0x4FCF086: virStoragePoolUndefine (libvirt-storage.c:656)
    by 0x15A7F5: cmdPoolUndefine (virsh-pool.c:1721)
    by 0x12F48D: vshCommandRun (vsh.c:1212)
    by 0x132AA7: main (virsh.c:943)

(cherry picked from commit 03cf57a37df750da46289b0f8aeac6463d521785)

9 years agolibxl: fix AttachDeviceConfig on hostdev type
Chunyan Liu [Thu, 17 Sep 2015 05:15:22 +0000 (01:15 -0400)] 
libxl: fix AttachDeviceConfig on hostdev type

After attach-device a <hostdev> with --config, new device doesn't
show up in dumpxml and in guest.

To fix that, set dev->data.hostdev = NULL after work so that the
pointer is not freed, since vmdef has the pointer and still need it.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
(cherry picked from commit 56945e1374bd254148643d76a98fba9be67fba15)

9 years agosecurity_selinux: Take @privileged into account
Michal Privoznik [Thu, 10 Sep 2015 11:27:28 +0000 (13:27 +0200)] 
security_selinux: Take @privileged into account

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

If running in session mode it may happen that we fail to set
correct SELinux label, but the image may still be readable to
the qemu process. Take this into account.

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

9 years agoselinux: fix compile errors
Guido Günther [Mon, 24 Aug 2015 12:04:37 +0000 (14:04 +0200)] 
selinux: fix compile errors

Remove unused variable, tag unused parameter and adjust return type.

introduced by 3f48345f7ec0c44b8ce2371cab454d2118f830b4

CC     security/libvirt_security_manager_la-security_selinux.lo
security/security_selinux.c: In function 'virSecuritySELinuxDomainSetDirLabel':
security/security_selinux.c:2520:5: error: return makes pointer from integer without a cast [-Werror]
security/security_selinux.c:2514:9: error: unused variable 'ret' [-Werror=unused-variable]
security/security_selinux.c:2509:59: error: unused parameter 'mgr' [-Werror=unused-parameter]

(cherry picked from commit 4d4c90dfd5475c100c6fd3fb705011e0d90d793e)

9 years agosecurity_selinux: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:07:07 +0000 (11:07 -0700)] 
security_selinux: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 3f48345f7ec0c44b8ce2371cab454d2118f830b4)

9 years agosecurity: Add virSecurityDomainSetDirLabel
Martin Kletzander [Mon, 17 Aug 2015 17:43:43 +0000 (10:43 -0700)] 
security: Add virSecurityDomainSetDirLabel

That function can be used for setting security labels on arbitrary
directories.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit f65a2a12f4b9ab6144a979774f0486cdc4f7a60a)

9 years agosecurity_selinux: Use proper structure to access socket data
Martin Kletzander [Thu, 13 Aug 2015 05:35:10 +0000 (07:35 +0200)] 
security_selinux: Use proper structure to access socket data

In virSecuritySELinuxSetSecurityChardevLabel() we are labelling unix
socket path, but accessing another structure of the union.  This does
not pose a problem currently as both paths are at the same offset, but
this should be fixed for the future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 4ac6ce38d3bc60f45491509ede4fc8437348048c)

9 years agosecurity_selinux: Replace SELinuxSCSICallbackData with proper struct
Michal Privoznik [Thu, 10 Sep 2015 11:49:18 +0000 (13:49 +0200)] 
security_selinux: Replace SELinuxSCSICallbackData with proper struct

We have plenty of callbacks in the driver. Some of these
callbacks require more than one argument to be passed. For that
we currently have a data type (struct) per each callback. Well,
so far for only one - SELinuxSCSICallbackData. But lets turn it
into more general name so it can be reused in other callbacks too
instead of each one introducing a new, duplicate data type.

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

9 years agovirSecuritySELinuxSetSecurityAllLabel: drop useless virFileIsSharedFSType
Michal Privoznik [Thu, 10 Sep 2015 11:29:36 +0000 (13:29 +0200)] 
virSecuritySELinuxSetSecurityAllLabel: drop useless virFileIsSharedFSType

The check is done in virSecuritySELinuxSetFilecon itself. There's
no need to check it again.

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

9 years agovirSecurityManager: Track if running as privileged
Michal Privoznik [Thu, 10 Sep 2015 09:43:31 +0000 (11:43 +0200)] 
virSecurityManager: Track if running as privileged

We may want to do some decisions in drivers based on fact if we
are running as privileged user or not. Propagate this info there.

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

9 years agoqemu: hotplug: Properly clean up drive backend if frontend hotplug fails
Peter Krempa [Fri, 11 Sep 2015 15:34:18 +0000 (17:34 +0200)] 
qemu: hotplug: Properly clean up drive backend if frontend hotplug fails

Commit 8125113c added code that should remove the disk backend if the
fronted hotplug failed for any reason. The code had a bug though as it
used the disk string for unplug rather than the backend alias. Fix the
code by pre-creating an alias string and using it instead of the disk
string. In cases where qemu does not support QEMU_CAPS_DEVICE, we ignore
the unplug of the backend since we can't really create an alias in that
case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1262399
(cherry picked from commit 64c6695f1ad72f0a99faace5deb1caf7effa2275)

9 years agoxen: fix race in refresh of config cache
Daniel P. Berrange [Fri, 11 Sep 2015 13:15:50 +0000 (14:15 +0100)] 
xen: fix race in refresh of config cache

The xenXMConfigCacheRefresh method scans /etc/xen and loads
all config files it finds. It then scans its internal hash
table and purges any (previously) loaded config files whose
refresh timestamp does not match the timestamp recorded at
the start of xenXMConfigCacheRefresh(). There is unfortunately
a subtle flaw in this, because if loading the config files
takes longer than 1 second, some of the config files will
have a refresh timestamp that is 1 or more seconds different
(newer) than is checked for. So we immediately purge a bunch
of valid config files we just loaded.

To avoid this flaw, we must pass the timestamp we record at
the start of xenXMConfigCacheRefresh() into the
xenXMConfigCacheAddFile() method, instead of letting the
latter call time(NULL) again.

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

9 years agolibxl: don't end job for ephemeal domain on start failure
Ian Campbell [Thu, 10 Sep 2015 15:45:07 +0000 (16:45 +0100)] 
libxl: don't end job for ephemeal domain on start failure

commit 4b53d0d4ac9c "libxl: don't remove persistent domain on start
failure" cleans up the vm object and sets it to NULL if the vm is not
persistent, however at end job vm (now NULL) is dereferenced via the call to
libxlDomainObjEndJob. Avoid this by skipping "endjob" and going
straight to "cleanup" in this case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
(cherry picked from commit ee7758f09bad855f5d0fdf9804d8979cdbbff40e)

9 years agoconf: fix crash when parsing a unordered NUMA <cell/>
Luyao Huang [Tue, 8 Sep 2015 04:59:10 +0000 (12:59 +0800)] 
conf: fix crash when parsing a unordered NUMA <cell/>

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

Introduced by 8fedbbdb, if we parse an unordered NUMA cell, will
get a segfault. This is because of a check for overlapping @cpus
sets we have there. However, since the array to hold guest NUMA
cells is allocated upfront and therefore it contains all zeros,
an out of order cell will break our assumption that cell IDs have
increasing character. At this point we try to access yet NULL
bitmap and therefore segfault.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit 83ae3ee39bd13feddecc49aaad382d5cae72c257)

9 years agoqemu: Check virGetLastError return value for migration finish failure
John Ferlan [Tue, 1 Sep 2015 10:47:55 +0000 (06:47 -0400)] 
qemu: Check virGetLastError return value for migration finish failure

Commit id '2e7cea243' added a check for an error from Finish instead
of 'unexpected error'; however, if for some reason there wasn't an
error, then virGetLastError could return NULL resulting in the
NULL pointer deref to err->domain.

(cherry picked from commit ea3c5f25eb94f08d2a54385362c7ad60c6b1854e)

9 years agolibxl: don't overwrite error from virNetSocketNewConnectTCP()
Jim Fehlig [Thu, 3 Sep 2015 16:14:20 +0000 (10:14 -0600)] 
libxl: don't overwrite error from virNetSocketNewConnectTCP()

Remove redundant error reporting in libxlDomainMigrationPerform().
virNetSocketNewConnectTCP() is perfectly capable of reporting
sensible errors.

(cherry picked from commit 6ce939c2472e8cd97dfe448e902bc878c826351e)

9 years agodomain-conf: escape string for socket attribute
Pavel Hrdina [Mon, 31 Aug 2015 13:33:49 +0000 (15:33 +0200)] 
domain-conf: escape string for socket attribute

Commit d091518b tried to escape all strings in produced XML, but missed
this one.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit e92e5ba12825b32ccc929a527077fb7019c87d1b)

9 years agosrc: Check for symbols ordering in ADMIN_SYM_FILES
Michal Privoznik [Mon, 31 Aug 2015 10:45:16 +0000 (12:45 +0200)] 
src: Check for symbols ordering in ADMIN_SYM_FILES

Like we are checking for the correct order in SYM_FILES, we
should do the same for ADMIN_SYM_FILES.

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

9 years agosrc: Cleanup libvirt_admin.syms
Michal Privoznik [Mon, 31 Aug 2015 09:37:45 +0000 (11:37 +0200)] 
src: Cleanup libvirt_admin.syms

It's a generated file, so after 'distclean' it should be gone.
But it isn't yet.

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

9 years agosrc: Check libvirt_admin.syms for exported symbols
Michal Privoznik [Mon, 31 Aug 2015 09:35:46 +0000 (11:35 +0200)] 
src: Check libvirt_admin.syms for exported symbols

We have this check rule in src/Makefile: check-symfile that
should check if all symbols we wanted to export are exported.
Moreover, if we are not exporting something more. Do the same
with libvirt_admin.syms.

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

9 years agoutil: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails
Laine Stump [Wed, 26 Aug 2015 03:19:03 +0000 (23:19 -0400)] 
util: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails

commit 09778e09 switched from using ioctl(SIOCBRDELBR) for bridge
device deletion to using a netlink RTM_DELLINK message, which is the
more modern way to delete a bridge (and also doesn't require the
bridge to be ~IFF_UP to succeed). However, although older kernels
(e.g. 2.6.32, in RHEL6/CentOS6) support deleting *some* link types
with RTM_NEWLINK, they don't support deleting bridges, and there is no
compile-time way to figure this out.

This patch moves the body of the SIOCBRDELBR version of
virNetDevBridgeDelete() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_DELLINK version if the RTM_DELLINK message generates an EOPNOTSUPP
error. Since RTM_DELLINK is done from the subordinate function
virNetlinkDelLink, which is also called for other purposes (deleting a
macvtap interface), a function pointer called "fallback" has been
added to the arglist of virNetlinkDelLink() - if that arg != NULL, the
provided function will be called when (and only when) RTM_DELLINK
fails with EOPNOTSUPP.

Resolves:  https://bugzilla.redhat.com/show_bug.cgi?id=1252780 (part 2)
(cherry picked from commit 97d26e470d5be2f1178cedfea212c5983afd7b30)

9 years agoutil: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails
Laine Stump [Wed, 26 Aug 2015 00:48:19 +0000 (20:48 -0400)] 
util: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails

commit fc7b23db switched from using ioctl(SIOCBRADDBR) for bridge
creation to using a netlink RTM_NEWLINK message with IFLA_INFO_KIND =
"bridge", which is the more modern way to create a bridge. However,
although older kernels (e.g. 2.6.32, in RHEL6/CentOS6) support
creating *some* link types with RTM_NEWLINK, they don't support
creating bridges, and there is no compile-time way to figure this out
(since the "type" isn't an enum, but rather a character string).

This patch moves the body of the SIOCBRADDBR version of
virNetDevBridgeCreate() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_NEWLINK version if the RTM_NEWLINK message generates an EOPNOTSUPP
error.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1252780
(cherry picked from commit 66dcb4093750aabd637607a1202cb9b9c15f1298)

9 years agolibxl: acquire a job when receiving a migrating domain
Jim Fehlig [Thu, 16 Jul 2015 18:24:32 +0000 (12:24 -0600)] 
libxl: acquire a job when receiving a migrating domain

Commit f86ae403 moved acquiring a job from libxlDomainStart()
to its callers. One spot missed was in libxlDoMigrateReceive().
Acquire a job in libxlDoMigrateReceive() before calling
libxlDomainStart().

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit e80b84a74324cd535ec7232c4e1653805af2103a)

9 years agolibxl: don't attempt to resume domain when suspend fails
Jim Fehlig [Wed, 15 Jul 2015 23:29:15 +0000 (17:29 -0600)] 
libxl: don't attempt to resume domain when suspend fails

Failure of libxl_domain_suspend() does not leave the domain in
a suspended state, so no need to call libxl_domain_resume(),
which btw will fail with "domain not suspended".

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit 15120b8c61014a9263cb53314076da9a44e39621)

9 years agolibxl: fix ref counting of libxlMigrationDstArgs
Jim Fehlig [Wed, 15 Jul 2015 22:35:50 +0000 (16:35 -0600)] 
libxl: fix ref counting of libxlMigrationDstArgs

This patch fixes some flawed logic around ref counting the
libxlMigrationDstArgs object.

First, when adding sockets to the event loop with
virNetSocketAddIOCallback(), the generic virObjectFreeCallback()
was registered as a free function, with libxlMigrationDstArgs as
its parameter. A reference was also taken on
libxlMigrationDstArgs for each successful call to
virNetSocketAddIOCallback(). The rational behind this logic was
that the libxlMigrationDstArgs object had to out-live the socket
objects. But virNetSocketAddIOCallback() already takes a
reference on socket objects, ensuring their life until removed
from the event loop and unref'ed in virNetSocketEventFree(). We
only need to ensure libxlMigrationDstArgs lives until
libxlDoMigrateReceive() finishes, which can be done by simply
unref'ing libxlMigrationDstArgs at the end of
libxlDoMigrateReceive().

The second flaw was unref'ing the sockets in the failure path of
libxlMigrateReceive() and at the end of libxlDoMigrateReceive().
As mentioned above, the sockets are already unref'ed by
virNetSocketEventFree() when removed from the event loop.
Attempting to unref the socket a second time resulted in a
libvirtd crash since the socket was previously unref'ed and
disposed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit 44a54eb073d2ae52ebf1661ae73bb1f0f98599f9)

9 years agolibvirt_lxc: Claim success for --help
Michal Privoznik [Thu, 27 Aug 2015 00:21:54 +0000 (02:21 +0200)] 
libvirt_lxc: Claim success for --help

So far, if libvirt_lxc binary (usually to be found under
/usr/libexec/) is run with --help, due to a missing line
and our usual functions pattern, an 'uknown' error is returned.
Yeah, the help is printed out, but we should not claim error.

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

9 years agovirt-aa-helper: Improve valid_path
Michal Privoznik [Thu, 27 Aug 2015 00:50:21 +0000 (02:50 +0200)] 
virt-aa-helper: Improve valid_path

So, after some movement in virt-aa-helper, I've noticed the
virt-aa-helper-test failing. I've ran gdb (it took me a while to
realize how to do that) and this showed up immediately:

  Program received signal SIGSEGV, Segmentation fault.
  strlen () at ../sysdeps/x86_64/strlen.S:106
  106     ../sysdeps/x86_64/strlen.S: No such file or directory.
  (gdb) bt
  #0  strlen () at ../sysdeps/x86_64/strlen.S:106
  #1  0x0000555555561a13 in array_starts_with (str=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", arr=0x7fffffffd160, size=-1540438016) at security/virt-aa-helper.c:525
  #2  0x0000555555561d49 in valid_path (path=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", readonly=false) at security/virt-aa-helper.c:617
  #3  0x0000555555562506 in vah_add_path (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw", recursive=false) at security/virt-aa-helper.c:823
  #4  0x0000555555562693 in vah_add_file (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw") at security/virt-aa-helper.c:854
  #5  0x0000555555562918 in add_file_path (disk=0x5555557d4440, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", depth=0, opaque=0x7fffffffd3e0) at security/virt-aa-helper.c:931
  #6  0x00007ffff78f18b1 in virDomainDiskDefForeachPath (disk=0x5555557d4440, ignoreOpenFailure=true, iter=0x5555555628a6 <add_file_path>, opaque=0x7fffffffd3e0) at conf/domain_conf.c:23286
  #7  0x0000555555562b5f in get_files (ctl=0x7fffffffd670) at security/virt-aa-helper.c:982
  #8  0x0000555555564100 in vahParseArgv (ctl=0x7fffffffd670, argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1277
  #9  0x00005555555643d6 in main (argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1332

So I've taken look at valid_path() because it is obviously
calling array_starts_with() with malformed @size. And here's the
result: there are two variables to hold the size of three arrays
and their value is recalculated before each call of
array_starts_with(). What if we just use three variables,
initialize them and do not touch them afterwards?

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

9 years agoqemu: Emit correct audit message for memory hot unplug
Luyao Huang [Thu, 13 Aug 2015 14:15:28 +0000 (22:15 +0800)] 
qemu: Emit correct audit message for memory hot unplug

https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3

If the qemu monitor fails to remove the memory from the guest for
any reason, the auditlog message will incorrectly use the current
actual memory (via virDomainDefGetMemoryActual) instead of the
value we were attempting to reduce to. The result is the 'new-mem'
and 'old-mem' values for the auditlog message would be identical.

This patch creates a local 'newmem' which accounts for the current
memory size minus the memory which is being removed. NB, for the
success case this results in the same value that would be returned
by virDomainDefGetMemoryActual without the need to do the math. This
follows the existing code which would subtract the size for cur_balloon.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit 8f8031df1998725ac34a9a3138705c4f7cdf0488)

9 years agoqemu: Emit correct audit message for memory hot plug
Luyao Huang [Thu, 13 Aug 2015 14:15:27 +0000 (22:15 +0800)] 
qemu: Emit correct audit message for memory hot plug

https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3

Prior to this patch, after successfully hot plugging memory
the audit log indicated that the update failed, e.g.:

type=VIRT_RESOURCE ... old-mem=1024000 new-mem=1548288 \
exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=pts/2 res=failed

This patch will adjust where virDomainAuditMemory is called to
ensure the proper 'ret' value is used based on success or failure.

Additionally, the audit message should include the size of the
memory we were attempting to change to rather than the current
actual size. On failure to add, the message showed the same value
for old-mem and new-mem.

In order to do this, introduce a 'newmem' local which will compute
the new size based on the oldmem size plus the size of memory we
are about to add. NB: This would be the same as calling the
virDomainDefGetMemoryActual again on success, but avoids the
overhead of recalculating. Plus cur_balloon is already adjusted
by the same value, so this follows that.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit cb1fbda4a1b23581ed9e305a48b0376633d5ff4a)

9 years agohostdev: skip ACS check when using VFIO for device assignment
Laine Stump [Wed, 26 Aug 2015 06:04:23 +0000 (02:04 -0400)] 
hostdev: skip ACS check when using VFIO for device assignment

The ACS checks are meaningless when using the more modern VFIO driver
for device assignment since VFIO has its own more complete and exact
checks, but I didn't realize that when I added support for VFIO. This
patch eliminates the ACS check when preparing PCI devices for
assignment if VFIO is being used.

This resolves:

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

(cherry picked from commit 108d591b1144bc6cb5d1199f6fc23ee972b76e86)

9 years agoStart daemon only after filesystems are mounted
Martin Kletzander [Tue, 25 Aug 2015 15:07:46 +0000 (17:07 +0200)] 
Start daemon only after filesystems are mounted

When images are on mounted filesystems, there is no guarantee libvirtd
will start before they are mounted.  Since we want to start after both
local and remote filesystems are mounted, we need to add both local-fs
and remote-fs as targets that should precede starting libvirtd service.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 3418e7815a9fc9245aa6476415a353790ed3cb8b)

9 years agovirt-aa-helper: add NVRAM store file for read/write
Peter Kieser [Thu, 20 Aug 2015 17:58:59 +0000 (10:58 -0700)] 
virt-aa-helper: add NVRAM store file for read/write

This is a cryptographically signed message in MIME format.

Some UEFI firmwares may want to use a non-volatile memory to store some
variables.
If AppArmor is enabled, and NVRAM store file is set currently
virt-aa-helper does
not add the NVRAM store file to the template. Add this file for
read/write when
this functionality is defined in domain XML.

Signed-off-by: Peter Kieser <peter@kieser.ca>
(cherry picked from commit 91fdcefa7f145c1c39acc8e9a44fbfbf11568e54)

9 years agoqemu: Update blkio.weight value after successful set
Luyao Huang [Wed, 19 Aug 2015 03:56:33 +0000 (11:56 +0800)] 
qemu: Update blkio.weight value after successful set

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

Make a call virCgroupGetBlkioWeight to re-read blkio.weight right
after it is set in order to keep internal data up-to-date.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit bf2788218ad29719467260aa4ecad6dc31c97046)

9 years agoEliminate incorrect and unnecessary check for changed IP address
Vasiliy Tolstov [Sat, 22 Aug 2015 15:33:15 +0000 (15:33 +0000)] 
Eliminate incorrect and unnecessary check for changed IP address

Commit aa2cc7 modified a previously unnecessary but innocuous check
for interface IP address during interface update incorrectly, causing
all attempted updates (e.g. changing link state) to interfaces of
type='ethernet' for QEMU to fail.

This patch fixes the issue by completely removing the check for IP
address, which is pointless since QEMU doesn't support setting
interface IP addresses from the domain interface XML anyway.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Signed-off-by: Laine Stump <laine@laine.org>
(cherry picked from commit bbc705d1309b8ec2eb4cdae011dc702802c96d11)