]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agovirBitmap: Place virBitmapIsAllClear check after virBitmapParse calls
Erik Skultety [Fri, 10 Apr 2015 09:11:21 +0000 (11:11 +0200)]
virBitmap: Place virBitmapIsAllClear check after virBitmapParse calls

This patch adds checks for empty bitmaps right after the calls of
virBitmapParse. These only include spots where set API's are called and
where domain's XML is parsed.
Also, it partially reverts commit 983f5a which added a check for
invalid nodeset "0,^0" into virBitmapParse function. This change broke
the logic, as an empty bitmap should not cause an error.

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

10 years agoRemove feature formating funcs from pool-specific options
Ján Tomko [Thu, 9 Apr 2015 12:02:53 +0000 (14:02 +0200)]
Remove feature formating funcs from pool-specific options

We only have one formatting function for the features.

10 years agoVisually separate snapshot disk subelements
Ján Tomko [Fri, 10 Apr 2015 12:25:37 +0000 (14:25 +0200)]
Visually separate snapshot disk subelements

Create four smaller blocks of texts instead of one large one.

10 years agoRewrite usb device version parsing
Ján Tomko [Fri, 10 Apr 2015 13:50:53 +0000 (15:50 +0200)]
Rewrite usb device version parsing

Simplify the function by leaving out the local copy and checking
return values of virStrToLong.

10 years agoFix usb device version parsing issues
Ján Tomko [Fri, 10 Apr 2015 13:49:42 +0000 (15:49 +0200)]
Fix usb device version parsing issues

Request that the number be parsed as decimal, to allow 08
and 09.

Format it with the leading zero, 1.01 and 1.10 are two
different versions.

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

10 years agoDo xml->xml test for usb-redir-filter
Ján Tomko [Fri, 10 Apr 2015 13:03:07 +0000 (15:03 +0200)]
Do xml->xml test for usb-redir-filter

We don't format the default '-1' fields back.

10 years agoDo not require virtio-pci devices when using virtio-mmio
Ján Tomko [Fri, 10 Apr 2015 09:22:05 +0000 (11:22 +0200)]
Do not require virtio-pci devices when using virtio-mmio

On arm, we probe for virtio-*-pci devices, but use their
virtio-*-device variants.

Set the capabilities based on the -device variants as well,
to make them work with qemus with the PCI devices compiled out.

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>
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>
10 years agoconf: Don't output <cpu> tag if it contains no information.
Andrea Bolognani [Fri, 10 Apr 2015 13:09:59 +0000 (15:09 +0200)]
conf: Don't output <cpu> tag if it contains no information.

The tag is already marked as optional in the schema, so no changes
are needed there.

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

10 years agoqemu: qemuDomainHotplugVcpus - separate out pin adjustment code
John Ferlan [Wed, 8 Apr 2015 13:25:47 +0000 (09:25 -0400)]
qemu: qemuDomainHotplugVcpus - separate out pin adjustment code

Future IOThread setting patches would copy the code anyway, so create
and generalize the adding of pindef for the vcpu and the pinning of the
thread into their own APIs.

10 years agoAUTHORS: Add my email address to AUTHORS.in
Dmitry Guryanov [Fri, 10 Apr 2015 15:26:00 +0000 (18:26 +0300)]
AUTHORS: Add my email address to AUTHORS.in

10 years agoSupport IPv6 in networkGetNetworkAddress
Ján Tomko [Wed, 8 Apr 2015 14:36:42 +0000 (16:36 +0200)]
Support IPv6 in networkGetNetworkAddress

We've been explicitly requesting IPv4 for some reason,
even if there were only IPv6 addresses in the network
definition.

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

10 years agoutil: Update virNetDevGetIPAddress to get IPv6 addresses
Luyao Huang [Tue, 10 Mar 2015 00:04:58 +0000 (20:04 -0400)]
util: Update virNetDevGetIPAddress to get IPv6 addresses

Add static virNetDevGetifaddrsAddress to attempt to get the interface
IP address. If getifaddrs is not supported, fall back to
virNetDevGetIPv4AddressIoctl to get the IP address.

This allows IPv6 addresses to be used for <listen type='network>
with device-backed networks.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoutil: Replace virNetDevGetIPv4Address with virNetDevGetIPAddress
John Ferlan [Tue, 10 Mar 2015 00:04:57 +0000 (20:04 -0400)]
util: Replace virNetDevGetIPv4Address with virNetDevGetIPAddress

Rename it to virNetDevGetIPv4AddressIoctl and make
virNetDevGetIPAddress a wrapper around it, allowing
other ways of getting the address to be implemented,
and still falling back to the old method.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoparallels: fix virDomainDefineXML for domain in saved state
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:13 +0000 (23:35 +0300)]
parallels: fix virDomainDefineXML for domain in saved state

PCS doesn't store domain config in managed save state file.
It's forbidden to change config for VMs in this state.
It's possible to change config for containers, but after
restoring domain will have that new config, not a config,
which domain had at the moment of virDomainManagedSave.

So we need to handle this case differently from other states.
Let's forbid this operation, if config is changed and if it's
not changed - just do nothing.

Openstack/nova calls virDomainDefineXML on resume with
current domain config, so we can't forbid this operation
in managed save state.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: fix virDomainDefFormatInternal for parallels
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:12 +0000 (23:35 +0300)]
conf: fix virDomainDefFormatInternal for parallels

We should add input devices with proper bus,
not VIR_DOMAIN_INPUT_BUS_XEN.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: fix virDomainDefParseXML for parallels
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:11 +0000 (23:35 +0300)]
conf: fix virDomainDefParseXML for parallels

Handle input devices in virDomainDefParseXML properly
in case of parallels containers and VMs.

Parallels containers support only
VIR_DOMAIN_INPUT_BUS_PARALLELS. And if VNC is enabled
we should add implicit mouse and keyboard.

For VMs we should add implicit PS/2 mouse and
keyboard.

BTW, is it worth to refactor code and move
all this code to drivers, to *DomainDefPostParse
functions?

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: add implicit input devices
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:10 +0000 (23:35 +0300)]
parallels: add implicit input devices

Add implicit input devices in parallelsLoadDomains,
when VNC is enabled.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: add input device type for parallels containers
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:09 +0000 (23:35 +0300)]
conf: add input device type for parallels containers

Add VIR_DOMAIN_INPUT_BUS_PARALLELS device type
to handle domain configuration properly for
parallels containers, when VNC is enabled.

When domain configuration has at least one
'graphics', there should be mouse and keyboard.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: return proper default video type for parallels
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:08 +0000 (23:35 +0300)]
conf: return proper default video type for parallels

Fix function virDomainVideoDefaultType for
parallels VMs and containers. It should return
VGA for VMs and VIR_DOMAIN_VIDEO_TYPE_PARALLELS
for containers.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: add VIR_DOMAIN_VIDEO_TYPE_PARALLELS video type
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:07 +0000 (23:35 +0300)]
conf: add VIR_DOMAIN_VIDEO_TYPE_PARALLELS video type

We support VNC for containers to have the same
interface with VMs. At this moment it just renders
linux text console.

Of course we don't pass any physical devices and
don't emulate virtual devices. Our VNC server
renders text from terminal master and sends
input events from VNC client to terminal.

So add special video type VIR_DOMAIN_VIDEO_TYPE_PARALLELS
for these pseudo-devices.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: don't fill net adapter model for containers
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:06 +0000 (23:35 +0300)]
parallels: don't fill net adapter model for containers

Network adapter model has no sense for container,
so we shouldn't set it to e1000 in
parallelsDomainDeviceDefPostParse.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: fill adapter model in virDomainNetDef
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:05 +0000 (23:35 +0300)]
parallels: fill adapter model in virDomainNetDef

We handle this parameter for VMs while defining
domains, so let's get this property from PCS and
set corresponding field of virDomainNetDef in
prlsdkLoadDomains function.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: add controllers in prlsdkLoadDomain
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:04 +0000 (23:35 +0300)]
parallels: add controllers in prlsdkLoadDomain

Call virDomainDefAddImplicitControllers to add disk
controllers, so virDomainDef, filled by this function
will look exactly like the one returned by virDomainDefParseString.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: report, that cdroms are readonly
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:03 +0000 (23:35 +0300)]
parallels: report, that cdroms are readonly

Set readonly flag for cdrom devices when we
retrieve a list of domains from PCS.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: implement virDomainManagedSave
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:02 +0000 (23:35 +0300)]
parallels: implement virDomainManagedSave

Implement virDomainManagedSave api function. In PCS
this feature called "suspend". You can suspend VM or
CT while it is in running or paused state. And after
resuming (or starting) it will have the same state, as
before suspend.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: split prlsdkDomainChangeState function
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:01 +0000 (23:35 +0300)]
parallels: split prlsdkDomainChangeState function

Split function prlsdkDomainChangeState into
prlsdkDomainChangeStateLocked and prlsdkDomainChangeState.
So it can be used from places, where virDomainObj already
found and locked.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: fix headers in parallels_sdk.h
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:00 +0000 (23:35 +0300)]
parallels: fix headers in parallels_sdk.h

Return value of functions prlsdkStart/Kill/Stop e.t.c.
is PRL_RESULT in parallels_sdk.c and int in parallels_sdk.h.
PRL_RESULT is int, so compiler didn't report errors.
Let's fix the difference.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoqemu: qemuDomainHotplugVcpus - separate out the del cgroup and pin
John Ferlan [Thu, 19 Mar 2015 13:46:09 +0000 (09:46 -0400)]
qemu: qemuDomainHotplugVcpus - separate out the del cgroup and pin

Future IOThread setting patches would copy the code anyway, so create
and generalize a delete cgroup and pindef for the vcpu into its own API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoqemu: qemuDomainHotplugVcpus - separate out the add cgroup
John Ferlan [Thu, 19 Mar 2015 12:28:14 +0000 (08:28 -0400)]
qemu: qemuDomainHotplugVcpus - separate out the add cgroup

Future IOThread setting patches would copy the code anyway, so create
and generalize the add the vcpu to a cgroup into its own API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agocgroup: Use virCgroupNewThread
John Ferlan [Tue, 7 Apr 2015 12:53:35 +0000 (08:53 -0400)]
cgroup: Use virCgroupNewThread

Replace the virCgroupNew{Vcpu|Emulator|IOThread} calls with the common
virCgroupNewThread API

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agocgroup: Introduce virCgroupNewThread
John Ferlan [Tue, 7 Apr 2015 12:28:05 +0000 (08:28 -0400)]
cgroup: Introduce virCgroupNewThread

Create a new common API to replace the virCgroupNew{Vcpu|Emulator|IOThread}
API's using an emum to generate the cgroup name

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agostorage: Don't duplicate efforts of backend driver
John Ferlan [Fri, 27 Mar 2015 15:19:54 +0000 (11:19 -0400)]
storage: Don't duplicate efforts of backend driver

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

If the backend driver updates the pool available and/or allocation values,
then the storage_driver VolCreateXML, VolCreateXMLFrom, and VolDelete APIs
should not change the value; otherwise, it will appear as if the values
were "doubled" for each change.  Additionally since unsigned arithmetic will
be used depending on the size and operation, either or both values could be
appear to be much larger than they should be (in the EiB range).

Currently only the disk pool updates the values, but other pools could.
Assume a "fresh" disk pool of 500 MiB using /dev/sde:

$ virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     0.00 B
Available:      509.84 MiB

$ virsh vol-create-as disk-pool sde1 --capacity 300M

$ virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     600.47 MiB
Available:      16.00 EiB

Following assumes disk backend updated to refresh the disk pool at deletion
of primary partition as well as extended partition:

$ virsh vol-delete --pool disk-pool sde1
Vol sde1 deleted

$ virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     9.73 EiB
Available:      6.27 EiB

This patch will check if the backend updated the pool values and honor that
update.

10 years agostorage: Need to update freeExtent at delete primary partition
John Ferlan [Fri, 27 Mar 2015 15:04:22 +0000 (11:04 -0400)]
storage: Need to update freeExtent at delete primary partition

Commit id '471e1c4e' only considered updating the pool if the extended
partition was removed. As it turns out removing a primary partition
would also need to update the freeExtent list otherwise the following
sequence would fail (assuming a "fresh" disk pool for /dev/sde of 500M):

$  virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     0.00 B
Available:      509.84 MiB

$ virsh vol-create-as disk-pool sde1 --capacity 300M
$ virsh vol-delete --pool disk-pool sde1
$ virsh vol-create-as disk-pool sde1 --capacity 300M
error: Failed to create vol sde1
error: internal error: no large enough free extent

$

This patch will refresh the pool, rereading the partitions, and
return

10 years agostorage: Fix issues in storageVolResize
John Ferlan [Fri, 27 Mar 2015 13:48:59 +0000 (09:48 -0400)]
storage: Fix issues in storageVolResize

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

When creating a volume in a pool, the creation allows the 'capacity'
value to be larger than the available space in the pool. As long as
the 'allocation' value will fit in the space, the volume will be created.

However, resizing the volume checks were made with the new absolute
capacity value against existing capacity + the available space without
regard for whether the new absolute capacity was actually allocating
space or not.  For example, a pool with 75G of available space creates
a volume of 10G using a capacity of 100G and allocation of 10G will succeed;
however, if the allocation used a capacity of 10G instead and then tried
to resize the allocation to 100G the code would fail to allow the backend
to try the resize.

Furthermore, when updating the pool "available" and "allocation" values,
the resize code would just "blindly" adjust them regardless of whether
space was "allocated" or just "capacity" was being adjusted.  This left
a scenario whereby a resize to 100G would fail; however, a resize to 50G
followed by one to 100G would both succeed.  Again, neither was adjusting
the allocation value, just the "capacity" value.

This patch adds more logic to the resize code to understand whether the
new capacity value is actually "allocating" space as well and whether it
shrinking or expanding. Since unsigned arithmatic is involved, the possibility
that we adjust the pool size values incorrectly is probable.

This patch also ensures that updates to the pool values only occur if we
actually performed the allocation.

NB: The storageVolDelete, storageVolCreateXML, and storageVolCreateXMLFrom
each only updates the pool allocation/availability values by the target
volume allocation value.

10 years agoqemu: Avoid shadow of 'sync' symbol
Peter Krempa [Thu, 9 Apr 2015 13:36:26 +0000 (15:36 +0200)]
qemu: Avoid shadow of 'sync' symbol

Old compilers whine that 'sync' is being shadowed in the function
introduced in 1eccac1d2da7bbe97e1df25fd0ddac6e71b0794a.

10 years agoqemu: blockPivot: Don't pause the VM any more since we don't use drive-reopen
Peter Krempa [Wed, 1 Apr 2015 08:13:34 +0000 (10:13 +0200)]
qemu: blockPivot: Don't pause the VM any more since we don't use drive-reopen

Support for drive-reopen was never present in the upstream code so we
don't need to pause the VM when doing the block pivot. Kill all the
code related to this semi-upstream artifact.

10 years agoqemu: Clean up old leftovers in qemuMonitorDrivePivot
Peter Krempa [Wed, 1 Apr 2015 08:06:55 +0000 (10:06 +0200)]
qemu: Clean up old leftovers in qemuMonitorDrivePivot

There are two leftover unused variables. Remove them and clean up the
fallout of the change.

10 years agoqemu: blockjob: Use the new helpers in qemuDomainGetBlockJobInfo
Peter Krempa [Wed, 1 Apr 2015 07:36:04 +0000 (09:36 +0200)]
qemu: blockjob: Use the new helpers in qemuDomainGetBlockJobInfo

Refactor the function to use the new helpers.

10 years agoqemu: domain: Add helper to check block job support
Peter Krempa [Tue, 31 Mar 2015 15:29:35 +0000 (17:29 +0200)]
qemu: domain: Add helper to check block job support

We need to check that qemu supports block jobs in multiple places. Add a
helper to do the check.

10 years agoqemu: domain: Introduce helper to retrieve domain monitor object
Peter Krempa [Tue, 31 Mar 2015 15:24:50 +0000 (17:24 +0200)]
qemu: domain: Introduce helper to retrieve domain monitor object

In some cases where the function does not need to access the private
data this helper may be used to retrieve the monitor object.

10 years agodoc: Add info (where necessary) that paths should be specified as absolute
Erik Skultety [Tue, 7 Apr 2015 10:46:13 +0000 (12:46 +0200)]
doc: Add info (where necessary) that paths should be specified as absolute

We documented this almost everywhere, but missed it on several places.

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

10 years agoOpen /proc/PID/ns/* read-only to avoid getting permission denied
Cédric Bosdonnat [Thu, 9 Apr 2015 07:22:43 +0000 (09:22 +0200)]
Open /proc/PID/ns/* read-only to avoid getting permission denied

lxc-enter-namespace stopped working on recent kernels (at least 3.19+)
due to /proc/PID/ns/* file descriptors being opened RW. From outside
the namespace these can only be opened RO.

10 years agoApparmor qemu abstraction fixes for SLES
Cédric Bosdonnat [Wed, 11 Mar 2015 10:09:40 +0000 (11:09 +0100)]
Apparmor qemu abstraction fixes for SLES

SLES 11 has legacy qemu-kvm package, /usr/bin/qemu-kvm and
/usr/share/qemu-kvm need to be accessed to domains.

10 years agolxc: create the required directories upon driver start
Lubomir Rintel [Wed, 8 Apr 2015 17:16:52 +0000 (19:16 +0200)]
lxc: create the required directories upon driver start

/var/run may reside on a tmpfs and we fail to create the PID file if
/var/run/lxc does not exist.

Since commit 0a8addc1, the lxc driver's state directory isn't
automatically created before starting a domain. Now, the lxc driver
makes sure the state directory exists when it initializes.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
10 years agoutil: file: Don't carelessly sanitize URIs
Peter Krempa [Wed, 8 Apr 2015 08:57:07 +0000 (10:57 +0200)]
util: file: Don't carelessly sanitize URIs

rfc3986 states that the separator in URI path is a single slash.
Multiple slashes may potentially lead to different resources and thus we
should not remove them.

10 years agotest: Add tests for virFileSanitizePath
Peter Krempa [Wed, 8 Apr 2015 08:27:30 +0000 (10:27 +0200)]
test: Add tests for virFileSanitizePath

Add test infrastructure for virFileSanitizePath so that it can be
sensibly refactored later.

10 years agovirLXCControllerSetupResourceLimits: Call virNuma*() iff needed
Michal Privoznik [Fri, 27 Mar 2015 10:44:55 +0000 (11:44 +0100)]
virLXCControllerSetupResourceLimits: Call virNuma*() iff needed

Like we are doing in qemu driver (ea576ee543d6fb95583), lets call
virNumaSetupMemoryPolicy() only if really needed. Problem is, if
we numa_set_membind() child, there's no way to change it from the
daemon afterwards. So any later attempts to change the pinning
will fail. But in very weird way - CGroups will be set, but due
to membind child will not allocate memory from any other node.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agofix memleak in qemuRestoreCgroupState
Luyao Huang [Wed, 8 Apr 2015 06:25:59 +0000 (14:25 +0800)]
fix memleak in qemuRestoreCgroupState

 131,088 bytes in 16 blocks are definitely lost in loss record 2,174 of 2,176
    at 0x4C29BFD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4C2BACB: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x52A026F: virReallocN (viralloc.c:245)
    by 0x52BFCB5: saferead_lim (virfile.c:1268)
    by 0x52C00EF: virFileReadLimFD (virfile.c:1328)
    by 0x52C019A: virFileReadAll (virfile.c:1351)
    by 0x52A5D4F: virCgroupGetValueStr (vircgroup.c:763)
    by 0x1DDA0DA3: qemuRestoreCgroupState (qemu_cgroup.c:805)
    by 0x1DDA0DA3: qemuConnectCgroup (qemu_cgroup.c:857)
    by 0x1DDB7BA1: qemuProcessReconnect (qemu_process.c:3694)
    by 0x52FD171: virThreadHelper (virthread.c:206)
    by 0x82B8DF4: start_thread (pthread_create.c:308)
    by 0x85C31AC: clone (clone.S:113)

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agovbox: Implement virDomainSendKey
Dawid Zamirski [Tue, 7 Apr 2015 15:37:36 +0000 (11:37 -0400)]
vbox: Implement virDomainSendKey

Since the holdtime is not supported by VBOX SDK, it's being simulated
by sleeping before sending the key-up codes. The key-up codes are
auto-generated based on XT codeset rules (adding of 0x80 to key-down)
which results in the same behavior as for QEMU implementation.

10 years agovbox: Register IKeyboard with the unified API.
Dawid Zamirski [Tue, 7 Apr 2015 15:37:35 +0000 (11:37 -0400)]
vbox: Register IKeyboard with the unified API.

The IKeyboard COM object is needed to implement virDomainSendKey and is
available in all supported VBOX versions.

10 years agoqemuProcessHook: Call virNuma*() only when needed
Michal Privoznik [Fri, 27 Mar 2015 10:39:45 +0000 (11:39 +0100)]
qemuProcessHook: Call virNuma*() only when needed

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

Once upon a time, there was a little domain. And the domain was pinned
onto a NUMA node and hasn't fully allocated its memory:

  <memory unit='KiB'>2355200</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>

  <numatune>
    <memory mode='strict' nodeset='0'/>
  </numatune>

Oh little me, said the domain, what will I do with so little memory.
If I only had a few megabytes more. But the old admin noticed the
whimpering, barely audible to untrained human ear. And good admin he
was, he gave the domain yet more memory. But the old NUMA topology
witch forbade to allocate more memory on the node zero. So he
decided to allocate it on a different node:

virsh # numatune little_domain --nodeset 0-1

virsh # setmem little_domain 2355200

The little domain was happy. For a while. Until bad, sharp teeth
shaped creature came. Every process in the system was afraid of him.
The OOM Killer they called him. Oh no, he's after the little domain.
There's no escape.

Do you kids know why? Because when the little domain was born, her
father, Libvirt, called numa_set_membind(). So even if the admin
allowed her to allocate memory from other nodes in the cgroups, the
membind() forbid it.

So what's the lesson? Libvirt should rely on cgroups, whenever
possible and use numa_set_membind() as the last ditch effort.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovircgroup: Introduce virCgroupControllerAvailable
Michal Privoznik [Tue, 31 Mar 2015 09:39:13 +0000 (11:39 +0200)]
vircgroup: Introduce virCgroupControllerAvailable

This new internal API checks if given CGroup controller is
available.  It is going to be needed later when we need to make a
decision whether pin domain memory onto NUMA nodes using cpuset
CGroup controller or using numa_set_membind().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
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>
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>
10 years agoparallels: delete old networks in prlsdkDoApplyConfig before adding new ones
Maxim Nestratov [Mon, 6 Apr 2015 15:53:47 +0000 (18:53 +0300)]
parallels: delete old networks in prlsdkDoApplyConfig before adding new ones

In order to change an existing domain we delete all existing devices and add
new from scratch. In case of network devices we should also delete corresponding
virtual networks (if any) before removing actual devices from xml. In the patch,
we do it by extending prlsdkDoApplyConfig with a new parameter, which stands for
old xml, and calling prlsdkDelNet every time old xml is specified.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
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>
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>
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>
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>
10 years agovirQEMUDriverGetConfig: Fix memleak
Michal Privoznik [Fri, 3 Apr 2015 18:58:20 +0000 (20:58 +0200)]
virQEMUDriverGetConfig: Fix memleak

==19015== 968 (416 direct, 552 indirect) bytes in 1 blocks are definitely lost in loss record 999 of 1,049
==19015==    at 0x4C2C070: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19015==    by 0x52ADF14: virAllocVar (viralloc.c:560)
==19015==    by 0x5302FD1: virObjectNew (virobject.c:193)
==19015==    by 0x1DD9401E: virQEMUDriverConfigNew (qemu_conf.c:164)
==19015==    by 0x1DDDF65D: qemuStateInitialize (qemu_driver.c:666)
==19015==    by 0x53E0823: virStateInitialize (libvirt.c:777)
==19015==    by 0x11E067: daemonRunStateInit (libvirtd.c:905)
==19015==    by 0x53201AD: virThreadHelper (virthread.c:206)
==19015==    by 0xA1EE1F2: start_thread (in /lib64/libpthread-2.19.so)
==19015==    by 0xA4EFC8C: clone (in /lib64/libc-2.19.so)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainVirtioSerialAddrSetFree: Fix memleak
Michal Privoznik [Fri, 3 Apr 2015 18:14:01 +0000 (20:14 +0200)]
virDomainVirtioSerialAddrSetFree: Fix memleak

==19015== 8 bytes in 1 blocks are definitely lost in loss record 34 of 1,049
==19015==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19015==    by 0x4C2C32F: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19015==    by 0x52AD888: virReallocN (viralloc.c:245)
==19015==    by 0x52AD97E: virExpandN (viralloc.c:294)
==19015==    by 0x52ADC51: virInsertElementsN (viralloc.c:436)
==19015==    by 0x5335864: virDomainVirtioSerialAddrSetAddController (domain_addr.c:816)
==19015==    by 0x53358E0: virDomainVirtioSerialAddrSetAddControllers (domain_addr.c:839)
==19015==    by 0x1DD5513B: qemuDomainAssignVirtioSerialAddresses (qemu_command.c:1422)
==19015==    by 0x1DD55A6E: qemuDomainAssignAddresses (qemu_command.c:1711)
==19015==    by 0x1DDA5818: qemuProcessStart (qemu_process.c:4616)
==19015==    by 0x1DDF1807: qemuDomainObjStart (qemu_driver.c:7265)
==19015==    by 0x1DDF1A66: qemuDomainCreateWithFlags (qemu_driver.c:7320)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuSetupCgroupForVcpu: Fix memleak
Michal Privoznik [Fri, 3 Apr 2015 18:06:17 +0000 (20:06 +0200)]
qemuSetupCgroupForVcpu: Fix memleak

==19015== 1,064 (656 direct, 408 indirect) bytes in 2 blocks are definitely lost in loss record 1,002 of 1,049
==19015==    at 0x4C2C070: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19015==    by 0x52AD74B: virAlloc (viralloc.c:144)
==19015==    by 0x52B47CA: virCgroupNew (vircgroup.c:1057)
==19015==    by 0x52B53E5: virCgroupNewVcpu (vircgroup.c:1451)
==19015==    by 0x1DD85A40: qemuSetupCgroupForVcpu (qemu_cgroup.c:1013)
==19015==    by 0x1DDA66EA: qemuProcessStart (qemu_process.c:4844)
==19015==    by 0x1DDF1807: qemuDomainObjStart (qemu_driver.c:7265)
==19015==    by 0x1DDF1A66: qemuDomainCreateWithFlags (qemu_driver.c:7320)
==19015==    by 0x1DDF1ACD: qemuDomainCreate (qemu_driver.c:7337)
==19015==    by 0x53F87EA: virDomainCreate (libvirt-domain.c:6820)
==19015==    by 0x12690A: remoteDispatchDomainCreate (remote_dispatch.h:3481)
==19015==    by 0x126827: remoteDispatchDomainCreateHelper (remote_dispatch.h:3457)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: Introduce storagePoolUpdateAllState function
Erik Skultety [Mon, 16 Mar 2015 15:30:03 +0000 (16:30 +0100)]
storage: Introduce storagePoolUpdateAllState function

The 'checkPool' callback was originally part of the storageDriverAutostart function,
but the pools need to be checked earlier during initialization phase,
otherwise we can't start a domain which mounts a volume after the
libvirtd daemon restarted. This is because qemuProcessReconnect is called
earlier than storageDriverAutostart. Therefore the 'checkPool' logic has been
moved to storagePoolUpdateAllState which is called inside storageDriverInitialize.

We also need a valid 'conn' reference to be able to execute 'refreshPool'
during initialization phase. Though it isn't available until storageDriverAutostart
all of our storage backends do ignore 'conn' pointer, except for RBD,
but RBD doesn't support 'checkPool' callback, so it's safe to pass
conn = NULL in this case.

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

10 years agoconf: Introduce virStoragePoolLoadAllState && virStoragePoolLoadState
Erik Skultety [Tue, 10 Mar 2015 12:59:51 +0000 (13:59 +0100)]
conf: Introduce virStoragePoolLoadAllState && virStoragePoolLoadState

These functions operate exactly the same as their network equivalents
virNetworkLoadAllState, virNetworkLoadState.

10 years agostorage: Add support for storage pool state XML
Erik Skultety [Mon, 9 Mar 2015 14:36:44 +0000 (15:36 +0100)]
storage: Add support for storage pool state XML

This patch introduces new virStorageDriverState element stateDir.
Also adds necessary changes to storageStateInitialize, so that
directories initialization becomes more generic.

10 years agohostdev: Report the domain name for used hostdevs during nodedev-detach
Shivaprasad G Bhat [Wed, 1 Apr 2015 10:58:05 +0000 (16:28 +0530)]
hostdev: Report the domain name for used hostdevs during nodedev-detach

The nodedev-detach can report the name of the domain using the device
just the way nodedev-reattach does it.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agovirsh: Improve change-media success message
Cole Robinson [Mon, 6 Apr 2015 17:59:46 +0000 (13:59 -0400)]
virsh: Improve change-media success message

$ sudo virsh change-media f19 hdc /mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso
succeeded to complete action update on media

Change the message to:

  Successfully {inserted,ejected,changed} media.

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

10 years agointerface: allow multiple IPv4 addresses in interface XML
Laine Stump [Fri, 27 Mar 2015 00:15:53 +0000 (20:15 -0400)]
interface: allow multiple IPv4 addresses in interface XML

An upcoming netcf release will support multiple ipv4 addresses, so
let's loosen up libvirt's interface.rng to allow it.

10 years agovirsh.pod: Remove redundant --config from attach-interface
Jiri Denemark [Fri, 3 Apr 2015 12:56:36 +0000 (14:56 +0200)]
virsh.pod: Remove redundant --config from attach-interface

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agolibvirt: virsh: Kill all uses of __FUNCTION__ in error messages
Noella Ashu [Fri, 3 Apr 2015 10:33:44 +0000 (11:33 +0100)]
libvirt: virsh: Kill all uses of __FUNCTION__ in error messages

The error output of snapshot-revert should be more friendly.
There is no need to show virDomainRevertToSnapshot to user.
virReportError already includes __FUNCTION__ information in a
separate member of the struct, so repeating it in the message is
redundant and leads to situations where higher level code ends up
reporting the lower level name. We correctly converted the error
output making it more succinct and user-friendly.

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

10 years agovirsh: Fix domifaddr output in quiet mode
Luyao Huang [Fri, 3 Apr 2015 09:41:03 +0000 (17:41 +0800)]
virsh: Fix domifaddr output in quiet mode

In virsh we have two printing functions: vshPrint() which prints a
string onto stdout and vshPrintExtra() which does not print anything
if virsh is run in quiet mode. Usually, the former is used to print
actual results, while the latter to print strings like table headers
and other formatting stuff. However, in cmdDomIfAddr we have
mistakenly used vshPrintExtra even for actual data. After this patch,
the output should look like the following:

  # virsh -q domifaddr test3 --source agent
  lo         00:00:00:00:00:00    ipv4         127.0.0.1/8
  -          -                    ipv6         ::1/128
  ens8       52:54:00:1a:cb:3f    ipv6         fe80::5054:ff:fe1a:cb3f/64
  virbr0     52:54:00:db:51:e7    ipv4         192.168.122.1/24
  virbr0-nic 52:54:00:db:51:e7    N/A          N/A

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoesx: esxNodeGetFreeMemory return info from host.
Dawid Zamirski [Mon, 9 Mar 2015 15:54:05 +0000 (11:54 -0400)]
esx: esxNodeGetFreeMemory return info from host.

Before this patch, when connected via vCenter, the free memory returned
was from the resorcePool (usually a cluster). This is in conflict with
e.g esxNodeGetInfo which always pulls info from the ESX host.
Since libvirt ESX driver works primarily with ESX hosts, this patch
changes esxNodeGetFreeMemory to pull that information from ESX host so
it's consistent with behavior of esxNodeGetInfo.

10 years agoesx: add esxVI_GetInt
Dawid Zamirski [Mon, 9 Mar 2015 15:54:04 +0000 (11:54 -0400)]
esx: add esxVI_GetInt

Modeled after the already existing esxVI_GetLong.

10 years agoconf: Change virStoragePoolSaveConfig prototype s/configDir/configFile
Erik Skultety [Fri, 3 Apr 2015 08:41:04 +0000 (10:41 +0200)]
conf: Change virStoragePoolSaveConfig prototype s/configDir/configFile

Just a minor change which might be a little confusing for someone
looking only at the API.

10 years agoconf: Introduce virStoragePoolSaveState
Erik Skultety [Thu, 2 Apr 2015 14:41:51 +0000 (16:41 +0200)]
conf: Introduce virStoragePoolSaveState

Introduce virStoragePoolSaveState to properly format the state XML in
the same manner as virStoragePoolDefFormat, except for adding a
<poolstate> ... </poolstate> around the definition. This is similar to
virNetworkObjFormat used to save the live/active network information.

10 years agoconf: Introduce virStoragePoolDefFormatBuf
Erik Skultety [Thu, 26 Mar 2015 15:44:38 +0000 (16:44 +0100)]
conf: Introduce virStoragePoolDefFormatBuf

When modifying config/status XML, it might be handy to include some
additional XML elements (e.g. <poolstate>). In order to do so,
introduce new formatting function virStoragePoolDefFormatBuf and make
virStoragePoolDefFormat call it.

10 years agolibxl: fix dom0 balloon logic
Jim Fehlig [Fri, 20 Mar 2015 23:08:34 +0000 (17:08 -0600)]
libxl: fix dom0 balloon logic

Recent testing on large memory systems revealed a bug in the Xen xl
tool's freemem() function.  When autoballooning is enabled, freemem()
is used to ensure enough memory is available to start a domain,
ballooning dom0 if necessary.  When ballooning large amounts of memory
from dom0, freemem() would exceed its self-imposed wait time and
return an error.  Meanwhile, dom0 continued to balloon.  Starting the
domain later, after sufficient memory was ballooned from dom0, would
succeed.  The libvirt implementation in libxlDomainFreeMem() suffers
the same bug since it is modeled after freemem().

In the end, the best place to fix the bug on the Xen side was to
slightly change the behavior of libxl_wait_for_memory_target().
Instead of failing after caller-provided wait_sec, the function now
blocks as long as dom0 memory ballooning is progressing.  It will return
failure only when more memory is needed to reach the target and wait_sec
have expired with no progress being made.  See xen.git commit fd3aa246.
There was a dicussion on how this would affect other libxl apps like
libvirt

http://lists.xen.org/archives/html/xen-devel/2015-03/msg00739.html

If libvirt containing this patch was build against a Xen containing
the old libxl_wait_for_memory_target() behavior, libxlDomainFreeMem()
will fail after 30 sec and domain creation will be terminated.
Without this patch and with old libxl_wait_for_memory_target() behavior,
libxlDomainFreeMem() does not succeed after 30 sec, but returns success
anyway.  Domain creation continues resulting in all sorts of fun stuff
like cpu soft lockups in the guest OS.  It was decided to properly fix
libxl_wait_for_memory_target(), and if anything improve the default
behavior of apps using the freemem reference impl in xl.

xl was patched to accommodate the change in libxl_wait_for_memory_target()
with xen.git commit 883b30a0.  This patch does the same in the libxl
driver.  While at it, I changed the logic to essentially match
freemem() in $xensrc/tools/libxl/xl_cmdimpl.c.  It was a bit cleaner
IMO and will make it easier to spot future, potentially interesting
divergences.

10 years agoTypos: Get rid of dependan(t|cies)
Martin Kletzander [Thu, 26 Mar 2015 06:36:07 +0000 (07:36 +0100)]
Typos: Get rid of dependan(t|cies)

Dependant is flagged as wrong in US dictionary (only valid in UK
dictionary, and even then, it has only the financial sense and not the
inter-relatedness sense that we are more prone to be wanting throughout
code).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodocs: Add Host sFlow into monitoring apps
Martin Kletzander [Wed, 25 Mar 2015 15:34:58 +0000 (16:34 +0100)]
docs: Add Host sFlow into monitoring apps

Reported-by: Peter Phaal <peter.phaal@gmail.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agohostdev: Fix index error in loop after remove an element
Huanle Han [Thu, 26 Mar 2015 14:23:46 +0000 (22:23 +0800)]
hostdev: Fix index error in loop after remove an element

'virPCIDeviceList' is actually an array. Removing one element makes the
rest of the element move.

Use while loop, increase index only when not virPCIDeviceListDel(pcidevs, dev)

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
10 years agoFix xlconfigtest with older libxl
Ján Tomko [Thu, 2 Apr 2015 12:57:54 +0000 (14:57 +0200)]
Fix xlconfigtest with older libxl

Commit cd5dc30 added this test, but it fails if
LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST is not defined:

6) Xen XM-2-XML Format fullvirt-multiusb
... libvirt:  error : unsupported configuration: multiple USB
devices not supported
FAILED

10 years agoAuto add virtio-serial controllers
Ján Tomko [Tue, 24 Mar 2015 14:23:46 +0000 (15:23 +0100)]
Auto add virtio-serial controllers

In virDomainVirtioSerialAddrNext, add another controller
if we've exhausted all ports of the existing controllers.

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

10 years agoAssign an address when hotplugging a virtio-serial device
Ján Tomko [Mon, 2 Mar 2015 09:59:52 +0000 (10:59 +0100)]
Assign an address when hotplugging a virtio-serial device

10 years agoExpand the address set when attaching a virtio-serial controller
Ján Tomko [Mon, 2 Mar 2015 09:59:25 +0000 (10:59 +0100)]
Expand the address set when attaching a virtio-serial controller

10 years agoAllocate virtio-serial addresses when starting a domain
Ján Tomko [Mon, 2 Mar 2015 09:58:48 +0000 (10:58 +0100)]
Allocate virtio-serial addresses when starting a domain

Instead of always using controller 0 and incrementing port number,
respect the maximum port numbers of controllers and use all of them.

Ports for virtio consoles are quietly reserved, but not formatted
(neither in XML nor on QEMU command line).

Also rejects duplicate virtio-serial addresses.
https://bugzilla.redhat.com/show_bug.cgi?id=890606
https://bugzilla.redhat.com/show_bug.cgi?id=1076708

Test changes:
* virtio-auto.args
  Filling out the port when just the controller is specified.
  switched from using
    maxport + 1
  to:
    first free port on the controller
* virtio-autoassign.args
  Filling out the address when no <address> is specified.
  Started using all the controllers instead of 0, also discards
  the bus value.
* xml -> xml output of virtio-auto
  The port assignment is no longer done as a part of XML parsing,
  so the unspecified values stay 0.

10 years agoAdd functions to track virtio-serial addresses
Ján Tomko [Mon, 2 Mar 2015 09:57:51 +0000 (10:57 +0100)]
Add functions to track virtio-serial addresses

Create a sorted array of virtio-serial controllers.
Each of the elements contains the controller index
and a bitmap of available ports.

Buses are not tracked, because they aren't supported by QEMU.

10 years agoAdd test for virtio serial port assignment
Ján Tomko [Thu, 29 May 2014 13:16:47 +0000 (15:16 +0200)]
Add test for virtio serial port assignment

Add a test to demonstrate the effect of automatic virtio-serial
address assignment.

10 years agoscsi: Remove unused 'type_path' in processLU
John Ferlan [Wed, 1 Apr 2015 12:45:11 +0000 (08:45 -0400)]
scsi: Remove unused 'type_path' in processLU

Seems to be a remnant that was never cleaned up from original submit...

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoiscsi: Fix exit path for virStorageBackendISCSIFindLUs failure
John Ferlan [Wed, 1 Apr 2015 10:46:25 +0000 (06:46 -0400)]
iscsi: Fix exit path for virStorageBackendISCSIFindLUs failure

If the call to virStorageBackendISCSIGetHostNumber failed, we set
retval = -1, but yet still called virStorageBackendSCSIFindLUs.
Need to add a goto cleanup - while at it, adjust the logic to
initialize retval to -1 and only changed to 0 (zero) on success.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoiscsi: Use error message from virStorageBackendSCSIFindLUs
John Ferlan [Mon, 30 Mar 2015 22:49:36 +0000 (18:49 -0400)]
iscsi: Use error message from virStorageBackendSCSIFindLUs

Don't supercede the error message virStorageBackendSCSIFindLUs as the
message such as "error: Failed to find LUs on host 60: ..." is not overly
clear as to what the real problem might be.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoconf: Introduce virStoragePoolSaveXML
Erik Skultety [Thu, 26 Mar 2015 15:49:20 +0000 (16:49 +0100)]
conf: Introduce virStoragePoolSaveXML

Make XML definition saving more generic by moving the common code into
virStoragePoolSaveXML and leave case specific code to
PoolSave{Status,Config,...} functions.

10 years agostorage: Remove unused attribute conn from 'checkPool' callback
Erik Skultety [Mon, 9 Mar 2015 14:34:35 +0000 (15:34 +0100)]
storage: Remove unused attribute conn from 'checkPool' callback

In order to be able to use 'checkPool' inside functions which do not
have any connection reference, 'conn' attribute needs to be discarded
from the checkPool's signature, since it's not used by any storage backend
anyway.

10 years agoqemuDomainBlockCopy: Check @granularity to be a power of two
Luyao Huang [Fri, 27 Mar 2015 09:56:30 +0000 (17:56 +0800)]
qemuDomainBlockCopy: Check @granularity to be a power of two

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

As described in virDomainBlockCopy() parameters description, the
VIR_DOMAIN_BLOCK_COPY_GRANULARITY parameter may require the value to
have some specific attributes (e.g. be a power of two or fall within a
certain range). And in qemu, a power of two is required. However, our
code does not check that and let qemu operation fail. Moreover, the
virsh man page is not as exact as it could be in this respect.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfodata: Remove broken symlinks and uneeded files
Michal Privoznik [Wed, 1 Apr 2015 08:48:04 +0000 (10:48 +0200)]
nodeinfodata: Remove broken symlinks and uneeded files

The 7c3c7f217ebae5 and f5c2d6 commits introduced a nodeinfo test.
In order to do that, some parts of sysfs had to be copied.
However, sysfs is full of symlinks, so during copying some
symlinks broke. Remove them, as on different systems they can
point to different files or be broken. At the same time, we don't
need all files added in those commits. For instance we don't care
about 'uevent' files, 'power' folders, and others.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: lifecycle: make agent-mode shutdown and reboot timeout
zhang bo [Wed, 1 Apr 2015 09:13:08 +0000 (17:13 +0800)]
qemu: lifecycle: make agent-mode shutdown and reboot timeout

When we shutdown/reboot a guest using agent-mode, if the guest itself blocks infinitely,
libvirt would block in qemuAgentShutdown() forever.
Thus, we set a timeout for shutdown/reboot, from our experience, 60 seconds would be fine.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
10 years agoFix indentation in cmdVcpuPin
Ján Tomko [Thu, 26 Mar 2015 14:10:50 +0000 (15:10 +0100)]
Fix indentation in cmdVcpuPin

10 years agovirsh: remove stale comment
Ján Tomko [Wed, 1 Apr 2015 17:53:28 +0000 (19:53 +0200)]
virsh: remove stale comment

Copied from the vcpupin command, which has two modes of operation.

10 years agoconf: Rename virDomainHasDiskMirror and detect block jobs properly
Shanzhi Yu [Tue, 24 Mar 2015 10:08:00 +0000 (18:08 +0800)]
conf: Rename virDomainHasDiskMirror and detect block jobs properly

virDomainHasDiskMirror() currently detects only jobs that add the mirror
elements. Since some operations like migration are interlocked by
existing block jobs on the given domain the check needs to be
instrumented to check regular jobs too.

This patch renames virDomainHasDiskMirror to virDomainHasDiskBlockjob
and adds an argument that allows to select that it returns true only for
block copy jobs as those interlock making the domain persistent.

Other two uses trigger on any block job type.

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>