]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agostorage: Adjust calculation of alloc/capacity for disk
John Ferlan [Thu, 1 Oct 2015 15:37:17 +0000 (11:37 -0400)]
storage: Adjust calculation of alloc/capacity for disk

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

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

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

9 years agostorage: Introduce virStorageBackendDiskStartPool
John Ferlan [Thu, 1 Oct 2015 12:38:58 +0000 (08:38 -0400)]
storage: Introduce virStorageBackendDiskStartPool

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

When 'starting' up a disk pool, we need to make sure the label on the
device is valid; otherwise, the followup refreshPool will assume the
disk has been properly formatted for use. If we don't find the valid
label, then refuse the start and give a proper reason.

9 years agostorage: Add additional errors/checks for disk label
John Ferlan [Thu, 1 Oct 2015 12:24:14 +0000 (08:24 -0400)]
storage: Add additional errors/checks for disk label

Let's check to ensure we can find the Partition Table in the label
and that libvirt actually recognizes that type; otherwise, when we
go to read the partitions during a refresh operation we may not be
reading what we expect.

This will expand upon the types of errors or reason that a build
would fail, so we can create more direct error messages.

9 years agostorage: Add param to check whether we can write a disk label
John Ferlan [Thu, 1 Oct 2015 13:30:28 +0000 (09:30 -0400)]
storage: Add param to check whether we can write a disk label

Modify virStorageBackendDiskValidLabel to add a 'writelabel' parameter.
While initially for the purpose of determining whether the label should
be written during DiskBuild, a future use during DiskStart could determine
whether the pool should be started using the label found. Augment the
error messages also to give a hint as to what someone may need to do
or why the command failed.

9 years agostorage: Refactor disk label checking
John Ferlan [Thu, 1 Oct 2015 12:07:35 +0000 (08:07 -0400)]
storage: Refactor disk label checking

Create a new function virStorageBackendDiskValidLabel to handle checking
whether there is a label on the device and whether it's valid or not.
While initially for the purpose of determining whether the label can be
overwritten during DiskBuild, a future use during DiskStart could determine
whether the pool should be started using the label found.

9 years agostorage: Prior to creating a volume, refresh the pool
John Ferlan [Wed, 30 Sep 2015 21:53:01 +0000 (17:53 -0400)]
storage: Prior to creating a volume, refresh the pool

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

Although perhaps bordering on a don't do that type scenario, if
someone creates a volume in a pool outside of libvirt, then uses that
same name to create a volume in the pool via libvirt, then the creation
will fail and in some cases cause the same name volume to be deleted.

This patch will refresh the pool just prior to checking whether the
named volume exists prior to creating the volume in the pool. While
it's still possible to have a timing window to create a file after the
check - at least we tried.  At that point, someone is being malicious.

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

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

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

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

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

9 years agovirfile: Add extra check for direct delete in virFileRemove
John Ferlan [Wed, 30 Sep 2015 21:25:34 +0000 (17:25 -0400)]
virfile: Add extra check for direct delete in virFileRemove

Unlike create options, if the file to be removed is already in the
pool, then the uid/gid will come from the pool. If it's the same as the
currently running process, then just do the unlink/rmdir directly
rather than going through the fork processing unnecessarily

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

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

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

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

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

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

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

Refactor the condition to avoid problems.

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

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

9 years agoconf: Reuse virDomainDefCheckDuplicateDiskWWN to check disk serial too
Peter Krempa [Tue, 29 Sep 2015 16:33:40 +0000 (18:33 +0200)]
conf: Reuse virDomainDefCheckDuplicateDiskWWN to check disk serial too

Rename the function to virDomainDefCheckDuplicateDiskInfo and make it
check disk serials too.

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

9 years agoqemu: Perform the disk WWN check only on fresh starts
Peter Krempa [Tue, 29 Sep 2015 16:13:06 +0000 (18:13 +0200)]
qemu: Perform the disk WWN check only on fresh starts

Since we'd disallow migration of a guest that would have possibly
invalid config but still be able to work, relax the WWN check to be
performed only on new starts of the VM.

9 years agointerface: let netcf pre-filter for active vs. inactive
Laine Stump [Fri, 18 Sep 2015 17:51:33 +0000 (13:51 -0400)]
interface: let netcf pre-filter for active vs. inactive

If a system has a large number of active or active interfaces, it can
be a big waste of time to retrieve and qualify all interfaces if the
caller only wanted one subset. Since netcf has a simple flag for this,
translate the libvirt flag into a netcf flag and let netcf pre-filter.

9 years agointerface: re-use name and mac address rather than re-retrieving
Laine Stump [Fri, 18 Sep 2015 17:19:27 +0000 (13:19 -0400)]
interface: re-use name and mac address rather than re-retrieving

Getting the MAC address of an interface is actually fairly expensive,
and we've already gotten it and stored it into def, so just keep def
around a bit longer and retrieve it from there.

This reduces the time for "virsh iface-list --all" from 28 to 23
seconds when there are 400 interfaces.

9 years agointerface: report correct interface count when not returning list
Laine Stump [Fri, 18 Sep 2015 17:24:47 +0000 (13:24 -0400)]
interface: report correct interface count when not returning list

The spec for virConnectListAllInterfaces says that if the pointer that
is supposed to hold the list of interfaces is NULL, the function
should just return the count of interfaces that matched the filter,
but the code never increments the count if the list pointer is NULL.

9 years agointerface: fail on OOM from virGetInterface()
Laine Stump [Fri, 18 Sep 2015 17:22:46 +0000 (13:22 -0400)]
interface: fail on OOM from virGetInterface()

9 years agolibvirt.spec: fix accidental conditional inclusion of polkit docs
Daniel P. Berrange [Fri, 2 Oct 2015 15:08:02 +0000 (16:08 +0100)]
libvirt.spec: fix accidental conditional inclusion of polkit docs

In previous change:

  commit 29b5167417483ef80f6c3fce12811b59a1e2bd55
  Author: Jiri Denemark <jdenemar@redhat.com>
  Date:   Tue Aug 4 14:05:52 2015 +0200

    examples: Add example polkit ACL rules

The polkit examples were accidentally added to the spec inside
a %if %{with_network} conditional.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: Use memory-backing-file only when needed
Martin Kletzander [Thu, 1 Oct 2015 05:34:57 +0000 (07:34 +0200)]
qemu: Use memory-backing-file only when needed

We are using memory-backing-file even when it's not needed, for example
if user requests hugepages for memory backing, but does not specify any
pagesize or memory node pinning.  This causes migrations to fail when
migrating from older libvirt that did not do this.  So similarly to
commit 7832fac84741d65e851dbdbfaf474785cbfdcf3c which does it for
memory-backend-ram, this commit makes is more generic and
backend-agnostic, so the backend is not used if there is no specific
pagesize of hugepages requested, no nodeset the memory node should be
bound to, no memory access change required, and so on.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Add -mem-path even with numa
Martin Kletzander [Thu, 1 Oct 2015 06:15:48 +0000 (08:15 +0200)]
qemu: Add -mem-path even with numa

So since the introduction of the memory-backend-file object until now we
only added '-mem-path' for non-NUMA guests and we used the parameters of
the memory-backend-file object to specify the path to the hugetlbfs
mount.  But hugepages can be also used without memory-backend-file
object, as it used to be before its introduction.  Let's just get this
part of the code back and properly append the '-mem-path' for NUMA
guests as well, but only when the memory backend is not needed.

This parameter is already being applied when no numa is requested and
because we still use memory-object-file unconditionally for
hugepage-backed NUMA guests, this should not fire until later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Extract -mem-path building into its own function
Martin Kletzander [Thu, 1 Oct 2015 05:47:39 +0000 (07:47 +0200)]
qemu: Extract -mem-path building into its own function

That function is called qemuBuildMemPathStr() and will be used in
other places in the future.  The change in the test suite is proper due
to the fact that -mem-prealloc makes only sense with -mem-path (from
qemu documentation -- html/qemu-doc.html).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Move memory size detection to the top of the function
Martin Kletzander [Thu, 1 Oct 2015 05:30:39 +0000 (07:30 +0200)]
qemu: Move memory size detection to the top of the function

To get rid of very long line and make it more readable.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Move simplification variable to begining of the function
Martin Kletzander [Thu, 1 Oct 2015 05:23:38 +0000 (07:23 +0200)]
qemu: Move simplification variable to begining of the function

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agodocs: Add Cuckoo Sandbox into apps.html
Martin Kletzander [Thu, 1 Oct 2015 12:32:47 +0000 (14:32 +0200)]
docs: Add Cuckoo Sandbox into apps.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Add test cases for gic-version option
Pavel Fedin [Wed, 30 Sep 2015 11:04:11 +0000 (14:04 +0300)]
qemu: Add test cases for gic-version option

These tests make sure that we can use this option only when the capability is
set.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agoqemu: Add support for gic-version machine option
Pavel Fedin [Wed, 30 Sep 2015 11:04:10 +0000 (14:04 +0300)]
qemu: Add support for gic-version machine option

Support for GICv3 has been recently introduced in qemu using gic-version
option for the 'virt' machine. The option can actually take values of
'2', '3' and 'host', however, since in libvirt this is a numeric
parameter, we limit it only to 2 and 3. Value of 2 is not added to the
command line in order to keep backward compatibility with older qemu
versions.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agoqemu: Introduce QEMU_CAPS_MACH_VIRT_GIC_VERSION capability
Pavel Fedin [Wed, 30 Sep 2015 11:04:09 +0000 (14:04 +0300)]
qemu: Introduce QEMU_CAPS_MACH_VIRT_GIC_VERSION capability

Unfortunately qemu currently doesn't offer introspection for machine types,
so we have to rely on version number, similar to QEMU_CAPS_MACHINE_USB_OPT.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agoPost-release version bump to 1.2.21
Martin Kletzander [Fri, 2 Oct 2015 11:40:33 +0000 (13:40 +0200)]
Post-release version bump to 1.2.21

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRelease of libvirt-1.2.20
Daniel Veillard [Fri, 2 Oct 2015 11:17:16 +0000 (13:17 +0200)]
Release of libvirt-1.2.20

* docs/news.html.in libvirt.spec.in: update for new release
* po/*.po*: regenerate localization

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

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

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

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

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

9 years agovirsh: Preserve startupPolicy in change-media command
Michal Privoznik [Thu, 24 Sep 2015 16:00:06 +0000 (18:00 +0200)]
virsh: Preserve startupPolicy in change-media command

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

Even after my rework of startupPolicy handling, one command
slipped my attention. The change-media command has a very unique
approach to constructing disk XML. However, it will not preserve
startupPolicy attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoCreate a shallow copy for volume building only if supported
Ján Tomko [Thu, 24 Sep 2015 15:12:02 +0000 (17:12 +0200)]
Create a shallow copy for volume building only if supported

Since the previous commit, the shallow copy is only used inside
the if (backend->buildVol) if.

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

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

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

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

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

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

9 years agoconf: Fix virtType check
John Ferlan [Fri, 25 Sep 2015 21:33:05 +0000 (17:33 -0400)]
conf: Fix virtType check

Commit id '7383b8cc' changed virDomainDef 'virtType' to an enum, that
caused a build failure on some archs due to comparing an unsigned value
to < 0.  Adjust the fetch of 'type' to be into temporary 'int virtType'
and then assign that virtType to the def->virtType

9 years agoqemu: Make virtType of type virDomainVirtType
Shivangi Dhir [Thu, 17 Sep 2015 08:46:56 +0000 (14:16 +0530)]
qemu: Make virtType of type virDomainVirtType

Earlier virtType was of type int. After, introducing the enum VIR_DOMAIN_VIRT_NONE,
the type of virtType is modified to virDomainVirtType.

9 years agoconf: Add new VIR_DOMAIN_VIRT_NONE enum
Shivangi Dhir [Thu, 17 Sep 2015 08:46:55 +0000 (14:16 +0530)]
conf: Add new VIR_DOMAIN_VIRT_NONE enum

Introduce VIR_DOMAIN_VIRT_NONE to give domaintype the default value of zero.
This is specially helpful in constructing better error messages
when we don't want to look up the default emulator by virtType.

The test data in vircapstest.c is also modified to reflect this change.

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

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

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=799633

9 years agotools: Link libvirt.la and readline to libvirt_shell.a
Michal Privoznik [Fri, 25 Sep 2015 11:20:38 +0000 (13:20 +0200)]
tools: Link libvirt.la and readline to libvirt_shell.a

So, our mingw build is broken. It's because while libvirt_shell
library is using some of our internal APIs, e.g. virStrndup, and
readline API but it's not being linked with nor libvirt.la nor
libreadline.  Only subsequent users of the library, like virsh,
do link to the needed libraries. In fact, I'm surprised Linux
linker doesn't care, because how can it make a static library
with missing symbols is mystery to me.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agomaint: Remove control characters from LGPL license file
Andrea Bolognani [Thu, 11 Jun 2015 13:15:19 +0000 (15:15 +0200)]
maint: Remove control characters from LGPL license file

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

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

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

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovsh: create a noinstall libvirt_shell library
Erik Skultety [Wed, 23 Sep 2015 13:17:35 +0000 (15:17 +0200)]
vsh: create a noinstall libvirt_shell library

Instead of referencing vsh sources in all relevant client targets,
create a library that the client can link against.

9 years agoqemu: Resolve Coverity RESOURCE_LEAK
John Ferlan [Tue, 8 Sep 2015 11:05:55 +0000 (07:05 -0400)]
qemu: Resolve Coverity RESOURCE_LEAK

This seemed to be more of a false positive as for some reason Coverity
was missing the "ret < 0" goto error condition and somehow believing that
event could be overwritten.  At first I thought it was just the ret != 0
condition difference, but it wasn't.

In any case, make use of the recent change to qemuDomainEventQueue to
check event == NULL and just pass it as a parameter directly in the
error path. That avoids the error.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Clean up ret in qemuDomainSaveMemory and qemuDomainSaveInternal
John Ferlan [Thu, 24 Sep 2015 13:47:13 +0000 (09:47 -0400)]
qemu: Clean up ret in qemuDomainSaveMemory and qemuDomainSaveInternal

As it turns out, ret can only be 0 or -1, so rather than have some comparisons
be "ret < 0" and others be "ret != 0", make them all "ret < 0".

9 years agoqemu: Resolve Coverity CHECKED_RETURN
John Ferlan [Wed, 23 Sep 2015 22:13:57 +0000 (18:13 -0400)]
qemu: Resolve Coverity CHECKED_RETURN

Coverity complains that return from virHookCall is not checked in
one place in qemuProcessStop.  Since the comment notes that we cannot
stop the operation even it if fails, just added the ignore_value.

9 years agovirsh: Resolve Coverity DEADCODE
John Ferlan [Wed, 23 Sep 2015 22:11:30 +0000 (18:11 -0400)]
virsh: Resolve Coverity DEADCODE

Use 'dead_error_condition' instead of 'dead_error_begin'

9 years agotests: Resolve Coverity RESOURCE_LEAK
John Ferlan [Tue, 8 Sep 2015 11:21:17 +0000 (07:21 -0400)]
tests: Resolve Coverity RESOURCE_LEAK

The cleanup path did not clear the reference for sk1 and sk2

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agotests: Resolve Coverity RESOURCE_LEAK
John Ferlan [Tue, 8 Sep 2015 11:12:52 +0000 (07:12 -0400)]
tests: Resolve Coverity RESOURCE_LEAK

In the error path need to unref the 'caps' as well

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirDomainRestore: Don't keep transient domains around
Michal Privoznik [Wed, 23 Sep 2015 12:13:53 +0000 (14:13 +0200)]
virDomainRestore: Don't keep transient domains around

So while working on my previous patches, I've noticed that
virDomainRestore implementation in qemu and test drivers has the
same problem as I am fixing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Move vm->persistent check into qemuDomainRemoveInactive
Michal Privoznik [Tue, 22 Sep 2015 13:25:00 +0000 (15:25 +0200)]
qemu: Move vm->persistent check into qemuDomainRemoveInactive

So far we have the following pattern occurring over and over
again:

  if (!vm->persistent)
      qemuDomainRemoveInactive(driver, vm);

It's safe to put the check into the function and save some LoC.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomainCreateXML: Make domain definition transient
Michal Privoznik [Tue, 22 Sep 2015 14:57:52 +0000 (16:57 +0200)]
virDomainCreateXML: Make domain definition transient

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

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomainCreateXML: Don't remove persistent domains on error
Michal Privoznik [Tue, 22 Sep 2015 14:52:03 +0000 (16:52 +0200)]
virDomainCreateXML: Don't remove persistent domains on error

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

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

Steps to reproduce:

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodocs: Add yet another libvirt based app
Michal Privoznik [Thu, 24 Sep 2015 06:10:37 +0000 (08:10 +0200)]
docs: Add yet another libvirt based app

As announced on the list [1], Cherrypop is a management
application based on libvirt. It's a decentralized cloud software
with nice scaling ability.

1: https://www.redhat.com/archives/libvir-list/2015-September/msg00670.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRemove redundand assignment
Martin Kletzander [Thu, 24 Sep 2015 08:20:33 +0000 (10:20 +0200)]
Remove redundand assignment

I initially added this in order to keep the code more error-prone to
following additions, but it seems it's still frowned upon.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemuDomainDeviceDefPostParse: Drop useless checks
Michal Privoznik [Wed, 23 Sep 2015 08:03:10 +0000 (10:03 +0200)]
qemuDomainDeviceDefPostParse: Drop useless checks

Now that virQEMUDriverCreateXMLConf is never called with NULL
(after 086f37e97aab) we can safely drop useless check in
qemuDomainDeviceDefPostParse as we are guaranteed to be always
called with the driver initialized. Therefore checking if driver
is NULL makes no sense. Moreover, if we mix it with direct driver
dereference. And after that, we are sure that nor @cfg will be
NULL, therefore we can drop checks for that too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Fix job status indicator for 0 length block jobs
Peter Krempa [Fri, 11 Sep 2015 19:34:24 +0000 (21:34 +0200)]
virsh: Fix job status indicator for 0 length block jobs

Although 0 length block jobs aren't entirely useful, the output of virsh
blockjob is empty due to the condition that suppresses the output for
migration jobs that did not start. Since the only place that actually
uses the condition that suppresses the output is in migration, let's
move the check there and thus add support for 0 of 0 equaling to 100%.

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

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

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

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

9 years agoqemu: Align memory module sizes to 2MiB
Peter Krempa [Wed, 23 Sep 2015 11:07:03 +0000 (13:07 +0200)]
qemu: Align memory module sizes to 2MiB

My original implementation was based on a qemu version that still did
not have all the checks in place. Using sizes that would align to odd
megabyte increments will produce the following error:

qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,id=dimm0: backend memory size must be multiple of 0x200000
qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,id=dimm0: Device 'pc-dimm' could not be initialized

Introduce an alignment retrieval function for memory devices and use it
to align the devices separately and modify a test case to verify it.

9 years agovirsh: Notify users about disconnects
Jiri Denemark [Tue, 15 Sep 2015 14:46:07 +0000 (16:46 +0200)]
virsh: Notify users about disconnects

After my "client rpc: Report proper error for keepalive disconnections"
patch, virsh would no long print a warning when it closes a connection
to a daemon after a keepalive timeout. Although the warning

    virsh # 2015-09-15 10:59:26.729+0000: 642080: info :
    libvirt version: 1.2.19
    2015-09-15 10:59:26.729+0000: 642080: warning :
    virKeepAliveTimerInternal:143 : No response from client
    0x7efdc0a46730 after 1 keepalive messages in 2 seconds

was pretty ugly, it was still useful. This patch brings the useful part
back while making it much nicer:

virsh # error: Disconnected from qemu:///system due to keepalive timeout

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoclient rpc: Process pending data on error
Jiri Denemark [Tue, 15 Sep 2015 14:45:41 +0000 (16:45 +0200)]
client rpc: Process pending data on error

Even though we hit an error in client's IO loop, we still want to
process any pending data. So instead of reporting the error right away,
we can finish the current iteration and report the error once we're done
with it. Note that the error is stored in client->error by
virNetClientMarkClose so we don't need to worry about it being reset or
rewritten by any API we call in the meantime.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoclient rpc: Report proper error for keepalive disconnections
Jiri Denemark [Fri, 11 Sep 2015 15:07:56 +0000 (17:07 +0200)]
client rpc: Report proper error for keepalive disconnections

Whenever a connection was closed due to keepalive timeout, we would log
a warning but the interrupted API would return rather useless generic
error:

    internal error: received hangup / error event on socket

Let's report a proper keepalive timeout error and make sure it is
propagated to all pending APIs. The error should be better now:

    internal error: connection closed due to keepalive timeout

Based on an old patch from Martin Kletzander.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoconf: escape string for disk driver name attribute
Luyao Huang [Tue, 22 Sep 2015 08:13:53 +0000 (16:13 +0800)]
conf: escape string for disk driver name attribute

Just like e92e5ba1, this attribute was missed.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoUse VIR_DIV_UP macro where possible
Martin Kletzander [Mon, 24 Aug 2015 13:54:26 +0000 (15:54 +0200)]
Use VIR_DIV_UP macro where possible

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoMakefile: fix build fail when make rpm
Luyao Huang [Wed, 23 Sep 2015 02:09:47 +0000 (10:09 +0800)]
Makefile: fix build fail when make rpm

Build fail and error like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_command.lo
qemu/qemu_capabilities.c:46:27: fatal error: qemu_capspriv.h: No such file or directory
 #include "qemu_capspriv.h"

Add qemu_capspriv.h to source.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agospec: Fix some warnings with latest rpmbuild
Cole Robinson [Tue, 22 Sep 2015 19:56:50 +0000 (15:56 -0400)]
spec: Fix some warnings with latest rpmbuild

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

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

9 years agotests: Avoid use of virQEMUDriverCreateXMLConf(NULL)
Michal Privoznik [Tue, 22 Sep 2015 14:27:57 +0000 (16:27 +0200)]
tests: Avoid use of virQEMUDriverCreateXMLConf(NULL)

We use the function to create a virDomainXMLOption object that is
required for some functions. However, we don't pass the driver
pointer to the object anywhere - rather than pass NULL. This
causes trouble later when parsing a domain XML and calling post
parse callbacks:

  Program received signal SIGSEGV, Segmentation fault.
  0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
  1043        qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
  (gdb) bt
  #0  0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
  #1  0x00007ffff2928bf9 in virDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, xmlopt=0x7c82c0) at conf/domain_conf.c:4269
  #2  0x00007ffff294de04 in virDomainDefParseXML (xml=0x7da8c0, root=0x7dab80, ctxt=0x7da980, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16400
  #3  0x00007ffff294e5b5 in virDomainDefParseNode (xml=0x7da8c0, root=0x7dab80, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16582
  #4  0x00007ffff294e424 in virDomainDefParse (xmlStr=0x0, filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16529
  #5  0x00007ffff294e4b2 in virDomainDefParseFile (filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16553
  #6  0x00000000004303ca in testSELinuxLoadDef (testname=0x53c929 "disks") at securityselinuxlabeltest.c:192
  #7  0x00000000004309e8 in testSELinuxLabeling (opaque=0x53c929) at securityselinuxlabeltest.c:313
  #8  0x0000000000431207 in virtTestRun (title=0x53c92f "Labelling \"disks\"", body=0x430964 <testSELinuxLabeling>, data=0x53c929) at testutils.c:211
  #9  0x0000000000430c5d in mymain () at securityselinuxlabeltest.c:373
  #10 0x00000000004325c2 in virtTestMain (argc=1, argv=0x7fffffffd7e8, func=0x430b4a <mymain>) at testutils.c:863
  #11 0x0000000000430deb in main (argc=1, argv=0x7fffffffd7e8) at securityselinuxlabeltest.c:381

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuTestDriverInit: init the driver lock too
Michal Privoznik [Tue, 22 Sep 2015 14:12:39 +0000 (16:12 +0200)]
qemuTestDriverInit: init the driver lock too

Even though usage of the lock is limited to a very few cases,
it's still needed. Therefore we should initialize it too.
Otherwise we may get some random test failures:

==1204== Conditional jump or move depends on uninitialised value(s)
==1204==    at 0xEF7F7CF: pthread_mutex_lock (in /lib64/libpthread-2.20.so)
==1204==    by 0x9CA89A5: virMutexLock (virthread.c:89)
==1204==    by 0x450B2A: qemuDriverLock (qemu_conf.c:83)
==1204==    by 0x45549C: virQEMUDriverGetConfig (qemu_conf.c:869)
==1204==    by 0x448E29: qemuDomainDeviceDefPostParse (qemu_domain.c:1240)
==1204==    by 0x9CC9B13: virDomainDeviceDefPostParse (domain_conf.c:4224)
==1204==    by 0x9CC9B91: virDomainDefPostParseDeviceIterator (domain_conf.c:4251)
==1204==    by 0x9CC7843: virDomainDeviceInfoIterateInternal (domain_conf.c:3440)
==1204==    by 0x9CC9C25: virDomainDefPostParse (domain_conf.c:4276)
==1204==    by 0x9CEEE03: virDomainDefParseXML (domain_conf.c:16400)
==1204==    by 0x9CEF5B4: virDomainDefParseNode (domain_conf.c:16582)
==1204==    by 0x9CEF423: virDomainDefParse (domain_conf.c:16529)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRevert "qemu: Fix integer/boolean logic in qemuSetUnprivSGIO"
John Ferlan [Fri, 18 Sep 2015 12:18:38 +0000 (08:18 -0400)]
Revert "qemu: Fix integer/boolean logic in qemuSetUnprivSGIO"

This reverts commit 69b850fe2a19d0c32ae2f209e8d8463df6ead665.

This change broke the ability to "clear" or reset unfiltered back
to filtered.

9 years agotest: Add test to validate that memory sizes don't get updated on migration
Peter Krempa [Mon, 21 Sep 2015 17:10:12 +0000 (19:10 +0200)]
test: Add test to validate that memory sizes don't get updated on migration

9 years agoqemu: ppc64: Align memory sizes to 256MiB blocks
Peter Krempa [Mon, 21 Sep 2015 16:10:55 +0000 (18:10 +0200)]
qemu: ppc64: Align memory sizes to 256MiB blocks

For some machine types ppc64 machines now require that memory sizes are
aligned to 256MiB increments (due to the dynamically reconfigurable
memory). As now we treat existing configs reasonably in regards to
migration, we can round all the sizes unconditionally. The only drawback
will be that the memory size of a VM can potentially increase by
(256MiB - 1byte) * number_of_NUMA_nodes.

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

9 years agoqemu: command: Align memory sizes only on fresh starts
Peter Krempa [Thu, 17 Sep 2015 06:14:05 +0000 (08:14 +0200)]
qemu: command: Align memory sizes only on fresh starts

When we are starting a qemu process for an incomming migration or
snapshot reloading we should not modify the memory sizes in the domain
since we could potentially change the guest ABI that was tediously
checked before. Additionally the function now updates the initial memory
size according to the NUMA node size, which should not happen if we are
restoring state.

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

9 years agoconf: Don't always recalculate initial memory size from NUMA size totals
Peter Krempa [Fri, 18 Sep 2015 15:24:32 +0000 (17:24 +0200)]
conf: Don't always recalculate initial memory size from NUMA size totals

When implementing memory hotplug I've opted to recalculate the initial
memory size (contents of the <memory> element) as a sum of the sizes of
NUMA nodes when NUMA was enabled. This was based on an assumption that
qemu did not allow starting when the NUMA node size total didn't equal
to the initial memory size. Unfortunately the check was introduced to
qemu just lately.

This patch uses the new XML parser flag to decide whether it's safe to
update the memory size total from the NUMA cell sizes or not.

As an additional improvement we now report an error in case when the
size of hotplug memory would exceed the total memory size.

The rest of the changes assures that the function is called with correct
flags.

9 years agoconf: Pre-calculate initial memory size instead of always calculating it
Peter Krempa [Thu, 13 Aug 2015 14:39:28 +0000 (16:39 +0200)]
conf: Pre-calculate initial memory size instead of always calculating it

Add 'initial_memory' member to struct virDomainMemtune so that the
memory size can be pre-calculated once instead of inferring it always
again and again.

Separating of the fields will also allow finer granularity of decisions
in later patches where it will allow to keep the old initial memory
value in cases where we are handling incomming migration from older
versions that did not always update the size from NUMA as the code did
previously.

The change also requires modification of the qemu memory alignment
function since at the point where we are modifying the size of NUMA
nodes the total size needs to be recalculated too.

The refactoring done in this patch also fixes a crash in the hyperv
driver that did not properly initialize def->numa and thus
virDomainNumaGetMemorySize(def->numa) crashed.

In summary this patch should have no functional impact at this point.

9 years agoconf: Rename max_balloon to total_memory
Peter Krempa [Wed, 16 Sep 2015 12:25:42 +0000 (14:25 +0200)]
conf: Rename max_balloon to total_memory

The name of the variable was misleading. Rename it and it's setting
accessor before other fixes.

9 years agoconf: Split memory related post parse stuff into separate function
Peter Krempa [Tue, 15 Sep 2015 14:59:23 +0000 (16:59 +0200)]
conf: Split memory related post parse stuff into separate function

The post parse func is growing rather large. Since later patches will
introduce more logic in the memory post parse code, split it into a
separate handler.

9 years agoconf: Add XML parser flag that will allow us to do incompatible updates
Peter Krempa [Tue, 15 Sep 2015 15:04:55 +0000 (17:04 +0200)]
conf: Add XML parser flag that will allow us to do incompatible updates

Add a new parser flag that will mark code paths that parse XML files
wich will not be used with existing VM state so that post parse
callbacks can possibly do ABI incompatible changes if needed.

9 years agoconf: Document all VIR_DOMAIN_DEF_PARSE_* flags
Peter Krempa [Tue, 15 Sep 2015 13:23:53 +0000 (15:23 +0200)]
conf: Document all VIR_DOMAIN_DEF_PARSE_* flags

9 years agoconf: Drop VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST flag
Peter Krempa [Tue, 15 Sep 2015 12:08:52 +0000 (14:08 +0200)]
conf: Drop VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST flag

The flag was used only for formatting the XML and once the parser and
formatter flags were split in 0ecd6851093945dd5ddc78266c61b577c65394ae
it doesn't make sense any more to have it.

9 years agoqemu: Make memory alignment helper more universal
Peter Krempa [Fri, 31 Jul 2015 14:00:20 +0000 (16:00 +0200)]
qemu: Make memory alignment helper more universal

Extract the size determination into a separate function and reuse it
across the memory device alignment functions. Since later we will need
to decide the alignment size according to architecture let's pass def to
the functions.

9 years agoconf: Add helper to determine whether memory hotplug is enabled for a vm
Peter Krempa [Mon, 14 Sep 2015 14:42:46 +0000 (16:42 +0200)]
conf: Add helper to determine whether memory hotplug is enabled for a vm

Add a simple helper so that the code doesn't have to rewrite the same
condition multiple times.

9 years agolibxl: vz: Use accessor instead of direct access for max_balloon
Peter Krempa [Wed, 16 Sep 2015 12:00:02 +0000 (14:00 +0200)]
libxl: vz: Use accessor instead of direct access for max_balloon

Commits 45697fe5 and f863ac80 used direct access to the variable instead
of the preferred accessor method.

9 years agoRemoved unneeded check
Pavel Fedin [Wed, 9 Sep 2015 14:03:16 +0000 (17:03 +0300)]
Removed unneeded check

Since test suite now correctly creates capabilities cache, the hack is not
needed any more.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agotests: use mockup cache
Pavel Fedin [Wed, 9 Sep 2015 14:03:15 +0000 (17:03 +0300)]
tests: use mockup cache

Use the new API in order to correctly add capability sets to the cache
before parsing XML files

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoImplement infrastracture for mocking up QEMU capabilities cache
Pavel Fedin [Wed, 9 Sep 2015 14:03:14 +0000 (17:03 +0300)]
Implement infrastracture for mocking up QEMU capabilities cache

The main purpose of this patch is to introduce test mode to
virQEMUCapsCacheLookup(). This is done by adding a global variable, which
effectively overrides binary name. This variable is supposed to be set by
test suite.

The second addition is qemuTestCapsCacheInsert() function which allows the
test suite to actually populate the cache.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agotests: split out common qemu driver initialization
Pavel Fedin [Tue, 15 Sep 2015 06:16:02 +0000 (08:16 +0200)]
tests: split out common qemu driver initialization

Two utility functions are introduced for proper initialization and
cleanup of the driver.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agotest driver: don't unlock pool after freeing it
David Mansfield [Thu, 17 Sep 2015 12:59:24 +0000 (08:59 -0400)]
test driver: don't unlock pool after freeing it

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

9 years agovirfile: Use virProcessWait in virDirCreate
John Ferlan [Tue, 15 Sep 2015 12:27:38 +0000 (08:27 -0400)]
virfile: Use virProcessWait in virDirCreate

Rather than inlining the code, use the common API.

9 years agovirfile: Use virProcessWait in virFileUnlink
John Ferlan [Mon, 14 Sep 2015 20:51:14 +0000 (16:51 -0400)]
virfile: Use virProcessWait in virFileUnlink

Rather than inlining the code, use the common API.

9 years agovirfile: Use virProcessWait in virFileOpenForked
John Ferlan [Tue, 8 Sep 2015 22:09:53 +0000 (18:09 -0400)]
virfile: Use virProcessWait in virFileOpenForked

Rather than inlining the code, use the common API

9 years agovirfile: Rename virFileUnlink to virFileRemove
John Ferlan [Mon, 21 Sep 2015 11:36:55 +0000 (07:36 -0400)]
virfile: Rename virFileUnlink to virFileRemove

Similar to commit id '35847860', it's possible to attempt to create
a 'netfs' directory in an NFS root-squash environment which will cause
the 'vol-delete' command to fail.  It's also possible error paths from
the 'vol-create' would result in an error to remove a created directory
if the permissions were incorrect (and disallowed root access).

Thus rename the virFileUnlink to be virFileRemove to match the C API
functionality, adjust the code to following using rmdir or unlink
depending on the path type, and then use/call it for the VIR_STORAGE_VOL_DIR

9 years agovz: remove error logging from prlsdkUUIDParse
Maxim Nestratov [Mon, 21 Sep 2015 11:08:41 +0000 (14:08 +0300)]
vz: remove error logging from prlsdkUUIDParse

As far as not every call of prlsdkUUIDParse assume correct UUID
supplied, there is no use to complain about wrong format in it.
Otherwise our log is flooded with false error messages.
For instance, calling prlsdkUUIDParse from prlsdkEventsHandler
works as a filter and in case of uuid absence for event issuer,
we simply know that we shouldn't continue further processing.
Instead of error logging for all calls we should explicitly take
into accaunt where it is called from.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainChangeDiskLive: Allow startupPolicy change
Michal Privoznik [Tue, 15 Sep 2015 15:13:01 +0000 (17:13 +0200)]
qemuDomainChangeDiskLive: Allow startupPolicy change

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainDiskChangeSupported: Fill in missing checks
Michal Privoznik [Tue, 15 Sep 2015 13:41:18 +0000 (15:41 +0200)]
qemuDomainDiskChangeSupported: Fill in missing checks

So far this function was not kept in sync with changing
virDomainDiskDef. Fill in all the missing checks and reorganize
their order so it's easier to track which items are not being
checked for.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: s/virDomainDiskDiffersSourceOnly/qemuDomainDiskChangeSupported/
Michal Privoznik [Tue, 15 Sep 2015 13:25:18 +0000 (15:25 +0200)]
qemu: s/virDomainDiskDiffersSourceOnly/qemuDomainDiskChangeSupported/

I always felt like this function is qemu specific rather than
libvirt-wide. Other drivers may act differently on virDomainDef
change and in fact may require talking to underlying hypervisor
even if something else's than disk->src has changed.  I know that
the function is still incomplete, but lets break that into two
commits that are easier to review. This one is pure code
movement.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainChangeDiskLive: rework slightly
Michal Privoznik [Tue, 15 Sep 2015 12:37:21 +0000 (14:37 +0200)]
qemuDomainChangeDiskLive: rework slightly

Firstly, our coding guidelines suggest using 'cleanup' label
instead of 'end'. Then, @ret should be set to value representing
success as the last statement before the 'cleanup' label.
And while I am at this function, lets enumerate all the possible
enum items (virDomainDiskDevice) and avoid using 'default' in
switch(). Pooh. Also, nothing bad happens if we look up the disk
to change in the domain upfront. In fact, it's going to be
helpful later when we want to keep some old values for performing
a rollback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu_domain: Introduce qemuDomainDiskSourceDiffers
Michal Privoznik [Tue, 15 Sep 2015 11:41:42 +0000 (13:41 +0200)]
qemu_domain: Introduce qemuDomainDiskSourceDiffers

This new private API should return true iff sources of two disks
differs in sense that qemu should be instructed to change the
disk backend. For instance, ejecting a CDROM is such case, or
pointing disk into a different ISO location, and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: s/qemuDomainChangeDiskMediaLive/qemuDomainChangeDiskLive/
Michal Privoznik [Tue, 15 Sep 2015 11:16:24 +0000 (13:16 +0200)]
qemu: s/qemuDomainChangeDiskMediaLive/qemuDomainChangeDiskLive/

While we currently only allow changing a media in a disk, this is
going to change in a while, so the function name would be
invalid. Moreover, the old name does not match the pattern laid
out by other update functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again
Michal Privoznik [Mon, 14 Sep 2015 10:59:53 +0000 (12:59 +0200)]
qemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again

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

So, in 11e058ca589808bd I've tried to make UpdateDevice update
startupPolicy too. And it worked well until somebody came around
and pushed d0dc6c036914da which accidentally removed my
contribution. Redo my commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix some corner cases in persistent migration
Jiri Denemark [Thu, 10 Sep 2015 22:14:59 +0000 (00:14 +0200)]
qemu: Fix some corner cases in persistent migration

When persistently migrating a domain to a destination host where the
same domain already exists (i.e., it is persistent and shutdown at the
destination), we would happily throw away the original persistent
definition without properly freeing it. And when updating the definition
fails for some reason we don't properly revert to the original state
leaving the domain broken.

In addition to fixing these issues, the patch also makes sure the domain
definition parsed from a migration cookie is either used or freed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Queue events in migration Finish phase ASAP
Jiri Denemark [Tue, 7 Jul 2015 13:54:39 +0000 (15:54 +0200)]
qemu: Queue events in migration Finish phase ASAP

For quite a long time we don't need to postpone queueing events until
the end of the function since we no longer have the big driver lock.
Let's make the code of qemuMigrationFinish simpler by queuing events at
the time we generate them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemuDomainEventQueue: Check if event is non-NULL
Jiri Denemark [Tue, 7 Jul 2015 13:33:53 +0000 (15:33 +0200)]
qemuDomainEventQueue: Check if event is non-NULL

Every single call to qemuDomainEventQueue() uses the following pattern:

    if (event)
        qemuDomainEventQueue(driver, event);

Let's move the check for valid event to qemuDomainEventQueue and
simplify all callers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>