]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoconf: Use virGICVersion enumeration in virDomainDef
Andrea Bolognani [Wed, 3 Feb 2016 13:33:28 +0000 (14:33 +0100)]
conf: Use virGICVersion enumeration in virDomainDef

Instead of allowing any random positive number, restrict the possible
values to the ones that are part of the virGICVersion enumeration.

9 years agoschema: List allowed GIC versions
Andrea Bolognani [Wed, 3 Feb 2016 13:34:32 +0000 (14:34 +0100)]
schema: List allowed GIC versions

This change allows to use "host" as a GIC version in the domain XML.

Since we'll need to update the virGICVersion enumeration to support
new GIC versions anyway, it makes sense to be a bit more strict in
the schema as well and reject values that are not in the enumeration.

9 years agogic: Introduce virGICVersion enumeration
Andrea Bolognani [Wed, 3 Feb 2016 11:49:51 +0000 (12:49 +0100)]
gic: Introduce virGICVersion enumeration

We currently blindly accept any numeric value as a GIC version, even
though only GIC v2 and GIC v3 actually exist; on the other hand, we
reject "host", which is a perfectly legitimate value for QEMU guests.

This new enumeration contains all GIC versions libvirt is aware of.

9 years agoqemu: fix hot unplug of PCI devices with VFIO
Ludovic Beliveau [Fri, 5 Feb 2016 19:07:50 +0000 (14:07 -0500)]
qemu: fix hot unplug of PCI devices with VFIO

Currently, on hot unplug of PCI devices with VFIO driver for QEMU, libvirt is
trying to restore the host devices to it's previous value (basically a chown
on the previous user/group).

However for devices with VFIO driver, when the device is unbinded it is
removed from the /dev/vfio file system causing the restore label to fail.

The fix is to not restore the label for those PCI devices since they are going
to be teared down anyway.

Signed-off-by: Ludovic Beliveau <ludovic.beliveau@windriver.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoSpell VMware with a lowercase w
Ján Tomko [Mon, 15 Feb 2016 14:34:24 +0000 (15:34 +0100)]
Spell VMware with a lowercase w

Replace all occurrences of VMWare outside the news.

9 years agovsh: Replace vshPrint macro with function
Peter Krempa [Fri, 12 Feb 2016 13:09:02 +0000 (14:09 +0100)]
vsh: Replace vshPrint macro with function

The macro would eat the first parameter. In some cases the format string
for vshPrint was eaten. In other cases the calls referenced variables
which did not exist in the given context. Avoid errors by doing compile
time checking.

9 years agovsh: Simplify bailing out on OOM conditions
Peter Krempa [Fri, 12 Feb 2016 13:00:28 +0000 (14:00 +0100)]
vsh: Simplify bailing out on OOM conditions

When we hit OOM it doesn't really make sense to format the error message
by attempting to allocate it. Introduce a simple helper that prints a
static message and terminates the execution.

9 years agoutil: clean up and expand 802.1QbX negotiation logging
Laine Stump [Thu, 11 Feb 2016 20:24:17 +0000 (15:24 -0500)]
util: clean up and expand 802.1QbX negotiation logging

The existing log messages for this have several problems; there are
two lines of log when one will suffice, they duplicate the function
name in log message (when it's already included by VIR_DEBUG), they're
missing some useful bits, they get logged even when the call is a NOP.

This patch cleans up the problems with those existing logs, and also
adds a new VIR_INFO-level log down at the function that is actually
creating and sending the netlink message that logs *everything* going
into the netlink message (which turns out to be much more useful in
practice for me; I didn't want to eliminate the logs at the existing
location though, in case they are useful in some scenario I'm
unfamiliar with; anyway those logs are remaining at debug level, so it
shouldn't be a bother to anyone).

9 years agonetwork: consolidated info log for all network allocate/free operations
Laine Stump [Tue, 9 Feb 2016 17:28:48 +0000 (12:28 -0500)]
network: consolidated info log for all network allocate/free operations

There are three functions that deal with allocating and freeing
devices from a networks netdev/pci device pool:
network(Allocate|Notify|Release)ActualDevice(). These functions also
maintain a counter of the number of domains currently using a network
(regardless of whether or not that network uses a device pool). Each
of these functions had multiple log messages (output using VIR_DEBUG)
that were in slightly different formats and gave varying amounts of
information.

This patch creates a single function to log the pertinent information
in a consistent manner for all three of these functions. Along with
assuring that all the functions produce a consistent form of output
(and making it simpler to change), it adds the MAC address of the
domain interface involved in the operation, making it possible to
verify which interface of which domain the operation is being done for
(assuming that all MAC addresses are unique, of course).

All of these messages are raised from DEBUG to INFO, since they don't
happen that often (once per interface per domain/libvirtd start or
domain stop), and can be very informative and helpful - eliminating
the need to log debug level messages makes it much easier to sort
these out.

9 years agonetwork: consolidate connection count updates for device pool
Laine Stump [Thu, 11 Feb 2016 18:52:04 +0000 (13:52 -0500)]
network: consolidate connection count updates for device pool

networkReleaseActualDevice() and networkNotifyActualDevice() both were
updating the individual devices' connections count in two separate
places (unlike networkAllocateActualDevice() which does it in a single
unified place after success:). The code is correct, but prone to
confusion / later breakage. All of these updates are anyway located at
the end of if/else clauses that are (with the exception of a single
VIR_DEBUG() in each case) immediately followed by the success: label
anyway, so this patch replaces the duplicated ++/-- instructions with
a single ++/-- inside a qualifying "if (dev)" down below success:.
(NB: if dev != NULL, by definition we are using a device (either pci
or netdev, doesn't matter for these purposes) from the network's pool)

The VIR_DEBUG args (which will be replaced in a followup patch anyway)
were all adjusted to account for the connection count being out of
date at the time.

9 years agorbd: Use RBD fast-diff for querying actual volume allocation
Wido den Hollander [Thu, 11 Feb 2016 16:04:17 +0000 (17:04 +0100)]
rbd: Use RBD fast-diff for querying actual volume allocation

Since Ceph version Infernalis (9.2.0) the new fast-diff mechanism
of RBD allows for querying actual volume usage.

Prior to this version there was no easy and fast way to query how
much allocation a RBD volume had inside a Ceph cluster.

To use the fast-diff feature it needs to be enabled per RBD image
and is only supported by Ceph cluster running version Infernalis
(9.2.0) or newer.

Without the fast-diff feature enabled libvirt will report an allocation
identical to the image capacity. This is how libvirt behaves currently.

'virsh vol-info rbd/image2' might output for example:

  Name:           image2
  Type:           network
  Capacity:       1,00 GiB
  Allocation:     124,00 MiB

Newly created volumes will have the fast-diff feature enabled if the
backing Ceph cluster supports it.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: rbd_diff_iterate2() is available in librbd since 266
Wido den Hollander [Thu, 11 Feb 2016 16:04:16 +0000 (17:04 +0100)]
rbd: rbd_diff_iterate2() is available in librbd since 266

In commit 0b15f920 there is a #ifdef which requires LIBRBD_VERSION_CODE
266 or newer for rbd_diff_iterate2()

rbd_diff_iterate2() is available since 266, so this if-statement should
require anything newer than 265.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Add volStorageBackendRBDGetFeatures() for internal calls
Wido den Hollander [Thu, 11 Feb 2016 16:04:15 +0000 (17:04 +0100)]
rbd: Add volStorageBackendRBDGetFeatures() for internal calls

As more and more features are added to RBD volumes we will need to
call this method more often.

By moving it into a internal function we can re-use code inside the
storage backend.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agodomsuspend: Fix warning on mingw build
Andrea Bolognani [Wed, 10 Feb 2016 18:44:01 +0000 (19:44 +0100)]
domsuspend: Fix warning on mingw build

Commit d82170d introduced a workaround for domtop: in that example
program, we define a symbol called ERROR for our own use, but since
a symbol with the same name is already defined in one of mingw's
header files, we get a warning when using that compiler.

domsuspend defines the same problematic symbol, so the workaround
has been copied over.

9 years agostorageVolCreateXMLFrom: Check if backend knows how to createVol
Michal Privoznik [Wed, 10 Feb 2016 16:17:00 +0000 (17:17 +0100)]
storageVolCreateXMLFrom: Check if backend knows how to createVol

It is highly unlikely that a backend will know how to create a
volume from a different volume (buildVolFrom) and not know how to
create an empty volume (createVol). But:
1) we call the function without any prior check so if that's the
case we would SIGSEGV immediatelly
2) it's better to be safe than sorry.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorageVolCreateXML: Swap order of two operations
Michal Privoznik [Wed, 10 Feb 2016 16:05:03 +0000 (17:05 +0100)]
storageVolCreateXML: Swap order of two operations

Firstly, we realloc internal list to hold new item (=volume that
will be potentially created) and then we check whether we
actually know how to create it. If we don't we consume more
memory than we really need for no good reason.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Teach vol-create-as to --print-xml
Michal Privoznik [Wed, 10 Feb 2016 15:48:15 +0000 (16:48 +0100)]
virsh: Teach vol-create-as to --print-xml

We have the same argument to many other commands that produce an
XML based on what user typed. But unfortunately vol-create-as
was missing it. Maybe nobody had needed it yet. Well, I did
just now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agocmdVolCreateAs: Rework to follow usual func pattern
Michal Privoznik [Wed, 10 Feb 2016 15:35:48 +0000 (16:35 +0100)]
cmdVolCreateAs: Rework to follow usual func pattern

The way we usually write functions is that we start the work and
if something goes bad we goto cleanup and roll back there. Or
just free resources that are no longer needed. Do the same here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirportallocatortest: Run on linux only
Michal Privoznik [Fri, 12 Feb 2016 12:48:02 +0000 (13:48 +0100)]
virportallocatortest: Run on linux only

After the rework of mocking of our tests there's the
virportallocator test failing to link on mingw. Well, it's the
mocking library actually:

../gnulib/lib/.libs/libgnu.a(bind.o): In function `rpl_bind':
/home/jenkins/libvirt-mingw/build32/gnulib/lib/../../../gnulib/lib/bind.c:33: multiple definition of `rpl_bind'
.libs/virportallocatormock_la-virportallocatormock.o:/home/jenkins/libvirt-mingw/build32/tests/../../tests/virportallocatormock.c:79: first defined here

I've no idea why this matters to mingw and does not to others.
Nevertheless, if we make the test linux only the problem goes
away.

Apparently, our test for RTLD_NEXT is not sufficient because
mingw32 defines it. Lets put aside for a while fact that it has
the same value as RTLD_DEFAULT which by description has different
meaning, shall we?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz: fix race condition when adding domain to domains list
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:14 +0000 (12:39 +0300)]
vz: fix race condition when adding domain to domains list

Race condition:
User calls defineXML to create new instance.
The main thread from vzDomainDefineXMLFlags() creates new instance by prlsdkCreateVm.
Then this thread calls prlsdkAddDomain to add new domain to domains list.
The second thread receives notification from hypervisor that new VM was created.
It calls prlsdkHandleVmAddedEvent() and also tries to add new domain to domains list.
These two threads call virDomainObjListFindByUUID() from prlsdkAddDomain() and don't find new domain.
So they add two domains with the same uuid to domains list.

This fix splits logic of prlsdkAddDomain() into two functions.
1. vzNewDomain() creates new empty domain in domains list with the specific uuid.
2. prlsdkLoadDomain() add data from VM to domain object.

New algorithm for creating an instance:
In vzDomainDefineXMLFlags() we add new domain to domain list by calling vzNewDomain()
and only after that we call CreateVm() to create VM.
It means that we "reserve" domain object with the specific uuid.
After creation of new VM we add info from this VM
to reserved domain object by calling prlsdkLoadDomain().

Before this patch prlsdkLoadDomain() worked in 2 different cases:
1. It creates and initializes new domain. Then updates it from sdk handle.
2. It updates existed domain from sdk handle.
In this patch we remove code which creates new domain from LoadDomain()
and move it to vzNewDomain().
Now prlsdkLoadDomain() only updates domain from skd handle.

In notification handler prlsdkHandleVmAddedEvent() we check
the existence of a domain and if it doesn't exist we add new domain by calling
vzNewDomain() and load info from sdk handle via prlsdkLoadDomain().

9 years agovz: fix notification subscription
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:13 +0000 (12:39 +0300)]
vz: fix notification subscription

Bug cause:
Update the domain that is subscribed to hypervisor notification.
LoadDomain() rewrites notifications fields in vzDomObj structure and makes domain as "unsubscribed".
Fix:
Initialize notification fields in vzDomObj only if we create a new domain.
And do not reinitialize these fields if we update domain (by calling LoadDomain with olddom argument)

9 years agovz: remove unused struct field
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:12 +0000 (12:39 +0300)]
vz: remove unused struct field

In commit 7039bb3c we have removed code that saves uuid to vzDomObj.uuid
So this field is no longer needed.

9 years agovz: make output arguments in prlsdkGetDomainIds as optional
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:11 +0000 (12:39 +0300)]
vz: make output arguments in prlsdkGetDomainIds as optional

prlsdkGetDomainIds() returns name and uuid for specified instance.
Now output arguments can be NULL.
It allows to get only necessary info(name or uuid).

9 years agoChange maintainers list
Maxim Nestratov [Fri, 12 Feb 2016 10:06:05 +0000 (13:06 +0300)]
Change maintainers list

Add Maxim Nestratov to the commiters list.
Move Dmitry Guryanov to the previous maintainers list.

9 years agotests: Rename virmockdbus -> virdbusmock for consistency
Andrea Bolognani [Thu, 11 Feb 2016 13:08:11 +0000 (14:08 +0100)]
tests: Rename virmockdbus -> virdbusmock for consistency

All mock libraries were called vir*mock except for this one; now
the naming is consistent across the board.

9 years agotests: Don't use "lib" prefix for mock libraries
Andrea Bolognani [Thu, 11 Feb 2016 12:59:41 +0000 (13:59 +0100)]
tests: Don't use "lib" prefix for mock libraries

virportallocatormock was the only one using it, and has been
changed accordingly.

9 years agotests: Allow use of close() in mock libraries
Andrea Bolognani [Thu, 11 Feb 2016 12:51:26 +0000 (13:51 +0100)]
tests: Allow use of close() in mock libraries

As mock libraries are not to be linked against libvirt, the
sc_prohibit_close syntax-check rule does not apply.

This fixes a syntax-check failure introduced by commit a03cbfe0fb.

9 years agotests: Split off the mock part of the port allocator test
Andrea Bolognani [Thu, 11 Feb 2016 12:46:16 +0000 (13:46 +0100)]
tests: Split off the mock part of the port allocator test

Instead of compiling either the mock or the non-mock part of the
file based on a compiler flag, split the mock part off to its
own file.

9 years agoconf: snapshot: Avoid autogenerating duplicate snapshot names
Peter Krempa [Thu, 11 Feb 2016 08:57:45 +0000 (09:57 +0100)]
conf: snapshot: Avoid autogenerating duplicate snapshot names

The snapshot name generator truncates the original file name after a '.'
and replaces the suffix with the snapshot name. If two disks source
images differ only in the suffix portion, the generated name will be
duplicate.

Since this is a corner case just error out stating that a duplicate name
was generated. The user can work around this situation by providing
the file names explicitly.

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

9 years agoconf: snapshot: Refactor virDomainSnapshotDefAssignExternalNames
Peter Krempa [Thu, 11 Feb 2016 08:42:36 +0000 (09:42 +0100)]
conf: snapshot: Refactor virDomainSnapshotDefAssignExternalNames

Get rid of one indentation level by negating condition and remove ugly
pointer arithmetic at the cost of one extra allocation.

9 years agoconf: snapshot: Extract code to generate default external file names
Peter Krempa [Thu, 11 Feb 2016 08:07:05 +0000 (09:07 +0100)]
conf: snapshot: Extract code to generate default external file names

9 years agoconf: snapshot: Rename disksorter to virDomainSnapshotCompareDiskIndex
Peter Krempa [Thu, 11 Feb 2016 07:42:00 +0000 (08:42 +0100)]
conf: snapshot: Rename disksorter to virDomainSnapshotCompareDiskIndex

Stick to the naming pattern.

9 years agotests: Link mock libraries against gnulib and gnulib only
Andrea Bolognani [Thu, 11 Feb 2016 11:10:35 +0000 (12:10 +0100)]
tests: Link mock libraries against gnulib and gnulib only

Mock libraries should not be linked against libvirt, but some of
them did - fix that.

On the other hand, not linking against gnulib can cause build
failures on mingw, so define a new $(MOCKLIBS_LIBS) variable and
use it everywhere.

9 years agotests: Use plain close() in mock code
Andrea Bolognani [Thu, 11 Feb 2016 10:33:45 +0000 (11:33 +0100)]
tests: Use plain close() in mock code

The virportallocatortest.c file is compiled both as a test case
and as a mock library; in the latter case, it can't use
VIR_FORCE_CLOSE() because mock libraries are not linked against
libvirt.

Replace VIR_FORCE_CLOSE() with plain close() to solve the issue.

9 years agodbus: Don't unref NULL messages
Michal Privoznik [Thu, 11 Feb 2016 10:14:11 +0000 (11:14 +0100)]
dbus: Don't unref NULL messages

Apparently we are not the only ones with dumb free functions
because dbus_message_unref() does not accept NULL either. But if
I were to vote, this one is even more evil. Instead of returning
an error just like we do it immediately dereference any pointer
passed and thus crash you app. Well done DBus!

  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 0x7f878ebda700 (LWP 31264)]
  0x00007f87be4016e5 in ?? () from /usr/lib64/libdbus-1.so.3
  (gdb) bt
  #0  0x00007f87be4016e5 in ?? () from /usr/lib64/libdbus-1.so.3
  #1  0x00007f87be3f004e in dbus_message_unref () from /usr/lib64/libdbus-1.so.3
  #2  0x00007f87bf6ecf95 in virSystemdGetMachineNameByPID (pid=9849) at util/virsystemd.c:228
  #3  0x00007f879761bd4d in qemuConnectCgroup (driver=0x7f87600a32a0, vm=0x7f87600c7550) at qemu/qemu_cgroup.c:909
  #4  0x00007f87976386b7 in qemuProcessReconnect (opaque=0x7f87600db840) at qemu/qemu_process.c:3386
  #5  0x00007f87bf6edfff in virThreadHelper (data=0x7f87600d5580) at util/virthread.c:206
  #6  0x00007f87bb602334 in start_thread (arg=0x7f878ebda700) at pthread_create.c:333
  #7  0x00007f87bb3481bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
  (gdb) frame 2
  #2  0x00007f87bf6ecf95 in virSystemdGetMachineNameByPID (pid=9849) at util/virsystemd.c:228
  228         dbus_message_unref(reply);
  (gdb) p reply
  $1 = (DBusMessage *) 0x0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirhook: do not save the return value of virBuildPath
Ján Tomko [Wed, 10 Feb 2016 15:30:38 +0000 (16:30 +0100)]
virhook: do not save the return value of virBuildPath

This function returns -1 on allocation error, there's no
need to check the path for NULL again.

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.