]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoqemu: fix set vcpus on host without NUMA
Pavel Hrdina [Fri, 20 Mar 2015 14:01:53 +0000 (15:01 +0100)]
qemu: fix set vcpus on host without NUMA

We don't have to modify cpuset.mems on hosts without NUMA.  It also
fixes an error message that you get instead of success if you trying
update vcpus of a guest on a host without NUMA.

error: internal error: NUMA isn't available on this host

Signer-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: cleanup setvcpus
Pavel Hrdina [Tue, 24 Mar 2015 17:22:27 +0000 (18:22 +0100)]
qemu: cleanup setvcpus

Remove unnecessary maximum variable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: move virDomainLiveConfigHelperMethod right after BeginJob
Pavel Hrdina [Tue, 24 Mar 2015 17:14:12 +0000 (18:14 +0100)]
qemu: move virDomainLiveConfigHelperMethod right after BeginJob

We should call virDomainLiveConfigHelperMethod ASAP because this
function transfers VIR_DOMAIN_AFFECT_CURRENT to VIR_DOMAIN_AFFECT_LIVE
or VIR_DOMAIN_AFFECT_CONFIG.  All other additional checks for those two
flags should consider that the user give us VIR_DOMAIN_AFFECT_CURRENT.

Remove the unnecessary check whether the domain is live in case of
VIR_DOMAIN_VCPU_GUEST because this check is done by
virDomainLiveConfigHelperMethod.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
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

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.

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.

10 years agoqemucaps2xmltest: fix the test to correspond to new domain formatting
Pavel Hrdina [Tue, 24 Mar 2015 14:22:16 +0000 (15:22 +0100)]
qemucaps2xmltest: fix the test to correspond to new domain formatting

Commit 2360fe5d updated formating of <domain> element but forgot to
update qemucaps2xmldata xml files.  In addition the test code was broken
too.  Update the xml files and return -1 if testCompareXMLToXML fails
together with indentation fix.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
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>
10 years agoqemu: Implement memory device hotunplug
Peter Krempa [Wed, 21 Jan 2015 16:45:54 +0000 (17:45 +0100)]
qemu: Implement memory device hotunplug

Add code to hot-remove memory devices from qemu. Unfortunately QEMU
doesn't support this right now, so this is just for completenes.

10 years agoqemu: Implement memory device hotplug
Peter Krempa [Sun, 12 Oct 2014 22:28:58 +0000 (00:28 +0200)]
qemu: Implement memory device hotplug

Add code to hot-add memory devices to running qemu instances.

10 years agoqemu: conf: Add support for memory device cold(un)plug
Peter Krempa [Wed, 21 Jan 2015 14:49:44 +0000 (15:49 +0100)]
qemu: conf: Add support for memory device cold(un)plug

Add a few helpers that allow to operate with memory device definitions
on the domain config and use them to implement memory device coldplug in
the qemu driver.

10 years agoqemu: add support for memory devices
Peter Krempa [Fri, 9 Jan 2015 09:40:37 +0000 (10:40 +0100)]
qemu: add support for memory devices

Add support to start qemu instance with 'pc-dimm' device. Thanks to the
refactors we are able to reuse the existing function to determine the
parameters.

10 years agoqemu: migration: Forbid migration with memory modules lacking info
Peter Krempa [Mon, 19 Jan 2015 13:28:14 +0000 (14:28 +0100)]
qemu: migration: Forbid migration with memory modules lacking info

Make sure that libvirt has all vital information needed to reliably
represent configuration of guest's memory devices in case of a
migration.

This patch forbids migration in case the required slot number and module
base address are not present (failed to be loaded from qemu via
monitor).

10 years agoqemu: memdev: Add infrastructure to load memory device information
Peter Krempa [Mon, 19 Jan 2015 12:21:09 +0000 (13:21 +0100)]
qemu: memdev: Add infrastructure to load memory device information

When using 'dimm' memory devices with qemu, some of the information
like the slot number and base address need to be reloaded from qemu
after process start so that it reflects the actual state. The state then
allows to use memory devices across migrations.

10 years agoconf: Add interface to parse and format memory device information
Peter Krempa [Mon, 29 Sep 2014 17:02:04 +0000 (19:02 +0200)]
conf: Add interface to parse and format memory device information

This patch adds code that parses and formats configuration for memory
devices.

A simple configuration would be:
<memory model='dimm'>
  <target>
    <size unit='KiB'>524287</size>
    <node>0</node>
  </target>
</memory>

A complete configuration of a memory device:
<memory model='dimm'>
  <source>
    <pagesize unit='KiB'>4096</pagesize>
    <nodemask>1-3</nodemask>
  </source>
  <target>
    <size unit='KiB'>524287</size>
    <node>1</node>
  </target>
</memory>

This patch preemptively forbids use of the <memory> device in individual
drivers so the users are warned right away that the device is not
supported.

10 years agoconf: Add device address type for dimm devices
Peter Krempa [Tue, 7 Oct 2014 16:11:47 +0000 (18:11 +0200)]
conf: Add device address type for dimm devices

Dimm devices are described by the slot and base address. Add a new
address type to be able to describe such address.

10 years agoqemu: Implement setup of memory hotplug parameters
Peter Krempa [Mon, 6 Oct 2014 12:18:37 +0000 (14:18 +0200)]
qemu: Implement setup of memory hotplug parameters

To enable memory hotplug the maximum memory size and slot count need to
be specified. As qemu supports now other units than mebibytes when
specifying memory, use the new interface in this case.

10 years agoconf: Add support for parsing and formatting max memory and slot count
Peter Krempa [Mon, 11 Aug 2014 15:40:32 +0000 (17:40 +0200)]
conf: Add support for parsing and formatting max memory and slot count

Add a XML element that will allow to specify maximum supportable memory
and the count of memory slots to use with memory hotplug.

To avoid possible confusion and misuse of the new element this patch
also explicitly forbids the use of the maxMemory setting in individual
drivers's post parse callbacks. This limitation will be lifted when the
support is implemented.

10 years agolibxl: Refactor logic in domain post parse callback
Peter Krempa [Mon, 16 Mar 2015 14:33:45 +0000 (15:33 +0100)]
libxl: Refactor logic in domain post parse callback

With the current control flow the post parse callback returned success
right away for fully virtualized VMs. To allow adding additional checks
into the post parse callback tweak the conditions so that the function
doesn't return early except for error cases.

To clarify the original piece of code borrow the wording from the commit
message for the patch that introduced the code.

10 years agoqemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject
Peter Krempa [Mon, 16 Mar 2015 14:25:58 +0000 (15:25 +0100)]
qemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject

The function comment states that @props is always consumed, even on
failure. This was not true with the failure if the monitor is not using
QMP.

10 years agoqemu: Don't return memory device config on error in qemuBuildMemoryBackendStr
Peter Krempa [Mon, 23 Mar 2015 13:17:42 +0000 (14:17 +0100)]
qemu: Don't return memory device config on error in qemuBuildMemoryBackendStr

In the last section if the function determines that the config is
invalid when QEMU doesn't support the memory device the JSON config
object would be returned even if it doesn't make sense.

Assign the object to be returned only on success.

10 years agoqemu: Set default SCSI controller model for S390 arch
Boris Fiuczynski [Fri, 20 Mar 2015 15:01:10 +0000 (16:01 +0100)]
qemu: Set default SCSI controller model for S390 arch

When no model is specified in the domain definition for
a scsi controller and the architectur is s390 than virtio-scsi
is set as default model.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix underlinking of libvirt_driver_interface.so
Natanael Copa [Mon, 23 Mar 2015 09:11:14 +0000 (10:11 +0100)]
Fix underlinking of libvirt_driver_interface.so

Always add udev linker flags when WITH_UDEV is enabled to avoid
underlinking.

See commit 43dbcb15 (interface: always build all available backends)

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
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>
10 years agonetwork_conf: Drop virNetworkObjIsDuplicate
Michal Privoznik [Sat, 14 Mar 2015 10:18:21 +0000 (11:18 +0100)]
network_conf: Drop virNetworkObjIsDuplicate

This function does not make any sense now, that network driver is
(almost) dropped. I mean, previously, when threads were
serialized, this function was there to check, if no other network
with the same name or UUID exists. However, nowadays that threads
can run more in parallel, this function is useless, in fact it
gives misleading return values. Consider the following scenario.
Two threads, both trying to define networks with same name but
different UUID (e.g. because it was generated during XML parsing
phase, whatever). Lets assume that both threads are about to call
networkValidate() which immediately calls
virNetworkObjIsDuplicate().

T1: calls virNetworkObjIsDuplicate() and since no network with
given name or UUID exist, success is returned.
T2: calls virNetworkObjIsDuplicate() and since no network with
given name or UUID exist, success is returned.

T1: calls virNetworkAssignDef() and successfully places its
network into the virNetworkObjList.
T2: calls virNetworkAssignDef() and since network with the same
name exists, the network definition is replaced.

Okay, this is mainly because virNetworkAssignDef() does not check
whether name and UUID matches. Well, lets make it so! And drop
useless function too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoobjecteventtest: Check for virNetwork* return values
Michal Privoznik [Mon, 16 Mar 2015 15:01:45 +0000 (16:01 +0100)]
objecteventtest: Check for virNetwork* return values

Lets not give a bad example and check for return values of
virNetwork* APIs called within the test. Even though it's
unlikely that any API will fail, it can happen. We're connected
to the test driver after all, and our API sequence is correct. So
test driver should fail only in case of bug or OOM.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonetworkStateInitialize: Don't lock network driver
Michal Privoznik [Fri, 13 Mar 2015 15:47:06 +0000 (16:47 +0100)]
networkStateInitialize: Don't lock network driver

There's no need to lock the network driver, as network driver
initialization is done prior accepting any client. There's nobody
to hop in and do something over partially initialized driver. Nor
qemu driver is doing that.

==30532== Observed (incorrect) order is: acquisition of lock at 0x1439EF50
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x5307E86: virObjectLock (virobject.c:323)
==30532==    by 0x5396440: virNetworkObjListForEach (network_conf.c:4511)
==30532==    by 0x19B29308: networkStateInitialize (bridge_driver.c:686)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==    by 0x4C30456: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0xA1EC1F2: start_thread (in /lib64/libpthread-2.19.so)
==30532==    by 0xA4EDC8C: clone (in /lib64/libc-2.19.so)
==30532==
==30532==  followed by a later acquisition of lock at 0x1439CD60
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x19B27B2C: networkDriverLock (bridge_driver.c:102)
==30532==    by 0x19B27B60: networkGetDnsmasqCaps (bridge_driver.c:113)
==30532==    by 0x19B2856A: networkUpdateState (bridge_driver.c:389)
==30532==    by 0x53963E9: virNetworkObjListForEachHelper (network_conf.c:4488)
==30532==    by 0x52E2224: virHashForEach (virhash.c:521)
==30532==    by 0x539645B: virNetworkObjListForEach (network_conf.c:4512)
==30532==    by 0x19B29308: networkStateInitialize (bridge_driver.c:686)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==
==30532== Required order was established by acquisition of lock at 0x1439CD60
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x19B27B2C: networkDriverLock (bridge_driver.c:102)
==30532==    by 0x19B28DF9: networkStateInitialize (bridge_driver.c:609)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==    by 0x4C30456: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0xA1EC1F2: start_thread (in /lib64/libpthread-2.19.so)
==30532==    by 0xA4EDC8C: clone (in /lib64/libc-2.19.so)
==30532==
==30532==  followed by a later acquisition of lock at 0x1439EF50
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x5307E86: virObjectLock (virobject.c:323)
==30532==    by 0x538A09C: virNetworkAssignDef (network_conf.c:527)
==30532==    by 0x5391EB2: virNetworkLoadState (network_conf.c:3008)
==30532==    by 0x53922D4: virNetworkLoadAllState (network_conf.c:3128)
==30532==    by 0x19B2929A: networkStateInitialize (bridge_driver.c:671)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==    by 0x4C30456: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0xA1EC1F2: start_thread (in /lib64/libpthread-2.19.so)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix common misspellings
Martin Kletzander [Thu, 19 Mar 2015 15:53:00 +0000 (16:53 +0100)]
Fix common misspellings

Wikipedia's list of common misspellings [1] has a machine-readable
version.  This patch fixes those misspellings mentioned in the list
which don't have multiple right variants (as e.g. "accension", which can
be both "accession" and "ascension"), such misspellings are left
untouched.  The list of changes was manually re-checked for false
positives.

[1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Migrate memory on numatune change
Martin Kletzander [Wed, 11 Mar 2015 10:17:15 +0000 (11:17 +0100)]
qemu: Migrate memory on numatune change

We've never set the cpuset.memory_migrate value to anything, keeping it
on default.  However, we allow changing cpuset.mems on live domain.
That setting, however, don't have any consequence on a domain unless
it's going to allocate new memory.

I managed to make 'virsh numatune' move all the memory to any node I
wanted even without disabling libnuma's numa_set_membind(), so this
should be safe to use with it as well.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agocgroup: Add accessors for cpuset.memory_migrate
Martin Kletzander [Wed, 11 Mar 2015 10:15:29 +0000 (11:15 +0100)]
cgroup: Add accessors for cpuset.memory_migrate

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agomaint: update .mailmap for recent contributions
Eric Blake [Fri, 20 Mar 2015 12:16:01 +0000 (06:16 -0600)]
maint: update .mailmap for recent contributions

Deepak Shetty has changed preferred email address since prior
contributions.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: use xenlight pkgconfig file if present
Jim Fehlig [Tue, 17 Mar 2015 20:10:28 +0000 (14:10 -0600)]
libxl: use xenlight pkgconfig file if present

xen.git commit babeca32 added a pkgconfig file for libxenlight,
allowing libxl apps to determine the location of Xen binaries
such as firmware blobs, device emulator, etc.

This patch adds support for xenlight.pc in the libxl driver, falling
back to the previous configure logic if not found.  It introduces
LIBXL_FIRMWARE_DIR and LIBXL_EXECBIN_DIR to define the firmware and
libexec_bin locations.  If xenlight.pc does not exist, the defines
are set to the current hardcoded paths.  The capabilities'
<emulator> and <loader> elements are updated to use the paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoparallels: fix libvirt crash if parallelsNetworkOpen fails
Maxim Nestratov [Thu, 19 Mar 2015 14:43:21 +0000 (17:43 +0300)]
parallels: fix libvirt crash if parallelsNetworkOpen fails

If, by any reason, parallelsNetworkOpen fails it dereferences
newly allocated privconn->networks via virObjectUnref, which in
turn deallocates its memory.
Subsequent call of parallelsNetworkClose calls virObjectUnref
that leads to double memory free. To prevent this we should zero
privconn->networks to make all subsequent virObjectUnref be safe.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
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>
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>
10 years agoqemu: Fix two issues in qemuDomainSetVcpus error handling
John Ferlan [Wed, 18 Mar 2015 11:10:54 +0000 (07:10 -0400)]
qemu: Fix two issues in qemuDomainSetVcpus error handling

Issue #1 - A call to virBitmapNew did not check if the allocation
failed which could lead to a NULL dereference

Issue #2 - When deleting the pin entries from the config file, the
code loops from the number of elements down to the "new" vcpu count;
however, the pin id values are numbered 0..n-1 not 1..n, so the "first"
pin attempt would never work. Luckily the check was for whether the
incoming 'n' (vcpu id) matched the entry in the array from 0..arraysize
rather than a dereference of the 'n' entry

10 years agodoc: Fix doc for backingStore
Deepak Shetty [Wed, 18 Mar 2015 13:48:22 +0000 (19:18 +0530)]
doc: Fix doc for backingStore

I spent quite some time figuring that backingStore info
isn't included in the dom xml, unless guest is up and
running. Hopefully putting that in the doc should help.

Also, several people have complained that libvirt reports
a backing file as raw, even though they expected it to be
qcow2; where the culprit is usually the user forgetting to
create the file with qemu-img create -o backing_fmt=qcow2.

This patch adds that info to the doc.

Signed-off-by: Deepak C Shetty <deepakcs@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: track 'cancelling' migration state
Eric Blake [Fri, 6 Mar 2015 16:30:14 +0000 (09:30 -0700)]
qemu: track 'cancelling' migration state

In qemu 2.3, the migration status will include 'cancelling' in the
window between when an asynchronous cancel has been requested and
when the migration is actually halted.  Previously, qemu hid this
state and reported 'active'.  Libvirt manages the sequence okay
even when the string is unrecognized (that is, it will report an
unknown state:

Migration: [ 69 %]^Cerror: internal error: unexpected migration status in cancelling.

but the migration is still cancelled), but recognizing the string
makes for a smoother user experience.

* src/qemu/qemu_monitor.h
(QEMU_MONITOR_MIGRATION_STATUS_CANCELLING): Add enum.
* src/qemu/qemu_monitor.c (qemuMonitorMigrationStatus): Map it.
* src/qemu/qemu_migration.c (qemuMigrationUpdateJobStatus): Adjust
clients.
* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONGetMigrationStatusReply): Likewise.

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

10 years agoutil: clean up #includes of virnetdevopenvswitch.h
Laine Stump [Tue, 17 Mar 2015 17:46:44 +0000 (13:46 -0400)]
util: clean up #includes of virnetdevopenvswitch.h

virnetdevopenvswitch.h declares a few functions that can be called to
add ports to and remove them from OVS bridges, and retrieve the
migration data for a port. It does not contain any data definitions
that are used by domain_conf.h. But for some reason, domain_conf.h
virnetdevopenvswitch.h should be directly #including it. This adds a
few lines to the project, but saves all the files that don't need it
from the extra computing, and makes the dependencies more clear cut.

10 years agoutil: vhost user: support for bootindex
zhang bo [Fri, 13 Mar 2015 09:17:46 +0000 (17:17 +0800)]
util: vhost user: support for bootindex

Problem Description:
When we set boot order for a vhost-user network interface, we found the boot index
doesn't work.

Cause of the Problem:
In the function qemuBuildVhostuserCommandLine(), it forcely set the arg bootindex of
function qemuBuildNicDevStr() to 0. Thus, the bootindex parameter got missing.

Solution:
Trans the arg bootindex down.

Signed-off-by: Gao Haifeng <gaohaifeng.gao@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoparallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE
Maxim Nestratov [Wed, 18 Mar 2015 08:33:57 +0000 (11:33 +0300)]
parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

network adapter is used

10 years agoparallels: switch off offline management feature
Maxim Nestratov [Wed, 18 Mar 2015 08:33:56 +0000 (11:33 +0300)]
parallels: switch off offline management feature

which is on by default when a new VM/CT is created.
We should do this because this feature can't be controlled
by libvirt now and it sets up some iptables rules. So it's
better to do this to avoid potential conflict of different
set of rules or to avoid unexpected behavior.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: make E1000 network adapter model default
Maxim Nestratov [Wed, 18 Mar 2015 08:33:55 +0000 (11:33 +0300)]
parallels: make E1000 network adapter model default

and set adapter model specified in xml

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: set correct network adapter link state
Maxim Nestratov [Wed, 18 Mar 2015 08:33:54 +0000 (11:33 +0300)]
parallels: set correct network adapter link state

when a new network adapter device is added

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: better bridge network interface support
Maxim Nestratov [Wed, 18 Mar 2015 08:33:53 +0000 (11:33 +0300)]
parallels: better bridge network interface support

In order to support 'bridge' network adapters in parallels
driver we need to plug our veth devices into corresponding
linux bridges.
We are going to do this by reusing our abstraction of
Virtual Networks in terms of PCS. On a domain creation, we
create a new Virtual Network naming it with the same name
as a source bridge for each network  interface.
Having done this, we plug PCS veth interfaces created with names of
target dev into specified bridges using our standard PCS procedures

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: fix parallelsLoadNetworks
Maxim Nestratov [Wed, 18 Mar 2015 08:33:52 +0000 (11:33 +0300)]
parallels: fix parallelsLoadNetworks

Don't fail initialization of parallels driver if
parallelsLoadNetwork fails for optional networks.
This can happen when some of them are added manually
and configured incompletely. PCS requires only two networks
created automatically (named Host-Only and Bridged), others
are optional and their incompleteness can be ignored.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: introduce and use string constants for network types and names
Maxim Nestratov [Wed, 18 Mar 2015 08:33:51 +0000 (11:33 +0300)]
parallels: introduce and use string constants for network types and names

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agomaint: Distribute tests/vircgroupdata
Jiri Denemark [Wed, 18 Mar 2015 11:13:41 +0000 (12:13 +0100)]
maint: Distribute tests/vircgroupdata

My commit 2dbfa71 added test data for vircgrouptest but forgot to
distribute the new directory.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agonetwork: Resolve Coverity FORWARD_NULL
John Ferlan [Mon, 16 Mar 2015 12:50:11 +0000 (08:50 -0400)]
network: Resolve Coverity FORWARD_NULL

The following is a long winded way to say this patch is avoiding a
false positive.

Coverity complains that calling networkPlugBandwidth() could eventually
end up with a NULL dereference on iface->bandwidth because in the
networkAllocateActualDevice there's a check of 'iface->bandwidth'
before deciding to try to use the 'portgroup' if it exists or to not
perferm the virNetDevBandwidthCopy if 'bandwidth' is not NULL.

Later in networkPlugBandwidth the 'iface->bandwidth' is sourced from
virDomainNetGetActualBandwidth - which would be either iface->bandwidth
or (preferably) iface->data.network.actual->bandwidth which would have
been filled in from either 'iface->bandwidth' or 'portgroup->bandwidth'
back in networkAllocateActualDevice

There *is* a check in networkCheckBandwidth for the result of the
virDomainNetGetActualBandwidth being NULL and a return 1 based on
that which would cause networkPlugBandwidth to exit properly and thus
never hit the condition that Coverity complains about.

However, since Coverity checks all paths - it somehow believes that
a return of 0 by networkCheckBandwidth in this condition would end
up causing the possible NULL dereference. The "fix" to silence Coverity
is to not have networkCheckBandwidth also call virDomainNetGetActualBandwidth
in order to get the ifaceBand, but rather have it accept it as an argument
which causes Coverity to "see" that it's the exit condition of 1 that won't
have the possible NULL dereference.  Since we're passing that, I added the
passing of iface->mac rather than passing iface as well. This just hopefully
makes sure someone doesn't undo this in the future...

10 years agoUse PAUSED state for domains that are starting up
Jiri Denemark [Mon, 16 Feb 2015 14:17:00 +0000 (15:17 +0100)]
Use PAUSED state for domains that are starting up

When libvirt is starting a domain, it reports the state as SHUTOFF until
it's RUNNING. This is not ideal because domain startup may take a long
time (usually because of some configuration issues, firewalls blocking
access to network disks, etc.) and domain lists provided by libvirt look
awkward. One can see weird shutoff domains with IDs in a list of active
domains or even shutoff transient domains. In any case, it looks more
like a bug in libvirt than a normal state a domain goes through.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agotests: Add tests for virCgroupDetectMounts
Jiri Denemark [Mon, 16 Mar 2015 21:36:52 +0000 (22:36 +0100)]
tests: Add tests for virCgroupDetectMounts

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemuGetDHCPInterfaces: Don't leak @network
Michal Privoznik [Tue, 17 Mar 2015 16:44:50 +0000 (17:44 +0100)]
qemuGetDHCPInterfaces: Don't leak @network

The function needs a pointer to the network to get list of DHCP
leases. The pointer is obtained via virNetworkLookupByName() which
requires callers to free the returned network once no longer needed.
Otherwise it's leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agocmdDomIfAddr: Free @ip_addr_str
Michal Privoznik [Tue, 17 Mar 2015 16:34:22 +0000 (17:34 +0100)]
cmdDomIfAddr: Free @ip_addr_str

The variable holds formatted suffix to each line printed out
(address type, address and prefix). However, the variable is
never freed. At the same time, honour fact, that data held in
the variable is not constant.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuAgentGetInterfaces: Don't error out on missing HW address
Michal Privoznik [Tue, 17 Mar 2015 16:32:24 +0000 (17:32 +0100)]
qemuAgentGetInterfaces: Don't error out on missing HW address

Now that we allow HW address to be not present on our RPC layer,
don't error out if qemu-ga hasn't provided any.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: Adapt to new HW address scenario
Michal Privoznik [Tue, 17 Mar 2015 16:28:53 +0000 (17:28 +0100)]
virsh: Adapt to new HW address scenario

Make sure we don't print (null) (which in fact is printf()'s
cleverness anyway, not ours). If no HW address is present, print
"N/A" string just like we do for other fields.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoRPC: Allow HW address in remote_domain_interface struct to be NULL
Michal Privoznik [Tue, 17 Mar 2015 16:18:02 +0000 (17:18 +0100)]
RPC: Allow HW address in remote_domain_interface struct to be NULL

Not all NICs (esp. the virtual ones like TUN) must have a hardware
address. Teach our RPC that it's possible.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: read backing chain names from qemu
Eric Blake [Wed, 11 Mar 2015 20:37:04 +0000 (14:37 -0600)]
qemu: read backing chain names from qemu

https://bugzilla.redhat.com/show_bug.cgi?id=1199182 documents that
after a series of disk snapshots into existing destination images,
followed by active commits of the top image, it is possible for
qemu 2.2 and earlier to end up tracking a different name for the
image than what it would have had when opening the chain afresh.
That is, when starting with the chain 'a <- b <- c', the name
associated with 'b' is how it was spelled in the metadata of 'c',
but when starting with 'a', taking two snapshots into 'a <- b <- c',
then committing 'c' back into 'b', the name associated with 'b' is
now the name used when taking the first snapshot.

Sadly, older qemu doesn't know how to treat different spellings of
the same filename as identical files (it uses strcmp() instead of
checking for the same inode), which means libvirt's attempt to
commit an image using solely the names learned from qcow2 metadata
fails with a cryptic:

error: internal error: unable to execute QEMU command 'block-commit': Top image file /tmp/images/c/../b/b not found

even though the file exists.  Trying to teach libvirt the rules on
which name qemu will expect is not worth the effort (besides, we'd
have to remember it across libvirtd restarts, and track whether a
file was opened via metadata or via snapshot creation for a given
qemu process); it is easier to just always directly ask qemu what
string it expects to see in the first place.

As a safety valve, we validate that any name returned by qemu
still maps to the same local file as we have tracked it, so that
a compromised qemu cannot accidentally cause us to act on an
incorrect file.

* src/qemu/qemu_monitor.h (qemuMonitorDiskNameLookup): New
prototype.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskNameLookup):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorDiskNameLookup): New function.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskNameLookup)
(qemuMonitorJSONDiskNameLookupOne): Likewise.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit)
(qemuDomainBlockJobImpl): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonetwork: Add midonet virtual port type support to qemu
Antoni Segura Puimedon [Mon, 23 Feb 2015 20:54:56 +0000 (21:54 +0100)]
network: Add midonet virtual port type support to qemu

Use the utilities introduced in the previous patches so the qemu
driver is able to create tap devices that are bound (and unbound
on domain destroyal) to Midonet virtual ports.

Signed-off-by: Antoni Segura Puimedon <toni+libvirt@midokura.com>
10 years agodocs: schema and docs for the midonet virtualport type
Antoni Segura Puimedon [Mon, 23 Feb 2015 20:54:55 +0000 (21:54 +0100)]
docs: schema and docs for the midonet virtualport type

Midonet is an opensource virtual networking that over lays the IP
network between hypervisors. Currently, such networks can be made
with the openvswitch virtualport type.

This patch, defines the schema and documentation that will serve
as basis for the follow up patches that will add support to libvirt
for using Midonet virtual ports for its interfaces. The schema
definition requires that the port profile expresses its interfaceid
as part of the port profile. For that reason, this is part of the
patch too.

Signed-off-by: Antoni Segura Puimedon <toni+libvirt@midokura.com>
10 years agoutil: functions to support binding/unbinding midonet virtualports
Antoni Segura Puimedon [Mon, 23 Feb 2015 20:54:54 +0000 (21:54 +0100)]
util: functions to support binding/unbinding midonet virtualports

Adds the port type definitions and methods that will be used to bind
interfaces to the Midonet virtual ports.

virtnetdevmidonet.c adds the way to bind and unbind the ports by
calling into the Midonet Host Agent control command line (installed
with the midolman package).

Signed-off-by: Antoni Segura Puimedon <toni+libvirt@midokura.com>
10 years agoconf: disk: Simplify checking if source definition was parsed
Peter Krempa [Thu, 12 Mar 2015 16:33:09 +0000 (17:33 +0100)]
conf: disk: Simplify checking if source definition was parsed

Previously we had to check for 3 fields to see if the source was filled.
Repurpose one of the variables as a boolean flag and use it instead of
combining multiple sources.

For the condition that checks that only CDROM/FLOPPY drives can be empty
we can use the virStorageSourceIsEmpty() helper.

10 years agoutil: storage: Fix check for empty storage device
Peter Krempa [Thu, 12 Mar 2015 16:53:01 +0000 (17:53 +0100)]
util: storage: Fix check for empty storage device

If the storage device type is parsed as network our parser still allows
it to omit the <source> element. The empty drive check would not trigger
on such device as it expects that every network storage source is valid.

Use VIR_STORAGE_NET_PROTOCOL_NONE as a marker that the storage source is
empty.

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

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

10 years agovirsh: domain: Fix the change-media command
Peter Krempa [Thu, 12 Mar 2015 15:41:21 +0000 (16:41 +0100)]
virsh: domain: Fix the change-media command

The command did not modify the disk type and thus didn't allow to change
media from a file image to a block backed image or vice versa. In
addition when operating on a network backed removable devices the
command would replace the while <source> subelement with an invalid one.

This patch adds the --block option that allows to specify that the new
image is block backed and assumes that without that option all images
are file backed. Since network backends were always mangled it should
not cause problems.

10 years agovirsh: domain: Add --print-xml flag for command change-media
Peter Krempa [Thu, 12 Mar 2015 15:04:00 +0000 (16:04 +0100)]
virsh: domain: Add --print-xml flag for command change-media

Allow printing the XML that would be used mostly for debugging purposes.

10 years agovirsh: domain: Don't use vshPrepareDiskXML for creating XML to detach disk
Peter Krempa [Thu, 12 Mar 2015 10:51:51 +0000 (11:51 +0100)]
virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach disk

Since cmdDetachDisk() calls into vshPrepareDiskXML() with
type == VSH_PREPARE_DISK_XML_NONE && source == NULL this would result
into skipping all the checks and effectively turn the function into a
XML formatter.

This patch changes the code to use the formatter directly so that the
function can be refactored in a easier way.

10 years agoparallels_sdk.c: minor cleanup
Maxim Nestratov [Tue, 17 Mar 2015 15:21:21 +0000 (18:21 +0300)]
parallels_sdk.c: minor cleanup

Fix indentation in prlsdkGetNetInf()o, remove unnecessary error
message in prlsdkDomainChangeState(), remove unnecessary job
freeing in prlsdkLoadDomains().

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodomifaddr: Add virsh support
Nehal J Wani [Sun, 25 Jan 2015 18:38:49 +0000 (00:08 +0530)]
domifaddr: Add virsh support

tools/virsh-domain-monitor.c
   * Introduce new command : domifaddr
     Usage: domifaddr <domain> [interface] [--full] [--source lease|agent]

     Example outputs:
     virsh # domifaddr f20
     Name       MAC address          Protocol     Address
     -------------------------------------------------------------------------------
     lo         00:00:00:00:00:00    ipv4         127.0.0.1/8
     -          -                    ipv6         ::1/128
     vnet0      52:54:00:2e:45:ce    ipv4         10.1.33.188/24
     -          -                    ipv6         2001:db8:0:f101::2/64
     -          -                    ipv6         fe80::5054:ff:fe2e:45ce/64
     vnet1      52:54:00:b1:70:19    ipv4         192.168.105.201/16
     -          -                    ipv4         192.168.201.195/16
     -          -                    ipv6         fe80::5054:ff:feb1:7019/64
     vnet2      52:54:00:36:2a:e5    N/A          N/A
     vnet3      52:54:00:20:70:3d    ipv4         192.168.105.240/16
     -          -                    ipv6         fe80::5054:ff:fe20:703d/64

     virsh # domifaddr f20 eth1 --source lease
     Name       MAC address          Protocol     Address
     -------------------------------------------------------------------------------
     vnet1      52:54:00:b1:70:19    ipv4         192.168.105.201/16
     -          -                    ipv4         192.168.201.195/16
     -          -                    ipv6         fe80::5054:ff:feb1:7019/64

     virsh # domifaddr f20 eth0 --source agent --full
     Name       MAC address          Protocol     Address
     -------------------------------------------------------------------------------
     eth0       52:54:00:2e:45:ce    ipv4         10.1.33.188/24
     eth0       52:54:00:2e:45:ce    ipv6         2001:db8:0:f101::2/64
     eth0       52:54:00:2e:45:ce    ipv6         fe80::5054:ff:fe2e:45ce/64

tools/virsh.pod
   * Document new command

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agodomifaddr: Implement the API for qemu
Nehal J Wani [Sun, 25 Jan 2015 18:38:48 +0000 (00:08 +0530)]
domifaddr: Implement the API for qemu

By querying the qemu guest agent with the QMP command
"guest-network-get-interfaces" and converting the received JSON
output to structured objects.

Although "ifconfig" is deprecated, IP aliases created by "ifconfig"
are supported by this API. The legacy syntax of an IP alias is:
"<ifname>:<alias-name>". Since we want all aliases to be clubbed
under parent interface, simply stripping ":<alias-name>" suffices.
Note that IP aliases formed by "ip" aren't visible to "ifconfig",
and aliases created by "ip" do not have any specific name. But
we are lucky, as qemu guest agent detects aliases created by both.

src/qemu/qemu_agent.h:
  * Define qemuAgentGetInterfaces

src/qemu/qemu_agent.c:
  * Implement qemuAgentGetInterface

src/qemu/qemu_driver.c:
  * New function qemuGetDHCPInterfaces
  * New function qemuDomainInterfaceAddresses

src/remote_protocol-sructs:
  * Define new structs

tests/qemuagenttest.c:
  * Add new test: testQemuAgentGetInterfaces
    Test cases for IP aliases, 0 or multiple ipv4/ipv6 address(es)

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agodomifaddr: Implement the remote protocol
Nehal J Wani [Sun, 25 Jan 2015 18:38:47 +0000 (00:08 +0530)]
domifaddr: Implement the remote protocol

daemon/remote.c
   * Define remoteSerializeDomainInterface, remoteDispatchDomainInterfaceAddresses

src/remote/remote_driver.c
   * Define remoteDomainInterfaceAddresses

src/remote/remote_protocol.x
   * New RPC procedure: REMOTE_PROC_DOMAIN_INTERFACE_ADDRESSES
   * Define structs remote_domain_ip_addr, remote_domain_interface,
     remote_domain_interfaces_addresse_args, remote_domain_interface_addresses_ret
   * Introduce upper bounds (to handle DoS attacks):
     REMOTE_DOMAIN_INTERFACE_MAX = 2048
     REMOTE_DOMAIN_IP_ADDR_MAX = 2048
     Restrictions on the maximum number of aliases per interface were
     removed after kernel v2.0, and theoretically, at present, there
     are no upper limits on number of interfaces per virtual machine
     and on the number of IP addresses per interface.

src/remote_protocol-structs
   * New structs added

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agodomifaddr: Implement the public APIs
Nehal J Wani [Sun, 25 Jan 2015 18:38:46 +0000 (00:08 +0530)]
domifaddr: Implement the public APIs

Define helper function virDomainInterfaceFree, which allows
the upper layer application to free the domain interface object
conveniently.

The API is going to provide multiple methods by flags, e.g.
  * Query guest agent
  * Parse DHCP lease file

include/libvirt/libvirt-domain.h
  * Define virDomainInterfaceAddresses, virDomainInterfaceFree
  * Define structs virDomainInterface, virDomainIPAddress

src/driver-hypervisor.h:
  * Define domainInterfaceAddresses

src/libvirt-domain.c:
  * Implement virDomainInterfaceAddresses
  * Implement virDomainInterfaceFree

src/libvirt_public.syms:
  * Export the new symbols

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agoparallels: fix home directory for VMs
Maxim Nestratov [Fri, 13 Mar 2015 15:40:42 +0000 (18:40 +0300)]
parallels: fix home directory for VMs

Failures of parallelsStorageOpen occured because we incorrectly treated
path to VM' configuration file as a directory. Now initialization of
parallels VM domains home directory is fixed.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: don't forget to unlock domain if unregister fails
Maxim Nestratov [Fri, 13 Mar 2015 15:40:41 +0000 (18:40 +0300)]
parallels: don't forget to unlock domain if unregister fails

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: set cpu mode when applying xml configuration
Mikhail Feoktistov [Fri, 13 Mar 2015 15:40:40 +0000 (18:40 +0300)]
parallels: set cpu mode when applying xml configuration

Otherwise exporting existing domain config and defining a new one like this:
virsh -c parallels:///system dumpxml instance01 > my.xml
virsh -c parallels:///system define my.xml
leads to an error because PCS default x64 mode turns to x32.
Thus, we need to set correct cpuMode in prlsdkDoApplyConfig() explicitly.

Signed-off-by: Mikhail Feoktistov <mfeoktistov@parallels.com>
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Use correct type for balloon stats period
Martin Kletzander [Fri, 13 Mar 2015 16:08:15 +0000 (17:08 +0100)]
conf: Use correct type for balloon stats period

We're parsing memballoon status period as unsigned int, but when we're
trying to set it, both we and qemu use signed int.  That means large
values will get wrapped around to negative one resulting in error.
Basically the same problem as commit e3a7b874 was dealing with when
updating live domain.

QEMU changed the accepted value to int64 in commit 1f9296b5, but even
values as INT_MAX don't make sense since the value passed means seconds.
Hence adding capability flag for this change isn't worth it.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Don't duplicate errors when settings stats period
Martin Kletzander [Fri, 13 Mar 2015 16:05:32 +0000 (17:05 +0100)]
qemu: Don't duplicate errors when settings stats period

In order not to leave old error messages set, this patch refactors the
code so the error is reported only when acted upon.  The only such place
already rewrites any error, so cleaning up all the error reporting in
qemuMonitorSetMemoryStatsPeriod() is enough.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: Reorder elements inside memballoon
Martin Kletzander [Fri, 13 Mar 2015 15:16:57 +0000 (16:16 +0100)]
conf: Reorder elements inside memballoon

All the devices we have format their address as its last sub-element, so
let's change memballoon to follow suit.  Also adjust RNG to allow any
order of them so 'virsh edit' doesn't shout at us.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoutil: Make sure the comment about virBufferAddBuffer is true
Martin Kletzander [Fri, 13 Mar 2015 15:41:42 +0000 (16:41 +0100)]
util: Make sure the comment about virBufferAddBuffer is true

Change it so it really *always* eats the @toadd buffer.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agowireshark: fix VPATH build
Pavel Hrdina [Tue, 17 Mar 2015 10:36:02 +0000 (11:36 +0100)]
wireshark: fix VPATH build

Add $(top_builddir) paths to INCLUDES to fix VPATH build.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu_command: Fix some indentation and a typo
Luyao Huang [Tue, 17 Mar 2015 02:34:26 +0000 (10:34 +0800)]
qemu_command: Fix some indentation and a typo

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agorpm-build: use pkg-config to detect wireshark presence
Pavel Hrdina [Mon, 16 Mar 2015 11:52:13 +0000 (12:52 +0100)]
rpm-build: use pkg-config to detect wireshark presence

Wireshark supports pkg-config since 1.11.3.  Right now we build
wireshark-dissectior tool as default trough rpm build only on
fedora >= 21 and there is new wireshark that supports pkg-config.
If someone wants to build libvirt with wireshark-dissector against old
wireshark, they should specify the location by hand.

This patch is mainly to fix wrong dependency on wireshark binary as it
doesn't make sense to require that binary file to just get version info
of that package in makefile.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agolibxl: fix regression introduced by commit 4ab8cd77
Jim Fehlig [Sat, 14 Mar 2015 00:36:04 +0000 (18:36 -0600)]
libxl: fix regression introduced by commit 4ab8cd77

Commit 4ab8cd77 added a check requiring input devices to have
a bus type of VIR_DOMAIN_INPUT_BUS_USB, failing to start the
domain otherwise.  But virDomainDefParseXML adds implicit mouse
and keyboard if a graphics device is configured.  See calls to
virDomainDefMaybeAddInput.

The regression is fixed by removing the check requiring USB input
devices, and skipping non-USB input devices when populating USB
'usbdevice' in libxl_domain_build_info struct.

10 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.

10 years agodaemon: avoid memleak when ListAll returns nothing
Eric Blake [Fri, 13 Mar 2015 23:01:43 +0000 (17:01 -0600)]
daemon: avoid memleak when ListAll returns nothing

Commit 4f25146 (v1.2.8) managed to silence Coverity, but at the
cost of a memory leak detected by valgrind:
==24129== 40 bytes in 5 blocks are definitely lost in loss record 355 of 637
==24129==    at 0x4A08B1C: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==24129==    by 0x5084B8E: virReallocN (viralloc.c:245)
==24129==    by 0x514D5AA: virDomainObjListExport (domain_conf.c:22200)
==24129==    by 0x201227DB: qemuConnectListAllDomains (qemu_driver.c:18042)
==24129==    by 0x51CC1B6: virConnectListAllDomains (libvirt-domain.c:6797)
==24129==    by 0x14173D: remoteDispatchConnectListAllDomains (remote.c:1580)
==24129==    by 0x121BE1: remoteDispatchConnectListAllDomainsHelper (remote_dispatch.h:1072)

In short, every time a client calls a ListAll variant and asks
for the resulting list, but there are 0 elements to return, we
end up leaking the 1-entry array that holds the NULL terminator.

What's worse, a read-only client can access these functions in a
tight loop to cause libvirtd to eventually run out of memory; and
this can be considered a denial of service attack against more
privileged clients.  Thankfully, the leak is so small (8 bytes per
call) that you would already have some other denial of service with
any guest calling the API that frequently, so an out-of-memory
crash is unlikely enough that this did not warrant a CVE.

* daemon/remote.c (remoteDispatchConnectListAllDomains)
(remoteDispatchDomainListAllSnapshots)
(remoteDispatchDomainSnapshotListAllChildren)
(remoteDispatchConnectListAllStoragePools)
(remoteDispatchStoragePoolListAllVolumes)
(remoteDispatchConnectListAllNetworks)
(remoteDispatchConnectListAllInterfaces)
(remoteDispatchConnectListAllNodeDevices)
(remoteDispatchConnectListAllNWFilters)
(remoteDispatchConnectListAllSecrets)
(remoteDispatchNetworkGetDHCPLeases): Plug leak.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoRemove virDomainIOThreadsPinDel
John Ferlan [Wed, 11 Mar 2015 20:47:15 +0000 (16:47 -0400)]
Remove virDomainIOThreadsPinDel

This one is no longer necessary since the Vcpu and IOThreads API's share

10 years agoReplace virDomainVcpuPinDel with virDomainPinDel
John Ferlan [Wed, 11 Mar 2015 20:42:44 +0000 (16:42 -0400)]
Replace virDomainVcpuPinDel with virDomainPinDel

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoReplace virDomainIOThreadsPinAdd with virDomainPinAdd
John Ferlan [Wed, 11 Mar 2015 20:22:33 +0000 (16:22 -0400)]
Replace virDomainIOThreadsPinAdd with virDomainPinAdd

This one is no longer necessary since the Vcpu and IOThreads API's share

10 years agoReplace virDomainVcpuPinAdd with virDomainPinAdd
John Ferlan [Wed, 11 Mar 2015 20:17:56 +0000 (16:17 -0400)]
Replace virDomainVcpuPinAdd with virDomainPinAdd

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinFindByVcpu into virDomainPinFindByVcpu
John Ferlan [Wed, 11 Mar 2015 00:31:44 +0000 (20:31 -0400)]
Convert virDomainVcpuPinFindByVcpu into virDomainPinFindByVcpu

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinIsDuplicate into virDomainPinIsDuplicate
John Ferlan [Wed, 11 Mar 2015 00:27:39 +0000 (20:27 -0400)]
Convert virDomainVcpuPinIsDuplicate into virDomainPinIsDuplicate

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinDefCopy into virDomainPinDefCopy
John Ferlan [Wed, 11 Mar 2015 00:24:04 +0000 (20:24 -0400)]
Convert virDomainVcpuPinDefCopy into virDomainPinDefCopy

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinDefArrayFree to virDomainPinDefArrayFree
John Ferlan [Wed, 11 Mar 2015 00:19:35 +0000 (20:19 -0400)]
Convert virDomainVcpuPinDefArrayFree to virDomainPinDefArrayFree

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinDefFree to virDomainPinDefFree
John Ferlan [Wed, 11 Mar 2015 00:15:45 +0000 (20:15 -0400)]
Convert virDomainVcpuPinDefFree to virDomainPinDefFree

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainPinDefPtr->vcpuid to virDomainPinDefPtr->id
John Ferlan [Wed, 11 Mar 2015 00:10:54 +0000 (20:10 -0400)]
Convert virDomainPinDefPtr->vcpuid to virDomainPinDefPtr->id

Since we're not specifically a vcpu related structure anymore...

10 years agoConvert virDomainVcpuPinDefPtr to virDomainPinDefPtr
John Ferlan [Sat, 14 Mar 2015 02:50:26 +0000 (22:50 -0400)]
Convert virDomainVcpuPinDefPtr to virDomainPinDefPtr

As pointed out by jtomko in his review of the IOThreads pinning code:

http://www.redhat.com/archives/libvir-list/2015-March/msg00495.html

there are some comments sprinkled in indicating IOThreads were using
the same structure as the VcpuPin code...

This is the first patch of a few that will change the virDomainVcpuPin*
structures and code to just virDomainPin* - starting with the data
structure naming...

10 years agoqemu: Fix possible memory leak in qemuDomainPinVcpuFlags
John Ferlan [Mon, 9 Mar 2015 22:41:04 +0000 (18:41 -0400)]
qemu: Fix possible memory leak in qemuDomainPinVcpuFlags

During his review of the iothreads pin setting code, Pavel noted that
there was a potential memory leak with respect to how the newVcpuPin
is handled and the goto endjob's in failure paths which would not free
the memory.  For reference, See:

http://www.redhat.com/archives/libvir-list/2015-March/msg00415.html

10 years agoconf: Make specifying <memory> optional
Peter Krempa [Wed, 4 Mar 2015 10:04:27 +0000 (11:04 +0100)]
conf: Make specifying <memory> optional

Now that the size of guest's memory can be inferred from the NUMA
configuration (if present) make it optional to specify <memory>
explicitly.

To make sure that memory is specified add a check that some form of
memory size was specified. One side effect of this change is that it is
no longer possible to specify 0KiB as memory size for the VM, but I
don't think it would be any useful to do so. (I can imagine embedded
systems without memory, just registers, but that's far from what libvirt
is usually doing).

Forbidding 0 memory for guests also fixes a few corner cases where 0 was
not interpreted correctly and caused failures. (Arguments for numad when
using automatic placement, size of the balloon). This fixes problems
described in https://bugzilla.redhat.com/show_bug.cgi?id=1161461

Test case changes are added to verify that the schema change and code
behave correctly.

10 years agoconf: Automatically use NUMA memory size in case NUMA is enabled
Peter Krempa [Wed, 18 Feb 2015 13:02:39 +0000 (14:02 +0100)]
conf: Automatically use NUMA memory size in case NUMA is enabled

Use the NUMA total instead of the configured size both in XML and for
uses in the code once NUMA is enabled for a domain.

One test case change is necessary as the rounding of the individual cell
sizes was not matching the rounding of the total size.