]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agovboxDumpDisplay: more indentation reducing
Ján Tomko [Fri, 5 Feb 2016 16:13:25 +0000 (17:13 +0100)]
vboxDumpDisplay: more indentation reducing

VRDxEnabled is initialized to false. Put the if (VRDxEnabled)
on the top level to reduce nesting.

9 years agovboxDumpDisplay: reduce indentation level
Ján Tomko [Fri, 5 Feb 2016 14:36:16 +0000 (15:36 +0100)]
vboxDumpDisplay: reduce indentation level

Use STREQ_NULLABLE instead of deep nesting.

9 years agoCheck return value of vboxDumpVideo
Ján Tomko [Fri, 5 Feb 2016 13:05:07 +0000 (14:05 +0100)]
Check return value of vboxDumpVideo

Error out on allocation failures instead of creating an incomplete
definition.

Fixes a possible crash when def->nvideos is 1, but def->videos is NULL.

9 years agoleaseshelper: split out virLeaseNew
Ján Tomko [Thu, 14 Jan 2016 16:15:19 +0000 (17:15 +0100)]
leaseshelper: split out virLeaseNew

For the actions ADD and OLD, split out creating the new lease object,
as well as getting the environment variables that do not affect
the parsing of command line arguments.

9 years agoqemu: iothread: Reuse qemuProcessSetupIOThread in iothread hotplug
Peter Krempa [Thu, 14 Jan 2016 10:30:52 +0000 (11:30 +0100)]
qemu: iothread: Reuse qemuProcessSetupIOThread in iothread hotplug

Since majority of the steps is shared, the function can be reused to
simplify code.

Similarly to previous path doing this same for vCPUs this also fixes the
a similar bug (which is not tracked).

9 years agoqemu: iothread: Aggregate code to set IOThread tuning
Peter Krempa [Thu, 14 Jan 2016 09:38:02 +0000 (10:38 +0100)]
qemu: iothread: Aggregate code to set IOThread tuning

Rather than iterating 3 times for various settings this function
aggregates all the code into single place. One of the other advantages
is that it can then be reused for properly setting IOThread info on
hotplug.

9 years agoqemu: vcpu: Reuse qemuProcessSetupVcpu in vcpu hotplug
Peter Krempa [Wed, 13 Jan 2016 16:00:54 +0000 (17:00 +0100)]
qemu: vcpu: Reuse qemuProcessSetupVcpu in vcpu hotplug

Since majority of the steps is shared, the function can be reused to
simplify code.

Additionally this resolves
https://bugzilla.redhat.com/show_bug.cgi?id=1244128 since the cpu
bandwidth limiting with cgroups would not be set on the hotplug path.

Additionally the code now sets the thread affinity and honors autoCpuset
as in the regular startup code path.

9 years agoqemu: vcpu: Aggregate code to set vCPU tuning
Peter Krempa [Wed, 13 Jan 2016 15:36:52 +0000 (16:36 +0100)]
qemu: vcpu: Aggregate code to set vCPU tuning

Rather than iterating 3 times for various settings this function
aggregates all the code into single place. One of the other advantages
is that it can then be reused for properly setting vCPU info on hotplug.

With this approach autoCpuset is also used when setting the process
affinity rather than just via cgroups.

9 years agoremote: enforce VIR_TYPED_PARAM_STRING_OKAY flag on client side serialization
Joao Martins [Fri, 5 Feb 2016 19:24:05 +0000 (19:24 +0000)]
remote: enforce VIR_TYPED_PARAM_STRING_OKAY flag on client side serialization

Commit 8cd1d54 consolidates both daemon and remote driver typed param
serialization functions. The consolidation now enforces client to use
VIR_TYPED_PARAM_STRING_OKAY flag to properly serialize string parameters, which
server has used for quite some time now. And this caused an issue, since the
commit had not adjusted client remote calls appropriately, thus causing a
failure in blkiotune, numatune and migration APIs (as per Xen CI tests). This
patch adjusts both remote_driver.c and gendispatch.pl to properly address this
issue.

http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01012.html

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agovircgroup: Update virCgroupGetPercpuStats stump
Michal Privoznik [Mon, 8 Feb 2016 13:06:30 +0000 (14:06 +0100)]
vircgroup: Update virCgroupGetPercpuStats stump

In the commit 7938b533 we've changed the function signature,
however forgot to update stump that's used on systems without
CGroups causing a build failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Fix how iothread scheduler info is stored
Peter Krempa [Fri, 29 Jan 2016 14:12:26 +0000 (15:12 +0100)]
conf: Fix how iothread scheduler info is stored

Similarly to previous commit change the way how iothread scheduler info
is stored and clean up a lot of unnecessary code.

9 years agoconf: Don't store vcpusched orthogonally to other vcpu info
Peter Krempa [Tue, 12 Jan 2016 12:12:05 +0000 (13:12 +0100)]
conf: Don't store vcpusched orthogonally to other vcpu info

Due to bad design the vcpu sched element is orthogonal to the way how
the data belongs to the corresponding objects. Now that vcpus are a
struct that allow to store other info too, let's convert the data to the
sane structure.

The helpers for the conversion are made universal so that they can be
reused for iothreads too.

This patch also resolves https://bugzilla.redhat.com/show_bug.cgi?id=1235180
since with the correct storage approach you can't have dangling data.

9 years agoconf: Extract code that formats <cputune>
Peter Krempa [Thu, 7 Jan 2016 12:50:03 +0000 (13:50 +0100)]
conf: Extract code that formats <cputune>

virDomainDefFormatInternal is growing rather large. Extract the cputune
formatter into a separate function.

9 years agoconf: remove unused cpu pinning helpers and data structures
Peter Krempa [Mon, 4 Jan 2016 18:12:50 +0000 (19:12 +0100)]
conf: remove unused cpu pinning helpers and data structures

Now that the pinning info is stored elsewhere we can delete all the
obsolete code.

9 years agoconf: Store cpu pinning data in def->vcpus
Peter Krempa [Fri, 29 Jan 2016 09:20:44 +0000 (10:20 +0100)]
conf: Store cpu pinning data in def->vcpus

Now with the new struct the data can be stored in a much saner place.

9 years agoconf: Don't copy def->cpumask into cpu pinning info
Peter Krempa [Fri, 18 Dec 2015 16:31:50 +0000 (17:31 +0100)]
conf: Don't copy def->cpumask into cpu pinning info

This step can be omitted, so that drivers can decide what to do when the
user requests to use default vcpu pinning.

9 years agoqemu: Reuse qemuDomainDetectVcpuPids in cpu hot(un)plug
Peter Krempa [Tue, 15 Dec 2015 07:48:46 +0000 (08:48 +0100)]
qemu: Reuse qemuDomainDetectVcpuPids in cpu hot(un)plug

Now that qemuDomainDetectVcpuPids is able to refresh the vCPU pid
information it can be reused in the hotplug and hotunplug code paths
rather than open-coding a very similar algorithm.

A slight algorithm change is necessary for unplug since the vCPU needs
to be marked offline prior to calling the thread detector function and
eventually rolled back if something fails.

9 years agoqemu: Differentiate error codes when VM exits in qemuDomainDetectVcpuPids
Peter Krempa [Fri, 5 Feb 2016 12:03:33 +0000 (13:03 +0100)]
qemu: Differentiate error codes when VM exits in qemuDomainDetectVcpuPids

Some callers will need to behave differently when the detection failed
and when the VM crashed during the redetection. Return -2 if it crashed.

9 years agocgroup: Prepare for sparse vCPU topologies in virCgroupGetPercpuStats
Peter Krempa [Mon, 14 Dec 2015 14:10:22 +0000 (15:10 +0100)]
cgroup: Prepare for sparse vCPU topologies in virCgroupGetPercpuStats

Pass a bitmap of enabled guest vCPUs to virCgroupGetPercpuStats so that
non-continuous vCPU topologies can be used.

9 years agoconf: Move and optimize disk target duplicity checking
Peter Krempa [Thu, 4 Feb 2016 13:24:53 +0000 (14:24 +0100)]
conf: Move and optimize disk target duplicity checking

Move the logic from virDomainDiskDefDstDuplicates into
virDomainDiskDefCheckDuplicateInfo so that we don't have to loop
multiple times through the array of disks. Since the original function
was called in qemuBuildDriveDevStr, it was actually called for every
single disk which was quite wasteful.

Additionally the target uniqueness check needed to be duplicated in
the disk hotplug case, since the disk was inserted into the domain
definition after the device string was formatted and thus
virDomainDiskDefDstDuplicates didn't do anything in that case.

9 years agotests: Integrate startup checks to qemuxml2argvtest
Peter Krempa [Thu, 4 Feb 2016 14:29:49 +0000 (15:29 +0100)]
tests: Integrate startup checks to qemuxml2argvtest

Some of the tests that are not a part of qemuBuildCommandLine were not
executed in the test suite. We can now reuse qemuProcessStartValidate to
integrate these tests.

9 years agoqemu: process: Extract pre-start checks into a function
Peter Krempa [Thu, 4 Feb 2016 14:25:29 +0000 (15:25 +0100)]
qemu: process: Extract pre-start checks into a function

When starting a qemu process there are certain checks done to ensure
that the configuration makes sense. Extract them into a separate
function so that they can be reused in the test code.

9 years agoqemu: process: Reorder operations on early VM startup
Peter Krempa [Thu, 4 Feb 2016 13:48:57 +0000 (14:48 +0100)]
qemu: process: Reorder operations on early VM startup

Retrieval of the driver capabilities as well as emulator capabilities
does not require the complete qemuProcessStop to be executed on
failure.

9 years agoqemu: hotplug: Check duplicate disk serial/wwn on hotplug too
Peter Krempa [Thu, 4 Feb 2016 12:39:15 +0000 (13:39 +0100)]
qemu: hotplug: Check duplicate disk serial/wwn on hotplug too

We do the check on VM start, but the user could still hotplug a disk
with a conflicting serial or WWN. Reuse the checker function to fix the
issue.

9 years agoconf: Extract code that checks disk serial/wwn conflict
Peter Krempa [Thu, 4 Feb 2016 11:17:50 +0000 (12:17 +0100)]
conf: Extract code that checks disk serial/wwn conflict

Put it into a separate function that can be called on two disk def
pointers.

9 years agoqemu: hotplug: Extract common code to qemuDomainAttachDeviceDiskLive
Peter Krempa [Wed, 3 Feb 2016 09:09:24 +0000 (10:09 +0100)]
qemu: hotplug: Extract common code to qemuDomainAttachDeviceDiskLive

Target uniqueness check was duplicated in all of the three workers
called from it. Extract it to the parent.

9 years agoqemu: hotplug: Use more common 'cleanup' label in qemuDomainAttachDeviceDiskLive
Peter Krempa [Tue, 2 Feb 2016 13:59:24 +0000 (14:59 +0100)]
qemu: hotplug: Use more common 'cleanup' label in qemuDomainAttachDeviceDiskLive

9 years agoqemu: hotplug: Break up if/else statement into switch
Peter Krempa [Tue, 2 Feb 2016 09:09:33 +0000 (10:09 +0100)]
qemu: hotplug: Break up if/else statement into switch

9 years agoqemu: hotplug: Remove unnecessary variable
Peter Krempa [Tue, 2 Feb 2016 08:59:55 +0000 (09:59 +0100)]
qemu: hotplug: Remove unnecessary variable

9 years agoqemu: hotplug: Use typecasted switch
Peter Krempa [Tue, 2 Feb 2016 08:43:36 +0000 (09:43 +0100)]
qemu: hotplug: Use typecasted switch

Remove the default case since all cases are covered.

9 years agoqemu: snapshot: Avoid infinite loop if vCPUs can't be resumed
Peter Krempa [Fri, 5 Feb 2016 15:57:58 +0000 (16:57 +0100)]
qemu: snapshot: Avoid infinite loop if vCPUs can't be resumed

In b3d2a42e I've refactored the code and moved the 'cleanup' label.
Unfortunately the code that was originally in the 'endjob' label and
wanted to jump to cleanup is now in the cleanup label. Remove the jump
and let the function finish.

9 years agoqemu: snapshot: Don't overwrite existing errors when thawing filesystems
Peter Krempa [Fri, 5 Feb 2016 15:55:09 +0000 (16:55 +0100)]
qemu: snapshot: Don't overwrite existing errors when thawing filesystems

If we are attempting to thaw the filesystems on error, the code would
overwrite the error code that caused the snapshot to fail with the error
of thawing the filesystem. Since the thawing function allows control of
error reporting behavior we can use this feature.

9 years agonodedev: stub nodeDeviceSysfsGetPCIRelatedDevCaps
Roman Bogorodskiy [Sat, 6 Feb 2016 23:05:53 +0000 (02:05 +0300)]
nodedev: stub nodeDeviceSysfsGetPCIRelatedDevCaps

Add a stub for nodeDeviceSysfsGetPCIRelatedDevCaps() for non-Linux
platforms. It allows nodedev driver to work on non-Linux platoforms
that, however, have HAL.

9 years agoutil: Fix virCgroupNewMachine ATTRIBUTE_NONNULL args
John Ferlan [Sat, 6 Feb 2016 11:45:46 +0000 (06:45 -0500)]
util: Fix virCgroupNewMachine ATTRIBUTE_NONNULL args

Commit id 'c3bd0019c0' removed arg3, but forgot to adjust the numbers
for NONNULL - caused build failure for coverity

9 years agobhyve: fix preprocessor indentation
Roman Bogorodskiy [Sat, 6 Feb 2016 02:26:51 +0000 (05:26 +0300)]
bhyve: fix preprocessor indentation

Syntax-check fails with:

cppi: src/bhyve/bhyve_driver.h: line 26: not properly indented
cppi: src/bhyve/bhyve_driver.h: line 27: not properly indented
maint.mk: incorrect preprocessor indentation

Fix by properly indenting '#include's.

Pushed as trivial.

9 years agobhyve: Fix the build
Michal Privoznik [Fri, 5 Feb 2016 21:36:42 +0000 (22:36 +0100)]
bhyve: Fix the build

After 1036ddadb276e we use bhyveDriverGetCapabilities from other
sources too, not only from bhyve_driver.c. However, the function
was static so not properly expose to other files. In order to
expose it, we need to move couple of #include-s too.
Then, there has been a copy paste error in
virBhyveProcessReconnect: s/privconn/data->driver/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotests: qemuargv2xml: separate from qemuxml2argv data
Cole Robinson [Wed, 13 Jan 2016 16:02:03 +0000 (11:02 -0500)]
tests: qemuargv2xml: separate from qemuxml2argv data

Most of the qemuargv2xml tests are parsing old style qemu command
lines (with -disk, -serial, etc), and it gets its input from
qemuxml2argv output.

But since we've raise the minimum supported qemu version to 0.12.0,
which supports -device, once that changes propagates through libvirt
the vast majority of qemuxml2argv output is _not_ going to be using
old style qemu options.

In preparation for this, switch qemuargv2xml to use its own copies
of input and output, so it's not tied to qemuxml2argv results.

This is just a straight copy of the current tests.

9 years agotests: Run test-wrap-argv with REGENERATE_OUTPUT
Cole Robinson [Wed, 13 Jan 2016 01:26:00 +0000 (20:26 -0500)]
tests: Run test-wrap-argv with REGENERATE_OUTPUT

To get properly wrapped output

9 years agorbd: Use %zu for uint64_t instead of casting to unsigned long long
Wido den Hollander [Sat, 30 Jan 2016 15:15:34 +0000 (16:15 +0100)]
rbd: Use %zu for uint64_t instead of casting to unsigned long long

This was only used in debugging messages and not in any real code.

Ceph/RBD uses uint64_t for sizes internally and they can be printed
with %zu without any need for casting.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Code styling cleanup
Wido den Hollander [Sat, 30 Jan 2016 15:15:33 +0000 (16:15 +0100)]
rbd: Code styling cleanup

Through the years the RBD storage pool code hasn't maintained the
same or correct coding standard which applies to libvirt.

This patch doesn't change any logic in the code, it only applies
the proper coding standards to the code where possible without
making large changes.

This way the code style used in this storage pool is consistent
throughout the whole file.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agovirSystemdGetMachineNameByPID: Initialize @reply
Michal Privoznik [Fri, 5 Feb 2016 16:17:45 +0000 (17:17 +0100)]
virSystemdGetMachineNameByPID: Initialize @reply

I've noticed that variable @reply is not initialized and if
something at the beginning of the function fails, e.g.
virDBusGetSystemBus(), the control jump straight to cleanup label
where dbus_message_unref() is then called over this uninitialized
variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirnetdevbandwidth: Compute quantum value
Michal Privoznik [Tue, 2 Feb 2016 11:48:44 +0000 (12:48 +0100)]
virnetdevbandwidth: Compute quantum value

I've noticed couple of warning in dmesg while debugging
something:

[ 9683.973754] HTB: quantum of class 10001 is big. Consider r2q change.
[ 9683.976460] HTB: quantum of class 10002 is big. Consider r2q change.

I've read the HTB documentation and linux kernel code to find out
what's wrong. Basically we need to pass another argument
"quantum" to our tc cmd line because the default computed by HTB
does not always work in which case the warning message is printed
out.

You can read more details here:

http://luxik.cdi.cz/~devik/qos/htb/manual/userg.htm#sharing

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Extract code for parsing thread resource scheduler info
Peter Krempa [Tue, 12 Jan 2016 12:11:56 +0000 (13:11 +0100)]
conf: Extract code for parsing thread resource scheduler info

As the scheduler info elements are represented orthogonally to how it
makes sense to actually store the information, the extracted code will
be later used when converting between XML and internal definitions.

9 years agoconf: Add helper to return a bitmap of active iothread ids
Peter Krempa [Wed, 13 Jan 2016 12:06:56 +0000 (13:06 +0100)]
conf: Add helper to return a bitmap of active iothread ids

9 years agoutil: bitmap: Introduce bitmap subtraction
Peter Krempa [Thu, 7 Jan 2016 14:45:39 +0000 (15:45 +0100)]
util: bitmap: Introduce bitmap subtraction

Performs binary subtraction of two bitmaps. Stores result in the first
operand.

9 years agosystemd: Modernize machine naming
Martin Kletzander [Mon, 1 Feb 2016 15:50:54 +0000 (16:50 +0100)]
systemd: Modernize machine naming

So, systemd-machined has this philosophy that machine names are like
hostnames and hence should follow the same rules.  But we always allowed
international characters in domain names.  Thus we need to modify the
machine name we are passing to systemd.

In order to change some machine names that we will be passing to systemd,
we also need to call TerminateMachine at the end of a lifetime of a
domain.  Even for domains that were started with older libvirt.  That
can be achieved thanks to virSystemdGetMachineNameByPID().  And because
we can change machine names, we can get rid of the inconsistent and
pointless escaping of domain names when creating machine names.

So this patch modifies the naming in the following way.  It creates the
name as <drivername>-<id>-<name> where invalid hostname characters are
stripped out of the name and if the resulting name is longer, it
truncates it to 64 characters.  That way we can start domains we
couldn't start before.  Well, at least on systemd.

To make it work all together, the machineName (which is needed only with
systemd) is saved in domain's private data.  That way the generation is
moved to the driver and we don't need to pass various unnecessary
arguments to cgroup functions.

The only thing this complicates a bit is the scope generation when
validating a cgroup where we must check both old and new naming, so a
slight modification was needed there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: add caps to virDomainSnapshotDefFormat
Joao Martins [Thu, 4 Feb 2016 22:55:05 +0000 (22:55 +0000)]
conf: add caps to virDomainSnapshotDefFormat

The virDomainSnapshotDefFormat calls into virDomainDefFormat,
so should be providing a non-NULL virCapsPtr instance. On the
qemu driver we change qemuDomainSnapshotWriteMetadata to also
include caps since it calls virDomainSnapshotDefFormat.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agoconf: add caps to virDomainObjFormat/SaveStatus
Daniel P. Berrange [Thu, 4 Feb 2016 12:32:45 +0000 (12:32 +0000)]
conf: add caps to virDomainObjFormat/SaveStatus

The virDomainObjFormat and virDomainSaveStatus methods
both call into virDomainDefFormat, so should be providing
a non-NULL virCapsPtr instance.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agobhyve: fix build
Roman Bogorodskiy [Fri, 5 Feb 2016 02:34:31 +0000 (05:34 +0300)]
bhyve: fix build

Fix build fail introduced as a side effect of commit d239a54.

Pushed under the build breaker rule.

9 years agoqemu migration: factor out setting migration option
Nikolay Shirokovskiy [Thu, 28 Jan 2016 07:04:27 +0000 (10:04 +0300)]
qemu migration: factor out setting migration option

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoFix build after recent patches
Peter Krempa [Thu, 4 Feb 2016 15:33:06 +0000 (16:33 +0100)]
Fix build after recent patches

Few build breaking mistakes in less-popular parts of our code.

9 years agological: Clarify pieces of lvs regex
John Ferlan [Tue, 2 Feb 2016 13:27:55 +0000 (08:27 -0500)]
logical: Clarify pieces of lvs regex

Rather than have a unwieldy regex string - split it up into its components
each having it's own #define and then combine in a different #define

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agolibxl: set net device prefix
Joao Martins [Wed, 3 Feb 2016 21:40:37 +0000 (21:40 +0000)]
libxl: set net device prefix

Use the newly added virCapabilitiesSetNetPrefix to set
the network prefix for the driver. This in return will
be use by NetDefFormat() and NetDefParseXML() routines
to free any interface name that start with the registered
prefix.

Acked-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agoconf: add caps to virDomainSaveConfig
Joao Martins [Wed, 3 Feb 2016 21:40:36 +0000 (21:40 +0000)]
conf: add caps to virDomainSaveConfig

virDomainSaveConfig calls virDomainDefFormat which was setting the caps
to NULL, thus keeping the old behaviour (i.e. not looking at
netprefix). This patch adds the virCapsPtr to the function and allows
the configuration to be saved and skipping interface names that were
registered with virCapabilitiesSetNetPrefix().

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agoconf: add caps to virDomainDefFormat*
Joao Martins [Wed, 3 Feb 2016 21:40:35 +0000 (21:40 +0000)]
conf: add caps to virDomainDefFormat*

And use the newly added caps->host.netprefix (if it exists) for
interface names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agoconf: add prefix in virDomainNetDefParseXML
Joao Martins [Wed, 3 Feb 2016 21:40:34 +0000 (21:40 +0000)]
conf: add prefix in virDomainNetDefParseXML

And use the newly added caps->host.netprefix for free interface
names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agoconf: add net device prefix to capabilities
Joao Martins [Wed, 3 Feb 2016 21:40:33 +0000 (21:40 +0000)]
conf: add net device prefix to capabilities

In the reverted commit d2e5538b1, the libxl driver was changed to copy
interface names autogenerated by libxl to the corresponding network def
in the domain's virDomainDef object. The copied name is freed when the
domain transitions to the shutoff state. But when migrating a domain,
the autogenerated name is included in the XML sent to the destination
host.  It is possible an interface with the same name already exists on
the destination host, causing migration to fail.

This patch defines a new capability for setting the network device
prefix that will be used in the driver. Valid prefixes are
VIR_NET_GENERATED_PREFIX or the one announced by the driver.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agovirsh: display if ZFS storage backend is enabled
Roman Bogorodskiy [Sun, 3 Jan 2016 02:25:35 +0000 (05:25 +0300)]
virsh: display if ZFS storage backend is enabled

Make 'virsh -V' list ZFS storage backend if it's enabled.

9 years agoconfigure: zfs: enable on Linux
Roman Bogorodskiy [Thu, 4 Feb 2016 00:13:10 +0000 (03:13 +0300)]
configure: zfs: enable on Linux

ZFS-on-Linux implementation of ZFS starting with version 0.6.4
contains all the features we use. Additionally, as we support
'volmode' option handling that's not available on ZoL but is
available on FreeBSD, there is no need to block ZFS storage driver
on Linux anymore.

So un-mark zfs storage driver as FreeBSD-only.

9 years agostorage: zfs: flexible use of 'volmode' option
Roman Bogorodskiy [Thu, 4 Feb 2016 00:03:12 +0000 (03:03 +0300)]
storage: zfs: flexible use of 'volmode' option

There are slight differences in various ZFS implementations.
Specifically, ZFS on FreeBSD requires to set value of 'volmode'
option to 'dev' to expose volumes as raw disk device (that's what
we need) rather than geom provides, for example.

With ZFS on Linux, however, such option is not available and
volumes exposed like we need by default.

To make our implementation more flexible, only pass 'volmode'
when it's supported. Support is checked by parsing usage
information of the 'zfs get' command.

9 years agoutil: Export remoteSerializeTypedParameters internally via util
Erik Skultety [Tue, 2 Feb 2016 13:13:15 +0000 (14:13 +0100)]
util: Export remoteSerializeTypedParameters internally via util

Same as for deserializer, this method might get handy for admin one day.
The major reason for this patch is to stay consistent with idea, i.e.
when deserializer can be shared, why not serializer as well. The only
problem to be solved was that the daemon side serializer uses a code
snippet which handles sparse arrays returned by some APIs as well as
removes any string parameters that can't be returned to older clients.
This patch makes of the new virTypedParameterRemote datatype introduced
by one of the pvious patches.

9 years agoutil: Export remoteFreeTypedParameters internally via util
Erik Skultety [Tue, 2 Feb 2016 12:19:35 +0000 (13:19 +0100)]
util: Export remoteFreeTypedParameters internally via util

Since the method is static to remote_driver, it can't even be used by our
daemon. Other than that, it would be useful to be able to use it with admin as
well. This patch uses the new virTypedParameterRemote datatype introduced in
one of previous patches.

9 years agoutil: Export remoteDeserializeTypedParameters internally via util
Erik Skultety [Thu, 28 Jan 2016 16:27:42 +0000 (17:27 +0100)]
util: Export remoteDeserializeTypedParameters internally via util

Currently, the deserializer is hardcoded into remote_driver which makes
it impossible for admin to use it. One way to achieve a shared implementation
(besides moving the code to another module) would be pass @ret_params_val as a
void pointer as opposed to the remote_typed_param pointer and add a new extra
argument specifying which of those two protocols is being used and typecast
the pointer at the function entry. An example from remote_protocol:

struct remote_typed_param_value {
        int type;
        union {
                int i;
                u_int ui;
                int64_t l;
                uint64_t ul;
                double d;
                int b;
                remote_nonnull_string s;
        } remote_typed_param_value_u;
};
typedef struct remote_typed_param_value remote_typed_param_value;

struct remote_typed_param {
        remote_nonnull_string field;
        remote_typed_param_value value;
};

That would leave us with a bunch of if-then-elses that needed to be used across
the method. This patch takes the other approach using the new datatype
introduced in one of earlier commits.

9 years agoutil: Introduce virTypedParameterRemote datatype
Erik Skultety [Tue, 2 Feb 2016 14:33:30 +0000 (15:33 +0100)]
util: Introduce virTypedParameterRemote datatype

Both admin and remote protocols define their own types
(remote_typed_param vs admin_typed_param). Because of the naming convention,
admin typed params wouldn't be able to reuse the serialization/deserialization
methods, which are tailored for use by remote protocol, even if those method
were exported properly. In that case, introduce a new internal data type
structurally copying both admin and remote protocols which, eventually, would
allow serializer and deserializer to be used in a more generic way.

9 years agoqemu: qemuDomainRename and virDomainObjListNumOfDomains ABBA deadlock fix
Nikolay Shirokovskiy [Mon, 1 Feb 2016 09:33:45 +0000 (12:33 +0300)]
qemu: qemuDomainRename and virDomainObjListNumOfDomains ABBA deadlock fix

A pretty nasty deadlock occurs while trying to rename a VM in parallel
with virDomainObjListNumOfDomains.
The short description of the problem is as follows:

Thread #1:

qemuDomainRename:
    ------> aquires domain lock by qemuDomObjFromDomain
       ---------> waits for domain list lock in any of the listed functions:
          - virDomainObjListFindByName
          - virDomainObjListRenameAddNew
          - virDomainObjListRenameRemove

Thread #2:

virDomainObjListNumOfDomains:
    ------> aquires domain list lock
       ---------> waits for domain lock in virDomainObjListCount

Introduce generic virDomainObjListRename function for renaming domains.
It aquires list lock in right order to avoid deadlock. Callback is used
to make driver specific domain updates.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosystemd: Add virSystemdGetMachineNameByPID
Martin Kletzander [Tue, 2 Feb 2016 18:45:55 +0000 (19:45 +0100)]
systemd: Add virSystemdGetMachineNameByPID

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRevert "systemd: Escape only needed characters for machined"
Martin Kletzander [Mon, 1 Feb 2016 15:28:29 +0000 (16:28 +0100)]
Revert "systemd: Escape only needed characters for machined"

This reverts commit 0e0149ce91d84f40b98acf4c4bb0da6e29b9c15c.

That commit was added to comply with systemd rules that were changed in
the meantime, so this patch is pointless.

9 years agoSimplify virDomainParseMemory
Ján Tomko [Fri, 29 Jan 2016 17:00:13 +0000 (18:00 +0100)]
Simplify virDomainParseMemory

Do not store the return value of virDomainParseScaledValue,
it was overwritten anyway.

Delete the cleanup label, there is nothing to clean up.

9 years agoconf: Split out logic to determine whether cpupin was provided
Peter Krempa [Mon, 4 Jan 2016 18:39:02 +0000 (19:39 +0100)]
conf: Split out logic to determine whether cpupin was provided

9 years agoqemu: domain: Prepare qemuDomainDetectVcpuPids for reuse
Peter Krempa [Thu, 17 Dec 2015 15:04:23 +0000 (16:04 +0100)]
qemu: domain: Prepare qemuDomainDetectVcpuPids for reuse

Free the old vcpupids array in case when this function is called again
during the run of the VM. It will be later reused in the vCPU hotplug
code. The function now returns the number of detected VCPUs.

9 years agoqemu: Move and rename qemuProcessDetectVcpuPIDs to qemuDomainDetectVcpuPids
Peter Krempa [Tue, 15 Dec 2015 13:45:33 +0000 (14:45 +0100)]
qemu: Move and rename qemuProcessDetectVcpuPIDs to qemuDomainDetectVcpuPids

Future patches will tweak and reuse the function in different places so
move it separately first.

9 years agoqemu: cpu hotplug: Set vcpu state directly in the new structure
Peter Krempa [Thu, 17 Dec 2015 12:19:54 +0000 (13:19 +0100)]
qemu: cpu hotplug: Set vcpu state directly in the new structure

Avoid using virDomainDefSetVcpus when we can set it directly in the
structure.

9 years agoconf: Add helper to retrieve bitmap of active vcpus for a definition
Peter Krempa [Mon, 7 Dec 2015 05:36:37 +0000 (06:36 +0100)]
conf: Add helper to retrieve bitmap of active vcpus for a definition

In some cases it may be better to have a bitmap representing state of
individual vcpus rather than iterating the definition. The new helper
creates a bitmap representing the state from the domain definition.

9 years agocgroup: Clean up virCgroupGetPercpuStats
Peter Krempa [Mon, 7 Dec 2015 06:39:34 +0000 (07:39 +0100)]
cgroup: Clean up virCgroupGetPercpuStats

Use 'ret' for return variable name, clarify use of 'param_idx' and avoid
unnecessary 'success' label. No functional changes. Also document the
function.

9 years agoqemu: Don't crash when create fails early
Martin Kletzander [Tue, 2 Feb 2016 21:08:59 +0000 (22:08 +0100)]
qemu: Don't crash when create fails early

Since commit 714080791778e3dfbd484ccb3953bffd820b8ba9 we are generating
socket path later than before -- when starting a domain.  That makes one
particular inconsistent state of a chardev, which was not possible
before, currently valid.  However, SELinux security driver forgot to
guard the main restoring function by a check for NULL-paths.  So make it
no-op for NULL paths, as in the DAC driver.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agocfg.mk: Adjust sc_prohibit_int_ijk to support 'exempt from syntax-check'
Erik Skultety [Thu, 28 Jan 2016 15:46:32 +0000 (16:46 +0100)]
cfg.mk: Adjust sc_prohibit_int_ijk to support 'exempt from syntax-check'

There might be cases, like with typed params, where triggering this check isn't
desirable. But including the whole module in the exception regex is not always
to right way of doing things. By adding an option to manually disable this check
on a specific occurrence, the module itself will still be checked against the
rule.

9 years agoqemuDomainResume: allow to resume domain with guest panicked
Dmitry Andreev [Sat, 23 Jan 2016 16:08:45 +0000 (19:08 +0300)]
qemuDomainResume: allow to resume domain with guest panicked

In case of guest panicked, preserved crashed domain has stopped CPUs.
It's not possible to use tools like WinDbg for the problem investigation
until we start CPUs back.

9 years agoqemu: return -1 on error paths in qemuDomainSaveImageStartVM
Nikolay Shirokovskiy [Mon, 1 Feb 2016 13:28:40 +0000 (16:28 +0300)]
qemu: return -1 on error paths in qemuDomainSaveImageStartVM

Error paths after sending the event that domain is started written as if ret = -1
which is set at the beginning of the function. It's common idioma to keep 'ret'
equal to -1 until the end of function where it is set to 0. But here we use ret
to keep result of restore operation too and thus breaks the idioma and its users :)

Let's use different variable to hold restore result.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agological: Clean up allocation when building regex on the fly
John Ferlan [Mon, 1 Feb 2016 15:26:02 +0000 (10:26 -0500)]
logical: Clean up allocation when building regex on the fly

Rather than a loop reallocating space to build the regex, just allocate
it once up front, then if there's more than 1 nextent, append a comma and
another regex_unit string.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agological: Use 'stripes' value for mirror/raid segtype
John Ferlan [Mon, 1 Feb 2016 14:59:44 +0000 (09:59 -0500)]
logical: Use 'stripes' value for mirror/raid segtype

The 'stripes' value is described as the "Number of stripes or mirrors in
a logical volume". So add "mirror" and anything that starts with "raid"
to the list of segtypes that can have an 'nextents' value greater than one.
Use of raid segtypes (raid1, raid4, raid5*, raid6*, and raid10) is favored
over mirror in more recent lvm code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agological: Use VIR_APPEND_ELEMENT instead of VIR_REALLOC_N
John Ferlan [Mon, 1 Feb 2016 14:39:00 +0000 (09:39 -0500)]
logical: Use VIR_APPEND_ELEMENT instead of VIR_REALLOC_N

Rather than preallocating a set number of elements, then walking through
the extents and adjusting the specific element in place, use the APPEND
macros to handle that chore.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoinclude: Handle case when builddir == srcdir
Michal Privoznik [Mon, 1 Feb 2016 11:24:58 +0000 (12:24 +0100)]
include: Handle case when builddir == srcdir

In my previous commit a70f3b1c779120129 I've tried to fix case
when building from VPATH and a file wasn't being installed.
However, my fix broke non-VPATH build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotests: avoid realpath in test-lib.sh
Eric Blake [Mon, 1 Feb 2016 18:43:32 +0000 (11:43 -0700)]
tests: avoid realpath in test-lib.sh

Ever since commit ace4aecd, running 'make check' on RHEL 6 produces:

./test-lib.sh: line 21: realpath: command not found

for every shell script test, because 'realpath' was not part of
coreutils back then.

* tests/test-lib.sh (_scriptdir): Compute with only portable shell.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agovirsh: improve waiting for block job readiness
Michael Chapman [Wed, 27 Jan 2016 02:24:54 +0000 (13:24 +1100)]
virsh: improve waiting for block job readiness

After a block job hits 100%, we only need to apply a timeout waiting for
a block job event if exactly one of the BLOCK_JOB or BLOCK_JOB_2
callbacks were able to be registered.

If neither callback could be registered, there's clearly no need for a
timeout.

If both callbacks were registered, then we're guaranteed to eventually
get one of the events. The path being used by virsh must be exactly the
source path or target device in the domain's disk definition, and these
are the respective strings sent back in these two events.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agovirsh: ensure SIGINT action is reset on all errors
Michael Chapman [Wed, 27 Jan 2016 02:24:53 +0000 (13:24 +1100)]
virsh: ensure SIGINT action is reset on all errors

If virTimeMillisNow() fails, the SIGINT action must be reset back to
its previous state.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agovirsh: be consistent with style of loop exit
Michael Chapman [Wed, 27 Jan 2016 02:24:52 +0000 (13:24 +1100)]
virsh: be consistent with style of loop exit

When waiting for a block job, the various statuses (COMPLETED, READY,
CANCELED, etc.) should all be treated consistently by having the loop be
exited with "break". Use "goto cleanup" for the error cases only, when
no block job status is available.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agovirsh: avoid unnecessary progress updates
Michael Chapman [Wed, 27 Jan 2016 02:24:51 +0000 (13:24 +1100)]
virsh: avoid unnecessary progress updates

There is no need to call virshPrintJobProgress() unless the block job's
cur or end cursors have changed since the last iteration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agoqemu: Mark some functions as static
Cole Robinson [Thu, 28 Jan 2016 20:05:54 +0000 (15:05 -0500)]
qemu: Mark some functions as static

9 years agofdstream: Realign
Michal Privoznik [Tue, 8 Dec 2015 10:00:34 +0000 (11:00 +0100)]
fdstream: Realign

Some lines in this file are misaligned which fires up my OCD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Align dump options for watchdog and on_crash events
Boris Fiuczynski [Wed, 20 Jan 2016 12:13:45 +0000 (13:13 +0100)]
qemu: Align dump options for watchdog and on_crash events

Having on_crash set to either coredump-destroy or coredump-restart
creates core dumps with option memory-only in the directory specified
by auto_dump_path. When a watchdog is triggered with the action dump
the core dump is also placed into the directory specified by auto_dump_path
but is created without the option memory-only.

This patch sets the option memory-only also for core dumps created by the
watchdog event.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
9 years agoincludes: Install libvirt-common.h
Michal Privoznik [Sat, 30 Jan 2016 10:55:45 +0000 (11:55 +0100)]
includes: Install libvirt-common.h

The libvirt-common.h is build time generated file from .in.
Obviously, it's generated into builddir and not srcdir. Problem
is, the list of header files to install, virinc_HEADERS contains
only $(srcdir)/*.h and this misses libvirt-common.h. This problem
is pretty obvious when doing a VPATH build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agological: Create helper virStorageBackendLogicalParseVolExtents
John Ferlan [Fri, 22 Jan 2016 17:02:18 +0000 (12:02 -0500)]
logical: Create helper virStorageBackendLogicalParseVolExtents

Create a helper routine in order to parse any extents information
including the extent size, length, and the device string contained
within the generated 'lvs' output string.

A future patch would then be able to avoid the code more cleanly

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agorbd: Open in Read-Only mode when refreshing a volume
Wido den Hollander [Thu, 28 Jan 2016 10:20:23 +0000 (11:20 +0100)]
rbd: Open in Read-Only mode when refreshing a volume

By opening a RBD volume in Read-Only we do not register a
watcher on the header object inside the Ceph cluster.

Refreshing a volume only calls rbd_stat() which is a operation
which does not write to a RBD image.

This allows us to use a cephx user which has no write
permissions if we would want to use the libvirt storage pool
for informational purposes only.

It also saves us a write into the Ceph cluster which should
speed up refreshing a RBD pool.

rbd_open_read_only() is available in all librbd versions which
also support rbd_open().

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Implement buildVolFrom using RBD cloning
Wido den Hollander [Wed, 27 Jan 2016 10:20:09 +0000 (11:20 +0100)]
rbd: Implement buildVolFrom using RBD cloning

RBD supports cloning by creating a snapshot, protecting it and create
a child image based on that snapshot afterwards.

The RBD storage driver will try to find a snapshot with zero deltas between
the current state of the original volume and the snapshot.

If such a snapshot is found a clone/child image will be created using
the rbd_clone2() function from librbd.

rbd_clone2() is available in librbd since Ceph version Dumpling (0.67) which
dates back to August 2013.

It will use the same features, strip size and stripe count as the parent image.

This implementation will only create a single snapshot on the parent image if
never changes. This reduces the amount of snapshots created for that RBD image
which benefits the performance of the Ceph cluster.

During build the decision will be made to use either rbd_diff_iterate() or
rbd_diff_iterate2().

The latter is faster, but only available on Ceph versions after 0.94 (Hammer).

Cloning is only supported if RBD format 2 is used. All images created by libvirt
are already format 2.

If a RBD format 1 image is used as the original volume the backend will report
a VIR_ERR_OPERATION_UNSUPPORTED error.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Add support for wiping RBD volumes using TRIM.
Wido den Hollander [Wed, 27 Jan 2016 10:20:08 +0000 (11:20 +0100)]
rbd: Add support for wiping RBD volumes using TRIM.

Using VIR_STORAGE_VOL_WIPE_ALG_TRIM a RBD volume can be trimmed down
to 0 bytes using rbd_discard()

Effectively all the data on the volume will be lost/gone, but the volume
remains available for use afterwards.

Starting at offset 0 the storage pool will call rbd_discard() in stripe
size * count increments which is usually 4MB. Stripe size being 4MB and
count 1.

rbd_discard() is available since Ceph version Dumpling (0.67) which dates
back to August 2013.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agostorage: Add TRIM algorithm to storage volume API
Wido den Hollander [Wed, 27 Jan 2016 10:20:07 +0000 (11:20 +0100)]
storage: Add TRIM algorithm to storage volume API

This new algorithm adds support for wiping volumes using TRIM.

It does not overwrite all the data in a volume, but it tells the
backing storage pool/driver that all bytes in a volume can be
discarded.

It depends on the backing storage pool how this is handled.

A SCSI backend might send UNMAP commands to remove all data present
on a LUN.

A Ceph backend might use rbd_discard() to instruct the Ceph cluster
that all data on that RBD volume can be discarded.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Add support for wiping RBD volumes
Wido den Hollander [Wed, 27 Jan 2016 10:20:06 +0000 (11:20 +0100)]
rbd: Add support for wiping RBD volumes

When wiping the RBD image will be filled with zeros started
at offset 0 and until the end of the volume.

This will result in the RBD volume growing to it's full allocation
on the Ceph cluster. All data on the volume will be overwritten
however, making it unavailable.

It does NOT take any RBD snapshots into account. The original data
might still be in a snapshot of that RBD volume.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agostorage: Adjust fix virStorageBackendVolWipeLocal switch
Wido den Hollander [Fri, 29 Jan 2016 12:35:35 +0000 (07:35 -0500)]
storage: Adjust fix virStorageBackendVolWipeLocal switch

Use the cast of (virStorageVolWipeAlgorithm) adding the missing case:'s
(VIR_STORAGE_VOL_WIPE_ALG_ZERO and VIR_STORAGE_VOL_WIPE_ALG_LAST).

Additionally, the old code would also still run the SCRUB command on
default since it didn't go to cleanup when a invalid flag was supplied.
We now go to cleanup and exit if a invalid flag would be provided.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agological: Fix comment examples for virStorageBackendLogicalFindLVs
John Ferlan [Fri, 22 Jan 2016 16:01:05 +0000 (11:01 -0500)]
logical: Fix comment examples for virStorageBackendLogicalFindLVs

When commit id '82c1740a' made changes to the output format (changing from
using a ',' separator to '#'), the examples in the lvs output from the
comments weren't changed.

Additionally, the two new fields added ('segtype' and 'stripes') were
not included in the output, leaving it well confusing.

This patch fixes the sample output, adds a 'striped' example, and makes
other comment related adjustments for long line and spacing between followup
'NB' remarks (while I'm there).

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agopci: Use bool return type for some virPCIDeviceGet*() functions
Andrea Bolognani [Thu, 28 Jan 2016 08:21:43 +0000 (09:21 +0100)]
pci: Use bool return type for some virPCIDeviceGet*() functions

The affected functions are:

  virPCIDeviceGetManaged()
  virPCIDeviceGetUnbindFromStub()
  virPCIDeviceGetRemoveSlot()
  virPCIDeviceGetReprobe()

Change their return type from unsigned int to bool: the corresponding
members in struct _virPCIDevice are defined as bool, and even the
corresponding virPCIDeviceSet*() functions take a bool value as input
so there's no point in these functions having unsigned int as return
type.

Suggested-by: John Ferlan <jferlan@redhat.com>