]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoClean up usage of 'ret' variable
Ján Tomko [Thu, 28 Jan 2016 16:44:33 +0000 (17:44 +0100)]
Clean up usage of 'ret' variable

Do not store the return value of called functions in the same variable
as the (future) return value of the current function.

This makes tracking the origin of the value easier and reduces
the chance of introducing a new point of exit without resetting
the return value back to -1.

9 years agoProhibit verbose strcat
Ján Tomko [Wed, 3 Feb 2016 08:48:40 +0000 (09:48 +0100)]
Prohibit verbose strcat

Using strcat directly is more readable than passing strlen
of the copied string to strncat.

9 years agovbox: remove more extra spaces
Ján Tomko [Tue, 9 Feb 2016 11:38:36 +0000 (12:38 +0100)]
vbox: remove more extra spaces

9 years agovbox: remove extra spaces from function headers
Ján Tomko [Tue, 9 Feb 2016 11:34:13 +0000 (12:34 +0100)]
vbox: remove extra spaces from function headers

Also fix the curly brace to pass sytnax-check.

9 years agovbox: remove extra spaces from assignments
Ján Tomko [Tue, 9 Feb 2016 11:29:59 +0000 (12:29 +0100)]
vbox: remove extra spaces from assignments

9 years agovbox: remove extra spaces from variable initializations
Ján Tomko [Tue, 9 Feb 2016 11:26:26 +0000 (12:26 +0100)]
vbox: remove extra spaces from variable initializations

9 years agovbox: remove extra spaces from macro definitions
Ján Tomko [Tue, 9 Feb 2016 11:05:02 +0000 (12:05 +0100)]
vbox: remove extra spaces from macro definitions

9 years agoqemu: Connect to guest agent iff needed
Michal Privoznik [Fri, 8 Jan 2016 16:03:48 +0000 (17:03 +0100)]
qemu: Connect to guest agent iff needed

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

Since we already have virtio channel events, we know when guest
agent within guest has (dis-)connected. Instead of us blindly
connecting to a socket that no one is listening to, we can just
follow what qemu-ga does. This has a nice benefit that we don't
need to 'guest-ping' the agent just to timeout and find out
nobody is listening.

The way that this commit is implemented:
- don't connect in qemuProcessLaunch directly, defer that to event
  callback (which already follows the agent) -
  processSerialChangedEvent
- after migration is settled, before we resume vCPUs, ask qemu
  whether somebody is listening on the socket and if so, connect
  to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Split the command parsing routines into own module
John Ferlan [Wed, 10 Feb 2016 12:33:47 +0000 (07:33 -0500)]
qemu: Split the command parsing routines into own module

Extract out the qemuParseCommandLine{String|Pid} into their own
separate module - taking with it all the various static functions.

Causes a ripple effect with a few other modules to include the
new qemu_parse_command.h.

Narrowed down the list of #include's in the split out module to
those that are necessary for build.

9 years agoqemu: Check return status for virDomainGraphicsListenSetAddress
John Ferlan [Tue, 9 Feb 2016 11:24:33 +0000 (06:24 -0500)]
qemu: Check return status for virDomainGraphicsListenSetAddress

Recent refactors in the vbox code to check the return status for the
function tipped Coverity's scales of justice for any functions that
do not check status - such as this one.

While I'm at it, since the call is essentially the same other than
whether starting from val or val+1 when val[0] = '[', just adjust
the val pointer by one and have one call instead of two.

Additionally, the call to virDomainGraphicsListenGetAddress is redundant
since it checking that the address field got filled.  It's a leftover
from the strndup -> ListenSetAddress conversion (commit id 'ef79fb5b5')

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuParseCommandLineVnc
John Ferlan [Tue, 9 Feb 2016 11:36:17 +0000 (06:36 -0500)]
qemu: Introduce qemuParseCommandLineVnc

Refactor qemuParseCommandLine to pull out the "-vnc" argument parsing
into its own helper function.  Modify the code to use "cleanup" instead
of "error" and use the standard return processing to indicate success
or failure by using ret

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoRevert "tests: Don't link mock libraries against libvirt and gnulib"
Andrea Bolognani [Wed, 10 Feb 2016 17:23:10 +0000 (18:23 +0100)]
Revert "tests: Don't link mock libraries against libvirt and gnulib"

This reverts commit 6aa90452aa63cb1e1ffa84ff5f93f5873bf810a0.

Turns out that not linking against libvirt and gnulib is okay for
regular Linux (and FreeBSD) builds, but makes mingw very unhappy.

  .../virnetserverclientmock_la-virnetserverclientmock.o:
    In function `virNetSocketGetSELinuxContext':
    .../virnetserverclientmock.c:61: undefined reference to `rpl_strdup'
  .../libvirportallocatormock_la-virportallocatortest.o:
    In function `init_syms':
    .../virportallocatortest.c:61: undefined reference to `virFileClose'

9 years agotests: Don't link mock libraries against libvirt and gnulib
Andrea Bolognani [Wed, 10 Feb 2016 15:51:51 +0000 (16:51 +0100)]
tests: Don't link mock libraries against libvirt and gnulib

Mock libraries are used with LD_PRELOAD from test binaries that
are already linked against those libraries, so they will be able
to resolve the symbols anyway.

9 years agoxenconfig: Properly check retval of virDomainGraphicsListenSetAddress
Michal Privoznik [Wed, 10 Feb 2016 08:34:59 +0000 (09:34 +0100)]
xenconfig: Properly check retval of virDomainGraphicsListenSetAddress

The function, like others in our code, returns zero on success
and a negative value on error. However, there are two places in
xenconfig source code where we check for non-zero value. While
the function can't currently return a positive value, those
checks look okay, but does not really follow our style.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibxl: keepalive messages support
Joao Martins [Fri, 5 Feb 2016 20:45:03 +0000 (20:45 +0000)]
libxl: keepalive messages support

This patch introduces keep alive messages support for P2P migration
and it adds two new configuration entries namely 'keepalive_interval'
'keepalive_count' to control it. Behavior of these entries is the
same as qemu driver thus the description is copied from there
with just a few simplifications.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agolibxl: add p2p migration
Joao Martins [Fri, 5 Feb 2016 20:45:02 +0000 (20:45 +0000)]
libxl: add p2p migration

Introduce support for VIR_MIGRATE_PEER2PEER in libvirt migration.
Most of the changes occur at the source and no modifications at
the receiver.

In P2P mode there is only the Perform phase so we must handle the
connection with the destination and actually perform the
migration. libxlDomainPerformP2P implements the connection to the
destination and libxlDoMigrateP2P implements the actual migration
logic with virConnectPtr. In this function we take care of doing
all phases of migration in the destination similar to
virDomainMigrateVersion3Full. We appropriately save the last
error reported in each of the phases to provide proper reporting.
We don't yet support VIR_MIGRATE_TUNNELED and we always use V3
with extensible params, thus it also makes the implementation
simpler.

It is worth noting that the receiver didn't have any changes, and
since it's still the v3 sequence thus it is possible to migrate
from a P2P to non-P2P host.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agotests: qemu: More aarch64 virtio and pci tests
Cole Robinson [Wed, 27 Jan 2016 22:47:14 +0000 (17:47 -0500)]
tests: qemu: More aarch64 virtio and pci tests

Clarify the point of some of the test cases by renaming them. Add more
xml2xml tests.

9 years agotests: qemuxml2xml: assign device addresses
Cole Robinson [Wed, 27 Jan 2016 21:03:52 +0000 (16:03 -0500)]
tests: qemuxml2xml: assign device addresses

We use the PreFormat callback for this. Many test cases need to be extended
to pass in proper qemuCaps flags so AssignAddresses doesn't throw errors.

One test case (pcie-root-port-too-many) is dropped, since it was meant
only for checking an error condition in qemuxml2argv, and one we add in
AssignAddresses it errors here too.

Long term I think AssignAddresses should be handled in qemu's PostParse
callback, but that's not entirely straightforward. Handling it here
means we can get the test suite churn over with.

9 years agotests: utils: Add PreFormat callback for CompareXML2XML helper
Cole Robinson [Wed, 27 Jan 2016 20:55:01 +0000 (15:55 -0500)]
tests: utils: Add PreFormat callback for CompareXML2XML helper

This allows individual driver tests to hook in their own code before
the def is formatted and compared.

We will eventually use this in the qemuxml2xml

9 years agovirStringListLength: Ensure const correctness
Michal Privoznik [Tue, 9 Feb 2016 17:18:49 +0000 (18:18 +0100)]
virStringListLength: Ensure const correctness

The virStringListLength function does not ever modify the passed
string list. It merely counts the items in it. Make sure that we
reflect this bit in the function header.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(crobinso: fix up spacing and squash in sheepdog bit suggested
 by Andrea)

9 years agotests: qemuxml2xml: specify qemuCaps in test cases
Cole Robinson [Wed, 27 Jan 2016 21:19:40 +0000 (16:19 -0500)]
tests: qemuxml2xml: specify qemuCaps in test cases

Similar to how we do it for qemuxml2argvtest. This will be used in future
patches.

9 years agotests: Unconditionally enable QEMU_CAPS_DEVICE
Cole Robinson [Wed, 13 Jan 2016 00:26:40 +0000 (19:26 -0500)]
tests: Unconditionally enable QEMU_CAPS_DEVICE

QEMU_CAPS_DEVICE is always enabled for qemu binaries we support.
Sync qemuxml2* to match, and regenerate all test output.

9 years agotests: qemuxml2argv: remove some QEMU_CAPS_DEVICE problem cases
Cole Robinson [Wed, 13 Jan 2016 01:41:49 +0000 (20:41 -0500)]
tests: qemuxml2argv: remove some QEMU_CAPS_DEVICE problem cases

When we unconditionally enable QEMU_CAPS_DEVICE, these tests need
some massaging, so do it ahead of time to not mix it in with the
big test refresh.

- minimal-s390 is not a real world working config, so drop it
- disk-usb was testing for an old code path that will be removed.
  instead use it to test lack of USB disk support, and rename it
  to disk-usb-nosupport. Switch xml2xml to use disk-usb-device for
  input.
- cputune-numatune was needlessly using q35, switch it to an older
  machine type

9 years agovirDomainFormatSchedDef: Initialize @priority
Michal Privoznik [Mon, 8 Feb 2016 13:12:56 +0000 (14:12 +0100)]
virDomainFormatSchedDef: Initialize @priority

Older gcc fails to see that the variable is set iff @hasPriority
== true in which case the former is set a value. Initialize the
value while declaring it to make the compiler shut up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: Get rid of virStringListLen()
Martin Kletzander [Tue, 9 Feb 2016 15:01:33 +0000 (16:01 +0100)]
util: Get rid of virStringListLen()

It does exactly the same thing as virStringListLength() and it's used in
one place only.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agotests: qemuxml2xml: Always use different output file
Cole Robinson [Wed, 13 Jan 2016 15:43:27 +0000 (10:43 -0500)]
tests: qemuxml2xml: Always use different output file

Most qemuxml2xml tests expect that the input XML is unchanged after
parsing. This is unlike 99% of new qemu configs in the wild, which after
initial parsing end up with stable PCI device addresses. The xml2xml bit
doesn't currently hit that code path though, so most XML testing indeed
does not change.

Future patches will add that PCI address bits, which means most test cases
will have different output. So let's do away with the hardcoded same vs
different test split, and always track a separate output file. Tests can
still have same input and output, it just necessitates 2 separate XML files.

9 years agoFix '-pie' build with clang
Martin Kletzander [Tue, 9 Feb 2016 11:33:29 +0000 (12:33 +0100)]
Fix '-pie' build with clang

Commit 97e70a593589e8f0432a748b4b93c3cdc18b9e5a added the option -pie to
CFLAGS and LDFLAGS, however '-pie' is just a linker option.  That
wouldn't be a problem.  However, clang is checking for that and outputs
an error or unused argument:

error: argument unused during compilation: '-pie'

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoleaseshelper: swap two parameters of virLeaseNew
Ján Tomko [Tue, 9 Feb 2016 12:13:51 +0000 (13:13 +0100)]
leaseshelper: swap two parameters of virLeaseNew

My commit e11aa74 messed up the parameter order.

Reported by John Ferlan.

9 years agovboxDumpDisplay: realign variable initializations
Ján Tomko [Tue, 9 Feb 2016 09:11:56 +0000 (10:11 +0100)]
vboxDumpDisplay: realign variable initializations

Remove the extra spaces, do not align them on '='.

9 years agovboxDumpDisplay: remove suspicious strlen
Ján Tomko [Fri, 5 Feb 2016 16:46:07 +0000 (17:46 +0100)]
vboxDumpDisplay: remove suspicious strlen

The return type of strlen is 'size_t', which is unsigned and therefore
never less than zero.

Use STREQ to make the check obvious.

9 years agovboxDumpDisplay: reuse the keyUtf16 variable
Ján Tomko [Fri, 5 Feb 2016 16:43:00 +0000 (17:43 +0100)]
vboxDumpDisplay: reuse the keyUtf16 variable

We free the key right after calling the API.

Reuse a single variable to remove the typo.

9 years agovboxDumpDisplay: use VIR_APPEND_ELEMENT
Ján Tomko [Fri, 5 Feb 2016 16:40:51 +0000 (17:40 +0100)]
vboxDumpDisplay: use VIR_APPEND_ELEMENT

Instead of open-coding it.

9 years agovboxDumpDisplay: check return of virDomainGraphicsListenSetAddress
Ján Tomko [Fri, 5 Feb 2016 16:33:52 +0000 (17:33 +0100)]
vboxDumpDisplay: check return of virDomainGraphicsListenSetAddress

Error out if the allocation failed.

9 years agovboxDumpDisplay: clean up VIR_STRDUP usage
Ján Tomko [Fri, 5 Feb 2016 16:09:05 +0000 (17:09 +0100)]
vboxDumpDisplay: clean up VIR_STRDUP usage

Two VIR_STRDUP calls are redundant - just steal the string
converted by VBOX_UTF16_TO_UTF8.

Report an error when the third one fails.

9 years agovboxDumpDisplay: fill out the graphics structure earlier
Ján Tomko [Fri, 5 Feb 2016 16:01:05 +0000 (17:01 +0100)]
vboxDumpDisplay: fill out the graphics structure earlier

Remove the need to track what type of graphics were present
by temporary variables.

9 years agovboxDumpDisplay: allocate the graphics structure upfront
Ján Tomko [Fri, 5 Feb 2016 15:42:26 +0000 (16:42 +0100)]
vboxDumpDisplay: allocate the graphics structure upfront

Allocate it as soon as we know we will need it.

Add it to def->ngraphics if it's allocated, removing the need
to use the addDesktop and totalPresent variables to track this.

9 years agovboxDumpDisplay: split out def->graphics allocation
Ján Tomko [Fri, 5 Feb 2016 15:25:25 +0000 (16:25 +0100)]
vboxDumpDisplay: split out def->graphics allocation

Separate allocation of the def->graphics array from the allocation
and initialization of its first element.

Note that the only possible values of totalPresent at this point
are 0 or 1, because it equals to guiPresent + sdlPresent.

9 years agovboxDumpDisplay: remove extra virReportOOMError
Ján Tomko [Fri, 5 Feb 2016 15:55:01 +0000 (16:55 +0100)]
vboxDumpDisplay: remove extra virReportOOMError

VIR_ALLOC* already reported an error.

9 years agovboxDumpDisplay: add addDesktop bool
Ján Tomko [Fri, 5 Feb 2016 14:44:19 +0000 (15:44 +0100)]
vboxDumpDisplay: add addDesktop bool

When FRONTEND/Type is not any of "sdl", "gui", "vrdp", we add a DESKTOP.
Use a bool to track this, instead of checking that both
totalPresent ("sdl" or "gui" present) and vrdpPresent are zero.

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.