]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
9 years agomigration: refactor: introduce parameter checking function
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:51 +0000 (10:52 +0300)]
migration: refactor: introduce parameter checking function

virDomainMigrateUnmanagedParams is not a good candidate for this functionality
as it is used by migrate family functions too and its have its own checks that
are superset of extracted and we don't need to check twice.

Actually name of the function is slightly misleading as there is also a check
for consistensy of flags parameter alone. So it could be refactored further and
reused by all migrate functions but for now let it be a matter of a different
patchset.

It is *not* a pure refactoring patch as it introduces offline check for older
versions. Looks like it must be done that way and no one will be broken too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: merge all proto branches into single function
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:50 +0000 (10:52 +0300)]
migration: merge all proto branches into single function

Finally on this step we get what we were aimed for - toURI{1, 2} (and
migration{*} APIs too) now can work thru V3_PARAMS protocol. Execution path
goes thru unchanged virDomainMigrateUnmanaged adapter function which is called
by all target places.

Note that we keep the fact that direct migration never works
thru V3_PARAMS proto. We can't change this aspect without
further investigation.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: refactor parameter compatibility checks
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:49 +0000 (10:52 +0300)]
migration: refactor: refactor parameter compatibility checks

Move virDomainMigrateUnmanagedProto* expected params list check into
function itself and use common virTypedParamsCheck for this purpose.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: extract parameter adaption functions
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:48 +0000 (10:52 +0300)]
migration: refactor: extract parameter adaption functions

Extract parameter adaptation and checking which is protocol dependent into
designated functions. Leave only branching and common checks in
virDomainMigrateUnmanagedParams.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: introduce params version of unmanaged
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:47 +0000 (10:52 +0300)]
migration: refactor: introduce params version of unmanaged

Let's put main functionality into params version of virDomainMigrateUnmanaged
as a preparation step for merging it with virDomainMigratePeer2PeerParams.
virDomainMigrateUnmanaged then does nothing more then just adapting arguments.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: merge direct and p2p into unmanaged
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:46 +0000 (10:52 +0300)]
migration: refactor: merge direct and p2p into unmanaged

p2p plain and direct function are good candidates for code reuse. Their main
function is same - to branch among different versions of migration protocol and
implementation of this function is also same. Also they have other common
functionality in lesser aspects. So let's merge them.

But as they have different signatures we have to get to convention on how to
pass direct migration 'uri' in 'dconnuri' and 'miguri'. Fortunately we alreay
have such convention in parameters passed to toURI2 function, just let's follow
it. 'uri' is passed in miguri and dconnuri is ignored.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: rename uri parameter to miguri
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:45 +0000 (10:52 +0300)]
migration: refactor: rename uri parameter to miguri

We use miguri name for this parameter in other places. So
make naming more consitent.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: remove direct migration dependency on version1 of driver
Michal Privoznik [Fri, 2 Oct 2015 07:52:44 +0000 (10:52 +0300)]
migration: remove direct migration dependency on version1 of driver

Direct migration should work if *perform3 is present but *perform
is not. This is situation when driver migration is implemented
after new version of driver function is introduced. We should not
be forced to support old version too as its parameter space is
subspace of newer one.

9 years agomigration: move implementation check to branches in p2p
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:43 +0000 (10:52 +0300)]
migration: move implementation check to branches in p2p

This is more structured code so it will be easier to add branch for _PARAMS
protocol here. It is not a pure refactoring strictly speaking as we remove
scenarios for broken cases when driver defines V3 feature and implements
perform function. So it is additionally a more solid code.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: reuse p2p url check
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:42 +0000 (10:52 +0300)]
migration: refactor: reuse p2p url check

Refactor dconnuri local server URI check to common API.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agomigration: refactor: get rid of use_params p2p_full
Nikolay Shirokovskiy [Fri, 2 Oct 2015 07:52:41 +0000 (10:52 +0300)]
migration: refactor: get rid of use_params p2p_full

'useParams' parameter usage is an example of control coupling. Most of the work
inside the function is done differently except for the uri check. Lets split
this function into two, one with extensible parameters set and one with hardcoded
parameter set.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovirJSONValueArraySize: return ssize_t
Michal Privoznik [Thu, 8 Oct 2015 08:17:42 +0000 (10:17 +0200)]
virJSONValueArraySize: return ssize_t

The internal representation of a JSON array counts the items in
size_t. However, for some reason, when asking for the count it's
reported as int. Firstly, we need the function to return a signed
type as it's returning -1 on an error. But, not every system has
integer the same size as size_t. Therefore, lets return ssize_t.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosrc: Remove $(builddir) usage
Andrea Bolognani [Fri, 9 Oct 2015 09:20:06 +0000 (11:20 +0200)]
src: Remove $(builddir) usage

Commit 4e8032272f1704f7 used $(builddir) in the header search
path to fix a build issue; however, $(builddir) is not defined
by old autoconf versions such as the one available in CentOS 5,
resulting in the following error:

  cc1: error: /util: No such file or directory
  make[3]: *** [libvirt_driver_la-fdstream.lo] Error 1

Since $(builddir) is defined to always be '.', just use that
value directly instead.

9 years agosrc: Include $(builddir)/util in the header search path
Andrea Bolognani [Thu, 8 Oct 2015 06:35:29 +0000 (08:35 +0200)]
src: Include $(builddir)/util in the header search path

Since a9fe620372144db, we are generating virkeymaps.h at build
time; however, we are not including $(builddir)/util in the
header search path, so when doing a VPATH build the compiler
is unable to locate the file.

make[2]: Entering directory
`/home/jenkins/libvirt/systems/libvirt-fedora-20/build/src'
  GEN      util/virkeymaps.h
  ...
  CC       util/libvirt_util_la-virkeycode.lo
  CC       util/libvirt_util_la-virkeyfile.lo
  CC       util/libvirt_util_la-virlockspace.lo
  CC       util/libvirt_util_la-virlog.lo
../../src/util/virkeycode.c:27:24: fatal error: virkeymaps.h: No such file or directory
 #include "virkeymaps.h"
                        ^
compilation terminated.

9 years agovz: cleanup
Maxim Nestratov [Wed, 7 Oct 2015 10:05:00 +0000 (13:05 +0300)]
vz: cleanup

Remove unused definitions, functions and structure fields.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agostorage: Perform some cleanup of calls
John Ferlan [Mon, 5 Oct 2015 13:53:02 +0000 (09:53 -0400)]
storage: Perform some cleanup of calls

Cleanup calls to virStorageBackendCopyToFD a bit.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoAUTHORS: Add myself to the list of committers
Andrea Bolognani [Thu, 8 Oct 2015 09:33:39 +0000 (11:33 +0200)]
AUTHORS: Add myself to the list of committers

9 years agoqemu: Resolve Coverity FORWARD_NULL
John Ferlan [Thu, 24 Sep 2015 21:32:59 +0000 (17:32 -0400)]
qemu: Resolve Coverity FORWARD_NULL

Coverity notices that net->ifname is potentially referenced after a
VIR_FREE().  Since the net->ifname will eventually be free'd during
virDomainDefFree when calling virDomainNetDefFree, let's just that
processing take care the free.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agolibxl: Resolve Coverity FORWARD_NULL
John Ferlan [Thu, 24 Sep 2015 18:57:14 +0000 (14:57 -0400)]
libxl: Resolve Coverity FORWARD_NULL

Since the strtok_r call in libxlCapsInitGuests expects a non NULL first
parameter when the third parameter is NULL, we need to check that
the returned 'capabilities' from a libxl_get_version_info call is
not NULL and error out if so since the code expects it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirSecurityManagerNew: Turn array of booleans into flags
Michal Privoznik [Tue, 6 Oct 2015 15:01:48 +0000 (17:01 +0200)]
virSecurityManagerNew: Turn array of booleans into flags

So imagine you want to crate new security manager:

  if (!(mgr = virSecurityManagerNew("selinux", "QEMU", false, true, false, true)));

Hard to parse, right? What about this:

  if (!(mgr = virSecurityManagerNew("selinux", "QEMU",
                                    VIR_SECURITY_MANAGER_DEFAULT_CONFINED |
                                    VIR_SECURITY_MANAGER_PRIVILEGED)));

Now that's better! This is what the commit does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotests: eventtest: Fix coverity warning
Cole Robinson [Wed, 7 Oct 2015 14:48:45 +0000 (10:48 -0400)]
tests: eventtest: Fix coverity warning

We can ignore the result of virtTestResult here, because failure is
unconditionally reported by the callers

9 years agoqemu: Fix indentation issue
Andrea Bolognani [Wed, 7 Oct 2015 09:07:11 +0000 (11:07 +0200)]
qemu: Fix indentation issue

Two #define lines introduced by b527aa0 did not respect the
indentation rules, thus breaking syntax-check.

9 years agoqemu: Remove explicit values from virQEMUCapsFlags
Andrea Bolognani [Tue, 6 Oct 2015 14:28:25 +0000 (16:28 +0200)]
qemu: Remove explicit values from virQEMUCapsFlags

This gets rid of the partially enforced alignment and makes it less
likely for a bogus value to be introduced in the enumeration.
Capabilities are divided in five-element groups for better readability.

Use #define for QEMU_CAPS_NET_NAME and QEMU_CAPS_HOST_NET_ADD, both
of which are aliases for QEMU_CAPS_0_10.

9 years agoqemu: migration: Skip few checks while doing offline migration
Peter Krempa [Tue, 6 Oct 2015 15:02:09 +0000 (17:02 +0200)]
qemu: migration: Skip few checks while doing offline migration

qemuMigrationIsAllowed would disallow offline migration if the VM
contained host devices or memory modules. Since during offline migration
we don't transfer any state we can safely migrate VMs with such
configuration.

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

9 years agoqemu: migration: Use migration flags in qemuMigrationIsAllowed
Peter Krempa [Tue, 6 Oct 2015 14:24:48 +0000 (16:24 +0200)]
qemu: migration: Use migration flags in qemuMigrationIsAllowed

Use the migration @flags for checking various migration aspects rather
than picking them out as booleans. Document the new semantics in the
function header.

9 years agoqemu: migration: Drop @def from qemuMigrationIsAllowed
Peter Krempa [Tue, 6 Oct 2015 13:53:02 +0000 (15:53 +0200)]
qemu: migration: Drop @def from qemuMigrationIsAllowed

Now that qemuMigrationIsAllowed is always called with @vm, we can drop
the @def argument and simplify the control flow.

Additionally the comment is invalid so drop it.

9 years agoqemu: migration: Split source and destination migration checks
Peter Krempa [Tue, 6 Oct 2015 13:39:48 +0000 (15:39 +0200)]
qemu: migration: Split source and destination migration checks

Extract the hostdev check from qemuMigrationIsAllowed into a separate
function since that is the only part that needs to be done in the v2
migration protocol prepare phase on the destination. All other checks
were added when the v3 protocol existed so they don't need to be
extracted.

This change will allow to drop the @def argument for
qemuMigrationIsAllowed and further simplify the function.

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

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

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

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

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

9 years agovz: remove storage driver as never used
Maxim Nestratov [Tue, 22 Sep 2015 10:33:00 +0000 (13:33 +0300)]
vz: remove storage driver as never used

In fact, it was never used as far as vz has no features supporting it.
That is why there will be no harm to anyone if we just remove this code to
prevent further misunderstanding and efforts to support dead code.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: remove network driver as never used
Maxim Nestratov [Tue, 22 Sep 2015 10:33:00 +0000 (13:33 +0300)]
vz: remove network driver as never used

At the time this code was added we had intentions to support libvirt interface
to manage vz networks. In fact, it was never implemented completely to work
correctly that makes me think that there will be no harm to anyone if we just
rip it off. Moreover, in vz7 we started to use libvirt bridge network driver to
manage networks.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agotests: qemu: Add aarch64 virtio pci tests
Cole Robinson [Wed, 30 Sep 2015 00:10:07 +0000 (20:10 -0400)]
tests: qemu: Add aarch64 virtio pci tests

- qemuxml2argv-aarch64-mmio-default-pci: Verify that we still default
  to virtio-mmio even if qemu is new enough to support PCI
- qemuxml2argv-aarch64-virtio-pci: Check generated arm virtio PCI args

9 years agodocs: domain: Show canonical pvspinlock XML
Cole Robinson [Mon, 5 Oct 2015 18:56:59 +0000 (14:56 -0400)]
docs: domain: Show canonical pvspinlock XML

The example pvspinlock XML is:

  <pvspinlock/>

While this is accepted by libvirt and works correctly, it's currently
always output as a tristate like

  <pvspinlock state='on'/>

So document that format instead

9 years agoqemu: Wait until destination QEMU consumes all migration data
Jiri Denemark [Fri, 2 Oct 2015 10:08:26 +0000 (12:08 +0200)]
qemu: Wait until destination QEMU consumes all migration data

Even though QEMU on the source host reports completed migration and thus
we move to the Finish phase, QEMU on the destination host may still be
processing migration data. Thus before we can start guest CPUs on the
destination, we have to wait for a completed migration event.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Make updating stats in qemuMigrationCheckJobStatus optional
Jiri Denemark [Mon, 5 Oct 2015 12:32:58 +0000 (14:32 +0200)]
qemu: Make updating stats in qemuMigrationCheckJobStatus optional

With new QEMU which supports migration events,
qemuMigrationCheckJobStatus needs to explicitly query QEMU for migration
statistics once migration is completed to make sure the caller sees
up-to-date statistics with both old and new QEMU. However, some callers
are not interested in the statistics at all and once we start waiting
for a completed migration on the destination host too, checking the
statistics would even fail. Let's push the decision whether to update
the statistics or not to the caller.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce flags in qemuMigrationCompleted
Jiri Denemark [Mon, 5 Oct 2015 12:36:15 +0000 (14:36 +0200)]
qemu: Introduce flags in qemuMigrationCompleted

The function already has two bool parameters and we will need to add a
new one. Let's switch to flags to make the callers readable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Copy completed migration stats only on success
Jiri Denemark [Thu, 1 Oct 2015 19:54:38 +0000 (21:54 +0200)]
qemu: Copy completed migration stats only on success

The destination host gets detailed statistics about the current
migration form the source host via migration cookie and copies them to
the domain object so that they can be queried using
virDomainGetJobStats. However, we should only copy statistics to the
domain object when migration finished successfully.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Always update migration times on destination
Jiri Denemark [Thu, 1 Oct 2015 19:39:35 +0000 (21:39 +0200)]
qemu: Always update migration times on destination

Even if we are migrating a domain with VIR_MIGRATE_PAUSED flag set, we
should still update the total time of the migration. Updating downtime
doesn't hurt either, even though we don't actually start guest CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Check GIC-related XMLs in qemuxml2xmltest
Martin Kletzander [Wed, 30 Sep 2015 14:36:24 +0000 (16:36 +0200)]
tests: Check GIC-related XMLs in qemuxml2xmltest

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoDo not distribute generated virkeymaps.h
Martin Kletzander [Tue, 8 Sep 2015 13:04:46 +0000 (15:04 +0200)]
Do not distribute generated virkeymaps.h

We are distributing virkeymaps.h and all the tools needed to rebuild
that file.  On top of that, we are generating that file into the
$(srcdir) and that sometimes fails when trying to do make dist in VPATH
on rawhide fedora.  And we don't clean the file when maintainer-clean
make target is requested.  So let's not distribute the file and rather
let everyone rebuild it when needed and clean it when appropriate.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoapparmor: differentiate between error and unconfined profiles
Cédric Bosdonnat [Tue, 6 Oct 2015 09:12:29 +0000 (11:12 +0200)]
apparmor: differentiate between error and unconfined profiles

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

9 years agoconf: Remove <metadata> elements with no namespace
Peter Krempa [Mon, 5 Oct 2015 07:58:30 +0000 (09:58 +0200)]
conf: Remove <metadata> elements with no namespace

Our docs state that subelements of <metadata> shall have a namespace
and the medatata APIs expect that too. To avoid inaccessible
<metadata> sub-elements, just remove those that don't conform to the
documentation.

Apart from adding the new condition this patch renames the function and
refactors the code flow to allow the changes.

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

9 years agotestutils: Drop virtTestResult
Cole Robinson [Tue, 29 Sep 2015 15:01:48 +0000 (11:01 -0400)]
testutils: Drop virtTestResult

virtTestResult is suboptimal for a few reasons:

- It poorly duplicates virtTestRun pass/fail reporting logic
- It doesn't have virtTestRun's alloc testing support
- It only reports the test name _after_ the test has run.
- It doesn't follow the standard virtTestRun pattern that most other
  tests use.

There's no users left, so drop it. If any other async tests like eventtest
spring up that don't cleanly fit the virtTestRun pattern, I suggest they
just open code the support for it around virtTestRun

9 years agotests: eventtest: Open code virtTestResult
Cole Robinson [Tue, 29 Sep 2015 14:55:22 +0000 (10:55 -0400)]
tests: eventtest: Open code virtTestResult

These event tests aren't run synchronously, so there isn't an obvious
function to pass to virtTestRun. Instead, open code roughly what
virtTestResult did before: printing an error message if a test failed.

9 years agotests: sheepdog: Drop use of virtTestResult
Cole Robinson [Tue, 29 Sep 2015 14:34:38 +0000 (10:34 -0400)]
tests: sheepdog: Drop use of virtTestResult

Instead use the same pattern that most other test files use.

9 years agotestutils: Add coloring to verbose PASS/FAILED output
Cole Robinson [Tue, 29 Sep 2015 15:28:15 +0000 (11:28 -0400)]
testutils: Add coloring to verbose PASS/FAILED output

Helps to visually track down test failures if debugging the test suite.

The colors match what 'make check' does for pass/fail/skip

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