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

CVE-2016-5008

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

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

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

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 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 agorpc: ensure daemon is spawn even if dead socket exists
Daniel P. Berrange [Fri, 3 Jul 2015 15:51:56 +0000 (16:51 +0100)] 
rpc: ensure daemon is spawn even if dead socket exists

The auto-spawn code would originally attempt to spawn the
daemon for both ENOENT and ECONNREFUSED errors from connect().
The various refactorings eventually lost this so we only
spawn the daemon on ENOENT. The result is if the daemon exits
uncleanly, so that the socket is left in the filesystem, we
will never be able to auto-spawn the daemon again.

(cherry picked from commit 406ee8c226d2197ba1aaecb9cf3ad2b6df31ae44)

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.13.2 v1.2.13.2
Cole Robinson [Wed, 23 Dec 2015 23:34:35 +0000 (18:34 -0500)] 
Prep for release 1.2.13.2

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 agoqemu: block-commit: Mark disk in block jobs only on successful command
Peter Krempa [Mon, 16 Mar 2015 15:52:44 +0000 (16:52 +0100)] 
qemu: block-commit: Mark disk in block jobs only on successful command

Patch 51f9f03a4ca50b070c0fbfb29748d49f583e15e1 introduces a regression
where if a blockCommit operation fails the disk is still marked as being
part of a block job but can't be unmarked later.

(cherry picked from commit ee744b5b387b5123ee40683c52ab40783ffc3020)

9 years agoqemu: Disallow concurrent block jobs on a single disk
Peter Krempa [Fri, 13 Mar 2015 16:22:04 +0000 (17:22 +0100)] 
qemu: Disallow concurrent block jobs on a single disk

While qemu may be prepared to do this libvirt is not. Forbid the block
ops until we fix our code.

(cherry picked from commit 51f9f03a4ca50b070c0fbfb29748d49f583e15e1)

9 years agoqemu: event: Don't fiddle with disk backing trees without a job
Peter Krempa [Fri, 13 Mar 2015 16:00:03 +0000 (17:00 +0100)] 
qemu: event: Don't fiddle with disk backing trees without a job

Surprisingly we did not grab a VM job when a block job finished and we'd
happily rewrite the backing chain data. This made it possible to crash
libvirt when queueing two backing chains tightly and other badness.

To fix it, add yet another handler to the helper thread that handles
monitor events that require a job.

(cherry picked from commit 1a92c719101e5bfa6fe2b78006ad04c7f075ea28)

9 years agoqemu: process: Export qemuProcessFindDomainDiskByAlias
Peter Krempa [Fri, 13 Mar 2015 15:59:26 +0000 (16:59 +0100)] 
qemu: process: Export qemuProcessFindDomainDiskByAlias

(cherry picked from commit 5c634730b99b53afd6e2cea4b7d2fc2dfc2ee630)

9 years agospec: Fix polkit dep on F23
Cole Robinson [Tue, 14 Jul 2015 18:42:28 +0000 (14:42 -0400)] 
spec: Fix polkit dep on F23

As of fedora polkit-0.113-2, polkit-devel only pulls in polkit-libs, not
full polkit, but we need the latter for pkcheck otherwise our configure
test fails.

(cherry picked from commit 6600f4f3d84bc07ee344a56d193c0a45ad0b7f7b)

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 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 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 agocgroup: Drop resource partition from virSystemdMakeScopeName
Peter Krempa [Thu, 16 Jul 2015 13:35:05 +0000 (15:35 +0200)] 
cgroup: Drop resource partition from virSystemdMakeScopeName

The scope name, even according to our docs is
"machine-$DRIVER\x2d$VMNAME.scope" virSystemdMakeScopeName would use the
resource partition name instead of "machine-" if it was specified thus
creating invalid scope paths.

This makes libvirt drop cgroups for a VM that uses custom resource
partition upon reconnecting since the detected scope name would not
match the expected name generated by virSystemdMakeScopeName.

The error is exposed by the following log entry:

debug : virCgroupValidateMachineGroup:302 : Name 'machine-qemu\x2dtestvm.scope' for controller 'cpu' does not match 'testvm', 'testvm.libvirt-qemu' or 'machine-test-qemu\x2dtestvm.scope'

for a "/machine/test" resource and "testvm" vm.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1238570
(cherry picked from commit 88f6c007c3fb4324396ec397de57c8a80ba7b31d)

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 agoremoteClientCloseFunc: Don't mangle connection object refcount
Michal Privoznik [Thu, 3 Sep 2015 10:11:53 +0000 (12:11 +0200)] 
remoteClientCloseFunc: Don't mangle connection object refcount

Well, in 8ad126e6 we tried to fix a memory corruption problem.
However, the fix was not as good as it could be. I mean, the
commit has one line more than it should. I've noticed this output
just recently:

  # ./run valgrind --leak-check=full --show-reachable=yes ./tools/virsh domblklist gentoo
  ==17019== Memcheck, a memory error detector
  ==17019== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
  ==17019== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
  ==17019== Command: /home/zippy/work/libvirt/libvirt.git/tools/.libs/virsh domblklist gentoo
  ==17019==
  Target     Source
  ------------------------------------------------
  fda        /var/lib/libvirt/images/fd.img
  vda        /var/lib/libvirt/images/gentoo.qcow2
  hdc        /home/zippy/tmp/install-amd64-minimal-20150402.iso

  ==17019== Thread 2:
  ==17019== Invalid read of size 4
  ==17019==    at 0x4EFF5B4: virObjectUnref (virobject.c:258)
  ==17019==    by 0x5038CFF: remoteClientCloseFunc (remote_driver.c:552)
  ==17019==    by 0x5069D57: virNetClientCloseLocked (virnetclient.c:685)
  ==17019==    by 0x506C848: virNetClientIncomingEvent (virnetclient.c:1852)
  ==17019==    by 0x5082136: virNetSocketEventHandle (virnetsocket.c:1913)
  ==17019==    by 0x4ECD64E: virEventPollDispatchHandles (vireventpoll.c:509)
  ==17019==    by 0x4ECDE02: virEventPollRunOnce (vireventpoll.c:658)
  ==17019==    by 0x4ECBF00: virEventRunDefaultImpl (virevent.c:308)
  ==17019==    by 0x130386: vshEventLoop (vsh.c:1864)
  ==17019==    by 0x4F1EB07: virThreadHelper (virthread.c:206)
  ==17019==    by 0xA8462D3: start_thread (in /lib64/libpthread-2.20.so)
  ==17019==    by 0xAB441FC: clone (in /lib64/libc-2.20.so)
  ==17019==  Address 0x139023f4 is 4 bytes inside a block of size 240 free'd
  ==17019==    at 0x4C2B1F0: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==17019==    by 0x4EA8949: virFree (viralloc.c:582)
  ==17019==    by 0x4EFF6D0: virObjectUnref (virobject.c:273)
  ==17019==    by 0x4FE74D6: virConnectClose (libvirt.c:1390)
  ==17019==    by 0x13342A: virshDeinit (virsh.c:406)
  ==17019==    by 0x134A37: main (virsh.c:950)

The problem is, when registering remoteClientCloseFunc(), it's
conn->closeCallback which is ref'd. But in the function itself
it's conn->closeCallback->conn what is unref'd. This is causing
imbalance in reference counting. Moreover, there's no need for
the remote driver to increase/decrease conn refcount since it's
not used anywhere. It's just merely passed to client registered
callback. And for that purpose it's correctly ref'd in
virConnectRegisterCloseCallback() and then unref'd in
virConnectUnregisterCloseCallback().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit e68930077034f786e219bdb015f8880dbc5a246f)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRevert "LXC: show used memory as 0 when domain is not active"
Jim Fehlig [Mon, 10 Aug 2015 18:49:55 +0000 (12:49 -0600)] 
Revert "LXC: show used memory as 0 when domain is not active"

This reverts commit 1ce7c1d20cfd5afb26d2dbc88201085d52415d0e,
which introduced a significant semantic change to the
virDomainGetInfo() API. Additionally, the change was only
made to 2 of the 15 virt drivers.

Conflicts:
src/qemu/qemu_driver.c

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

10 years agolxc: Don't pass a local variable address randomly
Michal Privoznik [Wed, 1 Jul 2015 15:21:28 +0000 (17:21 +0200)] 
lxc: Don't pass a local variable address randomly

So, recently I was testing the LXC driver. You know, startup some
domains. But to my surprise, I was not able to start a single one:

  virsh # start --console test
  error: Reconnected to the hypervisor
  error: Failed to start domain test
  error: internal error: guest failed to start: unexpected exit status 125

So I've start digging. It turns out, that in virExec(), when I printed
out the @cmd, I got strange values: *(cmd->outfdptr) was certainly not
valid FD number: it has random value of several millions. This
obviously made prepareStdFd(childout, STDOUT_FILENO) fail (line 611).
But outfdptr is set in virCommandSetOutputFD(). The only place within
LXC driver where the function is called is in
virLXCProcessBuildControllerCmd(). If you take a closer look at the
function it looks like this:

static virCommandPtr
virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
                                ..
                                int logfd,
                                const char *pidfile)
{
    ...
    virCommandSetOutputFD(cmd, &logfd);
    virCommandSetErrorFD(cmd, &logfd);
    ...
}

Yes, you guessed it. @logfd is passed into the function by value.
However, in the function we try to get its address (an address of a
local variable) which is no longer valid once function is finished and
stack is cleaned. Therefore when cmd->outfdptr is evaluated at any
point after this function, we may get a random number, depending on
what's currently on the stack. Of course, this may work sometimes too
- it depends on the compiler how it arranges the code, when the stack
is wiped out.

In order to fix this, lets pass a pointer to @logfd instead of
figuring out (wrong) its value in a function.

The bug was introduced in e1de5521.

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

10 years agolxc: set nosuid+nodev+noexec flags on /proc/sys mount
Eric W. Biederman [Tue, 16 Jun 2015 13:44:36 +0000 (14:44 +0100)] 
lxc: set nosuid+nodev+noexec flags on /proc/sys mount

Future kernels will mandate the use of nosuid+nodev+noexec
flags when mounting the /proc/sys filesystem. Unconditionally
add them now since they don't harm things regardless and could
mitigate future security attacks.

(cherry picked from commit 24710414d403f1040794299f5304fee160d0fc23)

10 years agovirnetdev: fix moving of 802.11 phys
Lubomir Rintel [Mon, 1 Jun 2015 18:40:23 +0000 (20:40 +0200)] 
virnetdev: fix moving of 802.11 phys

There was a couple of problems with the style fixes applied to the original
patch:

1.) virFileReadAllQuiet comparison was incorrectly parenthesized when moved
into a condition, causing the len to be set to the result of comparison. This,
together with the removed underflow check would underflow the phy buffer.

2.) The logic was broken. Failure to call "ip" would abort the function, thus
the "iw" branch would never be reached.

This aims to fix the issues and work around possible style complains :)

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
(cherry picked from commit 81b19ce46a9a65a00481403b8c0b15a8ac1367f2)

10 years agointerface: don't error out if a bond has no interfaces
Lubomir Rintel [Wed, 27 May 2015 17:30:50 +0000 (19:30 +0200)] 
interface: don't error out if a bond has no interfaces

It's not a problem at all and causes virt-manager to break down.

Note: netcf 0.2.8 and earlier generates invalid XML for a bond with no
interfaces anyway, so in that case this error in libvirt is never
reached since we fail earlier.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
(cherry picked from commit efc68de5cd70d62b1941a707d22299422f1962f9)

10 years agolxc: don't up the veth interfaces unless explicitly asked to
Lubomir Rintel [Fri, 24 Apr 2015 13:52:56 +0000 (15:52 +0200)] 
lxc: don't up the veth interfaces unless explicitly asked to

Upping an interface for no reason and not configuring it is a cardinal sin.

With the default addrgenmode if eui64 it sticks a link-local address to the
interface. That is not good, as NetworkManager would see an address configured,
assume the interface is already configured and won't touch it iself and the
interface might stay unconfigured until the end of the days.

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

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

10 years agotests: Add virnetdevtestdata to EXTRA_DIST
Michal Privoznik [Wed, 15 Apr 2015 08:09:52 +0000 (10:09 +0200)] 
tests: Add virnetdevtestdata to EXTRA_DIST

In one of my previous commits (49ed6cff9) I've introduced a test
among with some files stored under virnetdevtestdata folder.
While this works perfectly within a git tree, the folder was not
getting into .tar.gz and therefore the dist-check would fail.

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

10 years agolxc: move wireless PHYs to a network namespace
Lubomir Rintel [Tue, 14 Apr 2015 16:21:44 +0000 (18:21 +0200)] 
lxc: move wireless PHYs to a network namespace

The 802.11 interfaces can not be moved by themselves, their Phy has to move too.

If there are other interfaces, they have to move too -- hopefully it's not too
confusing. This is a less-invasive alternative to defining a new hostdev type
for PHYs.

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

10 years agoCleanup "/sys/class/net" usage
Michal Privoznik [Wed, 15 Apr 2015 09:45:47 +0000 (11:45 +0200)] 
Cleanup "/sys/class/net" usage

Throughout the code, we have several places need to construct a path
somewhere in /sys/class/net/... They are not consistent and nearly
each code piece invents its own way how to do it. So unify this by:

1) use virNetDevSysfsFile() wherever possible

2) At least use common macro SYSFS_NET_DIR declared in virnetdev.h at
   the rest of places which can't go with 1)

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

10 years agoIntroduce virnetdevtest
Michal Privoznik [Wed, 11 Jun 2014 13:05:00 +0000 (15:05 +0200)] 
Introduce virnetdevtest

This is yet another test for check of basic functionality of our
NIC state handling code.

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

10 years agobuild: provide virNetDevSysfsFile on non-Linux
Eric Blake [Tue, 14 Apr 2015 19:53:04 +0000 (13:53 -0600)] 
build: provide virNetDevSysfsFile on non-Linux

Commit 49ed6cff is broken on mingw and other non-linux platforms:

  CCLD     libvirt.la
  Cannot export virNetDevSysfsFile: symbol not defined
  collect2: error: ld returned 1 exit status

* src/util/virnetdev.c: Provide virNetDevSysfsFile fallback.

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

10 years agoPrep for release 1.2.13.1 v1.2.13.1
Cole Robinson [Tue, 28 Apr 2015 15:47:33 +0000 (11:47 -0400)] 
Prep for release 1.2.13.1

10 years agoFix memory leak in virNetSocketNewConnectUNIX
Jiri Denemark [Fri, 24 Apr 2015 09:56:34 +0000 (11:56 +0200)] 
Fix memory leak in virNetSocketNewConnectUNIX

==26726==    by 0x673CD67: __vasprintf_chk (vasprintf_chk.c:80)
==26726==    by 0x5673605: UnknownInlinedFun (stdio2.h:210)
==26726==    by 0x5673605: virVasprintfInternal (virstring.c:476)
==26726==    by 0x56736EE: virAsprintfInternal (virstring.c:497)
==26726==    by 0x5680C37: virGetUserRuntimeDirectory (virutil.c:866)
==26726==    by 0x5783A89: virNetSocketNewConnectUNIX (virnetsocket.c:572)
==26726==    by 0x57751AF: virNetClientNewUNIX (virnetclient.c:344)
==26726==    by 0x57689B3: doRemoteOpen (remote_driver.c:895)
==26726==    by 0x5769F8E: remoteConnectOpen (remote_driver.c:1195)
==26726==    by 0x57092DF: do_open (libvirt.c:1189)
==26726==    by 0x570A7BF: virConnectOpenAuth (libvirt.c:1341)

https://bugzilla.redhat.com/show_bug.cgi?id=1215042
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit da4d7c30693766b89604d3d1db3cee465866a4d7)

10 years agorng: fix port number range validation
Daniel P. Berrange [Thu, 23 Apr 2015 10:49:23 +0000 (11:49 +0100)] 
rng: fix port number range validation

The PortNumber data type is declared to derive from 'short'.
Unfortunately this is an signed type, so validates the range
[-32,768, 32,767] which excludes valid port numbers between
32767 and 65535.

We can't use 'unsignedShort', since we need -1 to be a valid
port number too.

This change is to use 'int' and set an explicit max boundary
instead of relying on the data types' built-in max.

One of the existing tests is changed to use a high port number
to validate the schema.

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

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

10 years agoqemu: Don't fail to reboot domains with unresponsive agent
zhang bo [Thu, 23 Apr 2015 03:40:15 +0000 (11:40 +0800)] 
qemu: Don't fail to reboot domains with unresponsive agent

just as what b8e25c35d7f80a2fadc0e51e95318e39db3d1687 did, we
fall back to the ACPI method when the guest agent is unresponsive
in qemuDomainReboot().

Signed-off-by: YueWenyuan <yuewenyuan@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit eadf41fe313a804409415841a3df0a494470f057)

10 years agovircommand: fix polling in virCommandProcessIO
Roman Bogorodskiy [Tue, 21 Apr 2015 17:11:32 +0000 (20:11 +0300)] 
vircommand: fix polling in virCommandProcessIO

When running on FreeBSD, there's a bug in virCommandProcessIO
polling that is triggered by the commandtest.

A test that triggers EPIPE in commandtest (named "test20") hungs
forever on FreeBSD.

Apparently, this happens because FreeBSD sets POLLHUP flag on revents
when stdin in closed. And as the current implementation only checks for
POLLOUT and POLLERR, it ends up looping forever inside
virCommandProcessIO and not trying to do one more write() that would
trigger EPIPE.

To fix that check for the POLLHUP flag along with POLLOUT and POLLERR.

(cherry picked from commit e34cccf783983e1b19f139bde873e950424a8778)

10 years agoutil: storage: Fix possible crash when source path is NULL
Peter Krempa [Tue, 21 Apr 2015 15:35:23 +0000 (17:35 +0200)] 
util: storage: Fix possible crash when source path is NULL

Some storage protocols allow to have the @path field in struct
virStorageSource set to NULL. Add NULLSTR() wrappers to handle this
possibility until I finish the storage source error formatter.

(cherry picked from commit 62a61d583c65fb5e4e56f49af33f926b6a0cba6e)

10 years agoqemu: set macvtap physdevs online when macvtap is set online
Laine Stump [Mon, 13 Apr 2015 17:26:54 +0000 (13:26 -0400)] 
qemu: set macvtap physdevs online when macvtap is set online

A further fix for:

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

Since there is no possibility that any type of macvtap will work if
the parent physdev it's attached to is offline, we should bring the
physdev online at the same time as the macvtap. When taking the
macvtap offline, it's also necessary to take the physdev offline for
macvtap passthrough mode (because the physdev has the same MAC address
as the macvtap device, so could potentially cause problems with
misdirected packets during migration, as outlined in commits 829770
and 879c13). We can't set the physdev offline for other macvtap modes
1) because there may be other macvtap devices attached to the same
physdev (and/or the host itself may be using the device) in the other
modes whereas passthrough mode is exclusive to one macvtap at a time,
and 2) there's no practical reason to do so anyway.

(cherry picked from commit 38172ed894ab20e0ee0072da6f695e4c97aecc4a)

10 years agoutil: set MAC address for VF via netlink message to PF+VF# when possible
Laine Stump [Fri, 10 Apr 2015 16:19:49 +0000 (12:19 -0400)] 
util: set MAC address for VF via netlink message to PF+VF# when possible

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

When we set the MAC address of a network device as a part of setting
up macvtap "passthrough" mode (where the domain has an emulated netdev
connected to a host macvtap device that has exclusive use of the
physical device, and sets the device MAC address to match its own,
i.e. "<interface type='direct'> <source mode='passthrough' .../>"), we
use ioctl(SIOCSIFHWADDR) giving it the name of that device. This is
true even if it is an SRIOV Virtual Function (VF).

But, when we are setting the MAC address / vlan ID of a VF in
preparation for "hostdev network" passthrough (this is where we set
the MAC address and vlan id of the VF after detaching the host net
driver and before assigning the device to the domain with PCI
passthrough, i.e. "<interface type='hostdev'>", we do the setting via
a netlink RTM_SETLINK message for that VF's Physical Function (PF),
telling it the VF# we want to change. This sets an "administratively
changed MAC" flag for that VF in the PF's driver, and from that point
on (until the PF driver is reloaded, *not* merely the VF driver) that
VF's MAC address can't be changed using ioctl(SIOCSIFHWADDR) - the
only way to change it is via the PF with RTM_SETLINK.

This means that if a VF is used for hostdev passthrough, it will have
the admin flag set, and future attempts to use that VF for macvtap
passthrough will fail.

The solution to this problem is to check if the device being used for
macvtap passthrough is actually a VF; if so, we use the netlink
RTM_SETLINK message to the PF to set the VF's mac address instead of
ioctl(SIOCSIFHWADDR) directly to the VF; if not, behavior does not
change from previously.

There are three pieces to making this work:

1) virNetDevMacVLan(Create|Delete)WithVPortProfile() now call
   virNetDev(Replace|Restore)NetConfig() rather than
   virNetDev(Replace|Restore)MacAddress() (simply passing -1 for VF#
   and vlanid).

2) virNetDev(Replace|Restore)NetConfig() check to see if the device is
   a VF. If so, they find the PF's name and VF#, allowing them to call
   virNetDev(Replace|Restore)VfConfig().

3) To prevent mixups when detaching a macvtap passthrough device that
   had been attached while running an older version of libvirt,
   virNetDevRestoreVfConfig() is potentially given the preserved name
   of the VF, and if the proper statefile for a VF can't be found in
   the stateDir (${stateDir}/${pfname}_vf${vfid}),
   virNetDevRestoreMacAddress() is called instead (which will look in
   the file named ${stateDir}/${vfname}).

This problem has existed in every version of libvirt that has both
macvtap passthrough and interface type='hostdev'. Fortunately people
seem to use one or the other though, so it hasn't caused any real
world problem reports.

(cherry picked from commit cb3fe38c74bd1fb4ef76c64c045cf48467a9d259)

10 years agoxend: Remove a couple of unused function prototypes.
Richard W.M. Jones [Mon, 20 Apr 2015 16:15:12 +0000 (17:15 +0100)] 
xend: Remove a couple of unused function prototypes.

Commit 70f446631f142ae92b4d4eb349fcf11408171556 (from 2008) introduced
some functions for testing whether xend was returning correct sound
models.  Those functions have long gone, but the function prototypes
remain.  This commit removes the unused prototypes.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit 093eea95894f1a2b3a4977e2dc676b53e9896c95)

10 years agoqemuDomainShutdownFlags: Set fakeReboot more frequently
zhang bo [Fri, 17 Apr 2015 00:43:58 +0000 (08:43 +0800)] 
qemuDomainShutdownFlags: Set fakeReboot more frequently

When a qemu domain is to be rebooted, from outside, at libvirt
level it looks like regular shutdown. To really restart the
domain, libvirt needs to issue reset command on the monitor once
SHUTDOWN event appeared. So, in order to differentiate bare
shutdown and reboot libvirt uses a variable within domain private
data. It's called fakeReboot. When the reboot API is called, the
variable is set, but when the shutdown API is called it must be
cleared out. But it was not for every possible case. So if user
called virDomainReboot(), and there was no ACPI daemon running
inside the guest (so guest didn't initiated shutdown sequence)
and then virDomainShutdown(mode=agent) was called bad thing
happened. We remembered the fakeReboot and instead of shutting
the domain down, we just rebooted it.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 8be502fd908c26b5e33c9cc7b65d8db32f5d19f9)

10 years agonwfilter: Partly initialize driver even for non-privileged users
Michal Privoznik [Thu, 16 Apr 2015 07:59:22 +0000 (09:59 +0200)] 
nwfilter: Partly initialize driver even for non-privileged users

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

This reverts commit b7829f959b33c6e32422222a9ed745c0da7dc696.

The previous fix was not correct. Like everywhere else, a driver is a
global variable allocated in stateInitialize function (or something
similar for stateless drivers). Later, when a driver API is called,
it's possible that the global variable is accessed and dereferenced.
Now, some drivers require root privileges because they undertake some
actions reserved only for the system admin (e.g. manipulating host
firewall). And here's the trouble, the NWFilter state initializer
exited too early when finding out it's running unprivileged, leaving
the global NWFilter driver variable uninitialized. Any subsequent
API call that tried to lock the driver resulted in dereferencing the
driver and thus crash.

On the other hand, in order to not resurrect the bug the original
commit was fixing, Let's forbid the nwfilter define in session mode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Conflicts:
src/nwfilter/nwfilter_driver.c: Context. Code changed a bit
        since 2013.

(cherry picked from commit 77d92e2e77f0dae8fc9e1eb5fa0db9fc9f2818bd)

10 years agovirNetSocketNewConnectUNIX: Don't unlink(NULL)
Michal Privoznik [Thu, 16 Apr 2015 14:07:15 +0000 (16:07 +0200)] 
virNetSocketNewConnectUNIX: Don't unlink(NULL)

There is a possibility that we jump onto error label with @lockpath
still initialized to NULL. Here, the @lockpath should be unlink()-ed,
but passing there a NULL is not a good idea. Don't do that. In fact,
we should call unlink() only if we created the lock file successfully.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 1fdac3d99a8147092075593d84350d80f5b9bb45)

10 years agosanlock: Use VIR_ERR_RESOURCE_BUSY if sanlock_acquire fails
Jiri Denemark [Tue, 14 Apr 2015 14:27:37 +0000 (16:27 +0200)] 
sanlock: Use VIR_ERR_RESOURCE_BUSY if sanlock_acquire fails

When acquiring resource via sanlock fails, we would report it as
VIR_ERR_INTERNAL_ERROR, which is not very friendly to applications using
libvirt. Moreover, the lockd driver would report the same failure as
VIR_ERR_RESOURCE_BUSY, which looks better.

Unfortunately, in sanlock driver we don't really know if acquiring the
resource failed because it was already locked or there was another
reason behind. But the end result is the same and I think using
VIR_ERR_RESOURCE_BUSY reason for all acquire failures is still better
than what we have now.

https://bugzilla.redhat.com/show_bug.cgi?id=1165119
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 4864e377c9a6ef08cd65672775e520751a27f6d7)

10 years agoqemuMigrationPrecreateStorage: Fix debug message
Michal Privoznik [Thu, 2 Apr 2015 14:34:01 +0000 (16:34 +0200)] 
qemuMigrationPrecreateStorage: Fix debug message

When pre-creating storage for domains, we need to find corresponding
disk in the XML on the destination (domain XML may differ there, e.g.
disk is accessible under different path). For better debugging, I'm
printing all info I received on a disk. But there was a typo when
printing the disk capacity: "%lluu" instead of "%llu".

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

10 years agoqemu_migration.c: sleep first before checking for migration status.
Xing Lin [Thu, 9 Apr 2015 22:02:02 +0000 (16:02 -0600)] 
qemu_migration.c: sleep first before checking for migration status.

The problem with the previous implementation is,
even when qemuMigrationUpdateJobStatus() detects a migration job
has completed, it will do a sleep for 50 ms (which is unnecessary
and only adds up to the VM pause time).

Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 522e81cbb501e9772fbafba975ac886c1b4a283d)

10 years agoqemu_driver: check caps after starting block job
Michael Chapman [Wed, 8 Apr 2015 06:51:51 +0000 (16:51 +1000)] 
qemu_driver: check caps after starting block job

Currently we check qemuCaps before starting the block job. But qemuCaps
isn't available on a stopped domain, which means we get a misleading
error message in this case:

  # virsh domstate example
  shut off

  # virsh blockjob example vda
  error: unsupported configuration: block jobs not supported with this QEMU binary

Move the qemuCaps check into the block job so that we are guaranteed the
domain is running.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit cfcdf5ff01aa96a0afcf8f1984967c7eaa2b4330)

10 years agoqemu_migrate: use nested job when adding NBD to cookie
Michael Chapman [Wed, 8 Apr 2015 06:51:42 +0000 (16:51 +1000)] 
qemu_migrate: use nested job when adding NBD to cookie

qemuMigrationCookieAddNBD is usually called from within an async
MIGRATION_OUT or MIGRATION_IN job, so it needs to start a nested job.

(The one exception is during the Begin phase when change protection
isn't enabled, but qemuDomainObjEnterMonitorAsync will behave the same
as qemuDomainObjEnterMonitor in this case.)

This bug was encountered with a libvirt client that repeatedly queries
the disk mirroring block job info during a migration. If one of these
queries occurs just as the Perform migration cookie is baked, libvirt
crashes.

Relevant logs are as follows:

    6701: warning : qemuDomainObjEnterMonitorInternal:1544 : This thread seems to be the async job owner; entering monitor without asking for a nested job is dangerous
[1] 6701: info : qemuMonitorSend:972 : QEMU_MONITOR_SEND_MSG: mon=0x7fefdc004700 msg={"execute":"query-block","id":"libvirt-629"}
[2] 6699: info : qemuMonitorIOWrite:503 : QEMU_MONITOR_IO_WRITE: mon=0x7fefdc004700 buf={"execute":"query-block","id":"libvirt-629"}
[3] 6704: info : qemuMonitorSend:972 : QEMU_MONITOR_SEND_MSG: mon=0x7fefdc004700 msg={"execute":"query-block-jobs","id":"libvirt-630"}
[4] 6699: info : qemuMonitorJSONIOProcessLine:203 : QEMU_MONITOR_RECV_REPLY: mon=0x7fefdc004700 reply={"return": [...], "id": "libvirt-629"}
    6699: error : qemuMonitorJSONIOProcessLine:211 : internal error: Unexpected JSON reply '{"return": [...], "id": "libvirt-629"}'

At [1] qemuMonitorBlockStatsUpdateCapacity sends its request, then waits
on mon->notify. At [2] the request is written out to the monitor socket.
At [3] qemuMonitorBlockJobInfo sends its request, and also waits on
mon->notify. The reply from the first request is received at [4].
However, qemuMonitorJSONIOProcessLine is not expecting this reply since
the second request hadn't completed sending. The reply is dropped and an
error is returned.

qemuMonitorIO signals mon->notify twice during its error handling,
waking up both of the threads waiting on it. One of them clears mon->msg
as it exits qemuMonitorSend; the other crashes:

  qemuMonitorSend (mon=0x7fefdc004700, msg=<value optimized out>) at qemu/qemu_monitor.c:975
  975         while (!mon->msg->finished) {
  (gdb) print mon->msg
  $1 = (qemuMonitorMessagePtr) 0x0

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit 72df8314f02ac575b8407ab1d0d4fbfe82affd9c)

10 years agoutil: fix removal of callbacks in virCloseCallbacksRun
Michael Chapman [Wed, 8 Apr 2015 03:22:39 +0000 (13:22 +1000)] 
util: fix removal of callbacks in virCloseCallbacksRun

The close callbacks hash are keyed by a UUID-string, but
virCloseCallbacksRun was attempting to remove them by raw UUID. This
patch ensures the callback entries are removed by UUID-string as well.

This bug caused problems when guest migrations were abnormally aborted:

  # timeout --signal KILL 1 \
      virsh migrate example qemu+tls://remote/system \
        --verbose --compressed --live --auto-converge \
        --abort-on-error --unsafe --persistent \
        --undefinesource --copy-storage-all --xml example.xml
  Killed

  # virsh migrate example qemu+tls://remote/system \
      --verbose --compressed --live --auto-converge \
      --abort-on-error --unsafe --persistent \
      --undefinesource --copy-storage-all --xml example.xml
  error: Requested operation is not valid: domain 'example' is not being migrated

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit fa2607d57713f4234ff75777468f43d9f5ec67a2)

10 years agoqemu: fix race between disk mirror fail and cancel
Michael Chapman [Mon, 30 Mar 2015 02:41:00 +0000 (13:41 +1100)] 
qemu: fix race between disk mirror fail and cancel

If a VM migration is aborted, a disk mirror may be failed by QEMU before
libvirt has a chance to cancel it. The disk->mirrorState remains at
_ABORT in this case, and this breaks subsequent mirrorings of that disk.

We should instead check the mirrorState directly and transition to _NONE
if it is already aborted. Do the check *after* aborting the block job in
QEMU to avoid a race.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit e5d729ba42d86eb3afa9799bca2944700fde41bb)

10 years agoqemu: fix error propagation in qemuMigrationBegin
Michael Chapman [Mon, 30 Mar 2015 02:40:59 +0000 (13:40 +1100)] 
qemu: fix error propagation in qemuMigrationBegin

If virCloseCallbacksSet fails, qemuMigrationBegin must return NULL to
indicate an error occurred.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit 77ddd0bba2379b4ba33980d8f3976f9344451cca)

10 years agoqemu: fix crash in qemuProcessAutoDestroy
Michael Chapman [Mon, 30 Mar 2015 02:40:58 +0000 (13:40 +1100)] 
qemu: fix crash in qemuProcessAutoDestroy

The destination libvirt daemon in a migration may segfault if the client
disconnects immediately after the migration has begun:

  # virsh -c qemu+tls://remote/system list --all
   Id    Name                           State
  ----------------------------------------------------
  ...

  # timeout --signal KILL 1 \
      virsh migrate example qemu+tls://remote/system \
        --verbose --compressed --live --auto-converge \
        --abort-on-error --unsafe --persistent \
        --undefinesource --copy-storage-all --xml example.xml
  Killed

  # virsh -c qemu+tls://remote/system list --all
  error: failed to connect to the hypervisor
  error: unable to connect to server at 'remote:16514': Connection refused

The crash is in:

   1531 void
   1532 qemuDomainObjEndJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
   1533 {
   1534     qemuDomainObjPrivatePtr priv = obj->privateData;
   1535     qemuDomainJob job = priv->job.active;
   1536
   1537     priv->jobs_queued--;

Backtrace:

  #0  at qemuDomainObjEndJob at qemu/qemu_domain.c:1537
  #1  in qemuDomainRemoveInactive at qemu/qemu_domain.c:2497
  #2  in qemuProcessAutoDestroy at qemu/qemu_process.c:5646
  #3  in virCloseCallbacksRun at util/virclosecallbacks.c:350
  #4  in qemuConnectClose at qemu/qemu_driver.c:1154
  ...

qemuDomainRemoveInactive calls virDomainObjListRemove, which in this
case is holding the last remaining reference to the domain.
qemuDomainRemoveInactive then calls qemuDomainObjEndJob, but the domain
object has been freed and poisoned by then.

This patch bumps the domain's refcount until qemuDomainRemoveInactive
has completed. We also ensure qemuProcessAutoDestroy does not return the
domain to virCloseCallbacksRun to be unlocked in this case. There is
similar logic in bhyveProcessAutoDestroy and lxcProcessAutoDestroy
(which call virDomainObjListRemove directly).

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit 7578cc17f58d7b2d582fffb118a077b73288d92b)

10 years agoqemu: blockCopy: Pass adjusted bandwidth when called via blockRebase
Peter Krempa [Mon, 30 Mar 2015 15:34:13 +0000 (17:34 +0200)] 
qemu: blockCopy: Pass adjusted bandwidth when called via blockRebase

The block copy API takes the speed in bytes/s rather than MiB/s that was
the prior approach in virDomainBlockRebase. We correctly converted the
speed to bytes/s in the old API but we still called the common helper
virDomainBlockCopyCommon with the unadjusted variable.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207122
(cherry picked from commit 3c6a72d5376732efd8effb4a0a419211c0eb0659)

10 years agovirsh: blockCopy: Add missing jump on error path
Luyao Huang [Fri, 27 Mar 2015 09:56:29 +0000 (17:56 +0800)] 
virsh: blockCopy: Add missing jump on error path

The overflow check for the bandwidth parameter did not jump to the
cleanup label.

Additionally virsh should use vshError instead of virReportError.

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

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

10 years agoqemu: end the job when try to blockcopy to non-file destination
Shanzhi Yu [Fri, 27 Mar 2015 09:16:41 +0000 (17:16 +0800)] 
qemu: end the job when try to blockcopy to non-file destination

Blockcopy to non-file destination is not supported according the code,
but a 'goto endjob' is missed after checking the destination.

This leads to calling drive-mirror with wrong parameters.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206406
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c5fbad66234b1b1a9afc36ef2fe3a3d903886386)

10 years agonodeinfo: Increase the num of CPU thread siblings to a larger value
Wei Huang [Thu, 26 Mar 2015 04:48:13 +0000 (00:48 -0400)] 
nodeinfo: Increase the num of CPU thread siblings to a larger value

Current libvirt can only handle up to 1023 bytes when it
reads Linux sysfs topology/thread_siblings. This isn't enough for
Linux distributions that support a large value. This patch fixes
the problem by using VIR_ALLOC()/VIR_FREE(), instead of using a
fixed-size (1024) local char array. In the meanwhile
SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX is increased to 8192 which
should be large enough for a foreseeable future.

Signed-off-by: Wei Huang <wei@redhat.com>
(cherry picked from commit c13de016916c826ad4d35157ee6a52baee87ac22)

10 years agorelaxng: allow : in /dev/disk/by-path names
Eric Blake [Thu, 26 Mar 2015 22:48:07 +0000 (16:48 -0600)] 
relaxng: allow : in /dev/disk/by-path names

On IRC, Hydrar pointed a problem where 'virsh edit' failed on
his domain created through an ISCSI pool managed by virt-manager,
all because the XML included a block device with colons in the
name.

* docs/schemas/basictypes.rng (absFilePath): Add colon as safe.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml: New file.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args: Likewise.
* tests/qemuxml2argvtest.c (mymain): Test it.

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

10 years agoqemu: Give hint about -noTSX CPU model
Jiri Denemark [Tue, 24 Mar 2015 13:12:07 +0000 (14:12 +0100)] 
qemu: Give hint about -noTSX CPU model

Because of the microcode update to Haswell/Broadwell CPUs, existing
domains using these CPUs may fail to start even though they used to run
just fine. To help users solve this issue we try to suggest switching to
-noTSX variant of the CPU model:

    virsh # start cd
    error: Failed to start domain cd
    error: unsupported configuration: guest and host CPU are not
    compatible: Host CPU does not provide required features: rtm, hle;
    try using 'Haswell-noTSX' CPU model

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

10 years agobuild: fix race when creating the cpu_map.xml symlink
Amy Fong [Mon, 23 Mar 2015 17:44:03 +0000 (13:44 -0400)] 
build: fix race when creating the cpu_map.xml symlink

In some circumstances where the build tree differs from the source,
libvirt's compile will try to create the symlink for cpu_map.xml before
creating the directory $(abs_builddir)/cpu:

'src/cpu/cpu_map.xml': No such file or directory'

Do not create the symlink, it is no longer needed after
commit e562e82f
    Load CPU map from builddir when run uninstalled

Signed-off-by: Amy Fong <amy.fong@windriver.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 237ffd1b1d725f04b3b185ee2cb5938b6d3d45b7)

10 years agoDon't validata filesystem target type
Guido Günther [Sat, 21 Mar 2015 10:37:12 +0000 (11:37 +0100)] 
Don't validata filesystem target type

When using QEMU's 9pfs the target "dir" element is not necessarily an
absolute path but merely an arbitrary identifier. So validation in that
case currently fails with the misleading

   $ virt-xml-validate /tmp/test.xml
   Relax-NG validity error : Extra element devices in interleave
   /tmp/test.xml:24: element devices: Relax-NG validity error : Element domain failed to validate content
   /tmp/test.xml fails to validate

(cherry picked from commit db1edae8951dab99232fba4b33c28f5d412ecb41)

10 years agoDocument behavior of compat when creating qcow2 volumes
Ján Tomko [Tue, 24 Mar 2015 16:13:24 +0000 (17:13 +0100)] 
Document behavior of compat when creating qcow2 volumes

Commit bab2eda changed the behavior for missing compat attribute,
but failed to update the documentation.

Before, the option was omitted from qemu-img command line and the
qemu-img default was used. Now we always specify the compat value
and the default is 0.10.

Reported by Christophe Fergeau
https://bugzilla.gnome.org/show_bug.cgi?id=746660#c4

(cherry picked from commit 7c8ae42d495d683f79ae4baf024f29f089eaa573)

10 years agoFix typo in error message
Ján Tomko [Mon, 16 Mar 2015 14:55:21 +0000 (15:55 +0100)] 
Fix typo in error message

by rewriting it completely from:
error: unsupported configuration: virtio only support device address
type 'PCI'

to:

error: unsupported configuration: virtio disk cannot have an address of type
drive

Since we now support CCW addresses as well.

(cherry picked from commit 68545ea629b40927e36d2062eff6358014b9fc8d)

10 years agoqemu: change accidental VIR_WARNING back to VIR_DEBUG
Laine Stump [Tue, 24 Mar 2015 14:45:09 +0000 (10:45 -0400)] 
qemu: change accidental VIR_WARNING back to VIR_DEBUG

While debugging the support for responding to qemu RX_FILTER_CHANGED
events, I had changed the "ignoring this event" log message from
VIR_DEBUG to VIR_WARN, but forgot to change it back before
pushing. Since many guest OSes make enough changes to multicast lists
and/or promiscuous mode settings to trigger this message, it's
starting to show up as a red herring in bug reports.

(cherry picked from commit dae3e246637a8863a1988683b0c43f461a1b4a5d)

10 years agoconf: fix parsing of NUMA settings in VM status XML
Luyao Huang [Thu, 19 Mar 2015 10:13:04 +0000 (18:13 +0800)] 
conf: fix parsing of NUMA settings in VM status XML

Commit 5bba61f changed the XPath strings to be absolute when parsing
the VM NUMA configuration. Unfortunately the <domain> element is not a
top level element when parsing the domain status XML thus the absolute
XPath string doesn't match.

Use the relative string so that the <numa> settings are not lost.

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

10 years agoqemu: skip precreation of network disks
Michael Chapman [Fri, 13 Mar 2015 00:34:58 +0000 (11:34 +1100)] 
qemu: skip precreation of network disks

Commit cf54c60699833b3791a5d0eb3eb5a1948c267f6b introduced the ability
to create missing storage volumes during migration. For network disks,
however, we may not necessarily be able to detect whether they already
exist -- there is no straight-forward way to map the disk to a storage
volume, and even if there were it's possible no configured storage pool
actually contains the disk.

It is better to assume the network disk exists in this case, rather than
aborting the migration completely. If the volume really is missing, QEMU
will generate an appropriate error later in the migration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit a1b1805155ede31dde755ff087963aa10b9b069b)

10 years agoqemu: do not overwrite the error in qemuDomainObjExitMonitor
Luyao Huang [Thu, 19 Mar 2015 03:14:39 +0000 (11:14 +0800)] 
qemu: do not overwrite the error in qemuDomainObjExitMonitor

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

When qemu exits during startup, libvirt includes the error from
/var/log/libvirt/qemu/vm.log in the error message:

$ virsh start test3
error: Failed to start domain test3
error: internal error: early end of file from monitor: possible problem:
2015-02-27T03:03:16.985494Z qemu-kvm: -numa memdev is not supported by
machine rhel6.5.0

The check for domain liveness added to qemuDomainObjExitMonitor
in commit dc2fd51f sometimes overwrites this error:
$ virsh start test3
error: Failed to start domain test3
error: operation failed: domain is no longer running

Fix the check to only report an error if there is none set.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4f068209387118f9b67c7cfe1a6c0097d7f573e7)

10 years agolibxl: Don't overwrite errors from xenconfig
Jim Fehlig [Wed, 18 Mar 2015 20:53:45 +0000 (14:53 -0600)] 
libxl: Don't overwrite errors from xenconfig

When converting domXML from native, the libxl driver was overwriting
useful errors from the xenconfig parsing code with a useless, generic
error.  E.g. "internal error: parsing xm config failed" vs
"internal error: config value usbdevice was malformed".  Remove the
redundant (and useless) error reporting in the libxl driver.

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

10 years agoutil: more verbose error when failing to create macvtap device
Laine Stump [Wed, 18 Mar 2015 18:27:05 +0000 (14:27 -0400)] 
util: more verbose error when failing to create macvtap device

Investigation of a problem with creating passthrough macvtap devices
(https://bugzilla.redhat.com/show_bug.cgi?id=1185501) has shown that
this slightly more verbose failure message is useful. In particular,
the mac address can be used to determine the domain. You could also
figure this out by looking at preceding messages in a debug log, but
this gets it in a single place.

(cherry picked from commit 72423df9920491f8f59455a4161a7c31d1e15c8a)

10 years agoqemu: hotplug: Use checker function to check if disk is empty
Peter Krempa [Thu, 12 Mar 2015 15:57:56 +0000 (16:57 +0100)] 
qemu: hotplug: Use checker function to check if disk is empty

(cherry picked from commit e7974b4f80f320c9232ff31762fd1aa82a590f2e)

10 years agoqemu: driver: Fix cold-update of removable storage devices
Peter Krempa [Thu, 12 Mar 2015 16:12:12 +0000 (17:12 +0100)] 
qemu: driver: Fix cold-update of removable storage devices

Only selected fields from the disk source were copied when cold updating
source in a CDROM drive. When such drive was backed by a network file
this resulted into corruption of the definition:

    <disk type='network' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source protocol='gluster' name='gluster-vol1(null)'>
        <host name='localhost'/>
      </source>
      <target dev='vdc' bus='virtio'/>
      <readonly/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>

Update the whole source instead of cherry-picking elements.

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

10 years agoqemu: Check for negative port values in network drive configuration
Erik Skultety [Thu, 19 Feb 2015 15:53:13 +0000 (16:53 +0100)] 
qemu: Check for negative port values in network drive configuration

We interpret port values as signed int (convert them from char *),
so if a negative value is provided in network disk's configuration,
we accept it as valid, however there's an 'unknown cause' error raised later.
This error is only accidental because we return the port value in the return code.
This patch adds just a minor tweak to the already existing check so we
reject negative values the same way as we reject non-numerical strings.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553
(cherry picked from commit 84646165262de4fcdfca49e9e9198fa7b26edea6)

10 years agovirsh: fix report of non-active commit completion
Eric Blake [Fri, 13 Mar 2015 15:56:48 +0000 (09:56 -0600)] 
virsh: fix report of non-active commit completion

Commit f182da20 (v1.2.6) caused a slight regression in virsh
reporting of a non-active block job; where it used to state
"Commit complete", it now states "Now in synchronized phase".
But the synchronized phase is only possible for an active commit.

For a reproducer, I created a chain 'a <- b <- c <- d <- e' and
ran virsh blockcommit $dom vda --top c --base a --verbose --wait

* tools/virsh-domain.c (cmdBlockCommit): Synchronized phase is
only possible on active commits.

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

10 years agoutil: don't fail if no PortData is found while getting migrateData
zhang bo [Thu, 5 Mar 2015 02:01:50 +0000 (10:01 +0800)] 
util: don't fail if no PortData is found while getting migrateData

Introduced by f6a2f97e

Problem Description:
After multiple times of migrating a domain, which has an ovs interface with no portData set,
with non-shared disk, nbd ports got overflowed.

The steps to reproduce the problem:
1 define and start a domain with its network configured as:
    <interface type='bridge'>
          <source bridge='br0'/>
          <virtualport type='openvswitch'>
          </virtualport>
          <model type='virtio'/>
          <driver name='vhost' queues='4'/>
    </interface>
2 do not set the network's portData.
3 migrate(ToURI2) it with flag 91(1011011), which means:
  VIR_MIGRATE_LIVE
  VIR_MIGRATE_PEER2PEER
  VIR_MIGRATE_PERSIST_DEST
  VIR_MIGRATE_UNDEFINE_SOURCE
  VIR_MIGRATE_NON_SHARED_DISK
4 migrate success, but we got an error log in libvirtd.log:
  error : virCommandWait:2423 : internal error: Child process (ovs-vsctl --timeout=5 get Interface
  vnet1 external_ids:PortData) unexpected exit status 1: ovs-vsctl: no key "PortData" in Interface
  record "vnet1" column external_ids
5 migrate it back, migrate it , migrate it back, .......
6 nbd port got overflowed.

The reasons for the problem is :
1 virNetDevOpenvswitchGetMigrateData() takes it as wrong if no portData is available for  the ovs
 interface of a domain. (We think it's not appropriate, as portData is just OPTIONAL)
2 in func qemuMigrationBakeCookie(), it fails in qemuMigrationCookieAddNetwork(), and returns with -1.
 qemuMigrationCookieAddNBD() is not called thereafter, and mig->nbd is still NULL.
3 However, qemuMigrationRun() just *WARN* if qemuMigrationBakeCookie() fails, migration still successes.
 cookie is NULL, it's not baked on the src side.
4 On the destination side, it would alloc a port first and then free the nbd port in COOKIE.
 But the cookie is NULL due to qemuMigrationCookieAddNetwork() failure at src side. thus the nbd port
 is not freed.

In this patch, we add "--if-exists" option to make ovs-vsctl not raise error if there's no portData available.
Further more, because portData may be NULL in the cookie at the dest side, check it before setting portData.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
(cherry picked from commit 25df57db73adc3e610193ee1fcdd202c47ba471d)

10 years agoClarify the meaning of version in redirdev filters
Ján Tomko [Thu, 12 Mar 2015 12:13:39 +0000 (13:13 +0100)] 
Clarify the meaning of version in redirdev filters

The version attribute in redirdev filters refers to the revision
of the device, not the version of the USB protocol.

Explicitly state that this is not the USB protocol and remove references
to those round version numbers that resemble USB protocol versions.

https://bugzilla.redhat.com/show_bug.cgi?id=1177237
(cherry picked from commit 76a2a5ce8ba319c63e5c5572d41d768a48d371b5)

10 years agoxenapi: Resolve Coverity REVERSE_INULL
John Ferlan [Tue, 10 Mar 2015 23:14:31 +0000 (19:14 -0400)] 
xenapi: Resolve Coverity REVERSE_INULL

Coverity notes in xenapiDomainGetXMLDesc that 'vms' is dereferenced
a few times before a "if (vms) xen_vm_set_free(vms);" call is made.
Since we'd exit out much sooner if the fetch of the vms failed, just
remove the unnecessary "if (vms)" check.

(cherry picked from commit eab968c7d7b4ee94e504499dc2a4ea70643718a0)

10 years agoxenapi: Resolve Coverity REVERSE_INULL
John Ferlan [Tue, 10 Mar 2015 23:10:34 +0000 (19:10 -0400)] 
xenapi: Resolve Coverity REVERSE_INULL

Coverity complains that "net_set" is compared to NULL before calling
xen_network_set_free, but used rather liberally before that.  While
I was looking at the code I also noted that if the virAsprintfQuiet
fails, then we leak our structures - so I added those too.

(cherry picked from commit 6da29e0faa44209bcbd737920d93c760104b8349)

10 years agoxenapi: Resolve Coverity NULL_RETURNS
John Ferlan [Tue, 10 Mar 2015 22:52:07 +0000 (18:52 -0400)] 
xenapi: Resolve Coverity NULL_RETURNS

Coverity points out that the return from virDomainDefParseString is
not checked in xenapiDomainCreateXML like it should be which could
end up in a NULL pointer dereference

(cherry picked from commit b193a1d61737fad7cf4b96e5fd9443b0ace36efc)

10 years agoxenapi: Resolve Coverity NO_EFFECT
John Ferlan [Tue, 10 Mar 2015 22:41:18 +0000 (18:41 -0400)] 
xenapi: Resolve Coverity NO_EFFECT

Coverity points out that check (def->uuid) has no effect since it's not
a pointer, rather an array of characters.   Just remove the extranous check.

(cherry picked from commit 467c90590924069d64a4cd884abef17c7c2c0f24)

10 years agoxenapi: Resolve Coverity FORWARD_NULL
John Ferlan [Tue, 10 Mar 2015 22:33:59 +0000 (18:33 -0400)] 
xenapi: Resolve Coverity FORWARD_NULL

Since inception.  Coverity complains that the code checks "(record ==
NULL && !session->ok)", but doesn't check (record != NULL) before
dereferencing at "record->is_a_template"

(cherry picked from commit 500d77f1811c371598ab7a5fcc90bad45b52bafd)

10 years agoRNG: Allow multiple parameters to be passed to an interface filter
Michal Privoznik [Wed, 11 Mar 2015 08:54:29 +0000 (09:54 +0100)] 
RNG: Allow multiple parameters to be passed to an interface filter

Our code supports that for ages. When using a <filterref/> to an
<interface/> several parameters can be passed to the filter. Later,
when building firewall rules, parameters are substituted for their
values. However, our RNG schema allowed only one parameter to be
passed.

Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 6cc5080a099a650c6cd98662219bfc5c9af153d7)

10 years agodomain_conf: fix crash in virDomainObjListFindByUUIDInternal
Michael Chapman [Wed, 11 Mar 2015 02:19:54 +0000 (13:19 +1100)] 
domain_conf: fix crash in virDomainObjListFindByUUIDInternal

If a domain object is being removed and looked up concurrently we must
ensure we unlock the object before unreferencing it, since the latter
might free the object.

The flaw was introduced in commit feb1a4d792e1c35b1009e69c00bf351b39.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit 616003d6bd5a3d87d6d529ddb6d83715979d903c)

10 years ago{domain, network}_conf: disable autostart when deleting config
Michael Chapman [Wed, 11 Mar 2015 02:20:28 +0000 (13:20 +1100)] 
{domain, network}_conf: disable autostart when deleting config

Undefining a running, autostarted domain removes the autostart link, but
dom->autostart is not cleared. If the domain is subsequently redefined,
libvirt thinks it is already autostarted and will not create the link
even if requested:

  # virsh dominfo example | grep Autostart
  Autostart:      enable

  # ls /etc/libvirt/qemu/autostart/example.xml
  /etc/libvirt/qemu/autostart/example.xml

  # virsh undefine example
  Domain example has been undefined

  # virsh define example.xml
  Domain example defined from example.xml

  # virsh dominfo example | grep Autostart
  Autostart:      enable

  # virsh autostart example
  Domain example marked as autostarted

  # ls /etc/libvirt/qemu/autostart/example.xml
  ls: cannot access /etc/libvirt/qemu/autostart/example.xml: No such file or directory

This commit ensures dom->autostart is cleared whenever the config and
autostart link (if present) are removed.

The bridge network driver cleared this flag itself in networkUndefine.
This commit moves this into virNetworkDeleteConfig for symmetry with
virDomainDeleteConfig, and to ensure it is not missed in future network
drivers.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
(cherry picked from commit a6ec4f472d585c0ab3df42b98926fb8c6893d6e4)

10 years agoqemu: Remove unnecessary virReportError on networkGetNetworkAddress return
Luyao Huang [Sat, 28 Feb 2015 09:08:34 +0000 (17:08 +0800)] 
qemu: Remove unnecessary virReportError on networkGetNetworkAddress return

Error messages are already set in all code paths returning -1 from
networkGetNetworkAddress, so we don't want to overwrite them.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 64595431cdf57f0a23351e8808f7c3c18e855f9f)

10 years agovirQEMUCapsInitQMP: Don't dispose locked @vm
Michal Privoznik [Tue, 10 Mar 2015 13:23:43 +0000 (14:23 +0100)] 
virQEMUCapsInitQMP: Don't dispose locked @vm

When creating qemu capabilities, a dummy virDomainObj is created just
because our monitor code expects that. However, the object is created
locked already. Then, under cleanup label, we simply unref the object
which results in whole domain object to be disposed. The object lock
is destroyed subsequently, but hey - it's still locked:

==24845== Thread #14's call to pthread_mutex_destroy failed
==24845==    with error code 16 (EBUSY: Device or resource busy)
==24845==    at 0x4C3024E: pthread_mutex_destroy (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==24845==    by 0x531F72E: virMutexDestroy (virthread.c:83)
==24845==    by 0x5302977: virObjectLockableDispose (virobject.c:237)
==24845==    by 0x5302A89: virObjectUnref (virobject.c:265)
==24845==    by 0x1DD37866: virQEMUCapsInitQMP (qemu_capabilities.c:3397)
==24845==    by 0x1DD37CC6: virQEMUCapsNewForBinary (qemu_capabilities.c:3481)
==24845==    by 0x1DD381E2: virQEMUCapsCacheLookup (qemu_capabilities.c:3609)
==24845==    by 0x1DD30F8A: virQEMUCapsInitGuest (qemu_capabilities.c:744)
==24845==    by 0x1DD31889: virQEMUCapsInit (qemu_capabilities.c:1020)
==24845==    by 0x1DD7DD36: virQEMUDriverCreateCapabilities (qemu_conf.c:888)
==24845==    by 0x1DDC57C0: qemuStateInitialize (qemu_driver.c:803)
==24845==    by 0x53DC743: virStateInitialize (libvirt.c:777)
==24845==

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

10 years agoqemu: fix memory leak in qemuAgentGetFSInfo
Chen Fan [Tue, 10 Mar 2015 05:56:11 +0000 (13:56 +0800)] 
qemu: fix memory leak in qemuAgentGetFSInfo

in virDomainFSInfoFree(), don't free the virDomainFSInfo data.

==10670== 80 bytes in 2 blocks are definitely lost in loss record 576 of 793
==10670==    at 0x4A06BC3: calloc (vg_replace_malloc.c:618)
==10670==    by 0x509DEBD: virAlloc (viralloc.c:144)
==10670==    by 0x19FBD558: qemuAgentGetFSInfo (qemu_agent.c:1837)
==10670==    by 0x1A03CF91: qemuDomainGetFSInfo (qemu_driver.c:19238)

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
(cherry picked from commit f276b36d65f5013425eb57524de7d919d99aba9a)

10 years agodocs: add a note that spice channel is usable only with spice graphics
Pavel Hrdina [Thu, 26 Feb 2015 10:59:41 +0000 (11:59 +0100)] 
docs: add a note that spice channel is usable only with spice graphics

To prevent a confusion about missing chardev argument in qemu
command line add a note about that behavior into documentation.

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

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

10 years agolocking: Fix flags in virLockManagerLockDaemonNew
Jiri Denemark [Mon, 9 Mar 2015 12:12:36 +0000 (13:12 +0100)] 
locking: Fix flags in virLockManagerLockDaemonNew

virLockManager*New APIs are never called with
VIR_LOCK_MANAGER_USES_STATE. Moreover, lockd driver does not maintain
any state that would need to be transferred during migration and thus it
should not mention VIR_LOCK_MANAGER_USES_STATE at all.

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

10 years agotests: fix qemuxml2argvtest to be arch independent
Pavel Hrdina [Sat, 7 Mar 2015 10:24:48 +0000 (11:24 +0100)] 
tests: fix qemuxml2argvtest to be arch independent

Commit 5aee81a0 introduced a new test for disk-serial.  The test fails
on i686 arch because there is no need to add "-cpu qemu32" to command
line.  To fix the test update emulator in XML to "/usr/bin/qemu" so we
don't add the "-cpu qemu32" to command while running the test on i686 or
x86_64 host.

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

10 years agotests: Add test for virtio-mmio address type
Martin Kletzander [Wed, 25 Feb 2015 14:12:31 +0000 (15:12 +0100)] 
tests: Add test for virtio-mmio address type

Commit 3e4b783e fixed an issue with RNG schema where this address type
was missing, this commit adds a test for it.

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

10 years agoqemu: Allow spaces in disk serial
Michal Privoznik [Mon, 23 Feb 2015 11:34:23 +0000 (12:34 +0100)] 
qemu: Allow spaces in disk serial

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

There's been a bug report appearing on the qemu-devel list, that
libvirt is unable to pass spaces in disk serial number [1]. Not only
our RNG schema forbids that, the code is not prepared either. However,
with a bit of escaping (if needed) we can allow spaces there.

1: https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg04041.html

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

10 years agostorage: tweak condition to properly test lseek
Erik Skultety [Tue, 3 Mar 2015 15:57:38 +0000 (16:57 +0100)] 
storage: tweak condition to properly test lseek

According to the POSIX standard, off_t (returned by lseek) is defined as
signed integral type no shorter than int. Because our offset variable is defined
as unsigned long long, the original check was passed successfully if UINT64_MAX had
been used as offset value, due to implicit conversion.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177219
(cherry picked from commit 3fde7986d6694f122ae919d68ec64eee79bd51db)

10 years agovirsh: tweak domif-getlink link state reporting message
Erik Skultety [Tue, 24 Feb 2015 16:25:55 +0000 (17:25 +0100)] 
virsh: tweak domif-getlink link state reporting message

According to docs, we only support 2 link states for an interface
up/down, 'up' being the default state if link state is unspecified in
domain's XML, so the message when no link state is provided should be
changed a little.

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

10 years agoqemu: snapshot: Don't skip check for qcow2 format with network disks
Shanzhi Yu [Sat, 28 Feb 2015 09:51:36 +0000 (17:51 +0800)] 
qemu: snapshot: Don't skip check for qcow2 format with network disks

When the domain's source disk type is network, if source protocol is rbd
or sheepdog, the 'if().. break' will end the current case, which lead to
miss check the driver type is raw or qcow2. Libvirt will allow to create
internal snapshot for a running domain with raw format disk which based
on rbd storage.

While both protocols support internal snapshots of the disk qemu is not
able to use it as it requires some place to store the memory image. The
check if the disk is backed by a qcow2 image needs to be executed
always.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1179533
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
(cherry picked from commit f7c1410b0ee5b878e81f2eddf86c609947a9b27c)