]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agotests: Add resctrl test for vircaps2xmltest
Martin Kletzander [Fri, 31 Mar 2017 12:36:58 +0000 (14:36 +0200)]
tests: Add resctrl test for vircaps2xmltest

Add info from yet another machine, this time with resctrl data so that
we can extend tests easily in a test-driven way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add support for more complicated hierarchies in vircaps2xmltest
Martin Kletzander [Fri, 31 Mar 2017 12:33:57 +0000 (14:33 +0200)]
tests: Add support for more complicated hierarchies in vircaps2xmltest

More directories will need to be mocked, so let's prepare for that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoInit host cache info in drivers
Martin Kletzander [Wed, 29 Mar 2017 13:52:31 +0000 (15:52 +0200)]
Init host cache info in drivers

Added only in drivers that were already calling
virCapabilitiesInitNUMA().  Instead of refactoring all the callers to
behave the same way in case of error, just follow what the callers are
doing for all the functions.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoAdd host cache information in capabilities
Martin Kletzander [Thu, 30 Mar 2017 13:01:27 +0000 (15:01 +0200)]
Add host cache information in capabilities

We're only adding only info about L3 caches, we can add more
later (just by changing one line), but for now that's more than enough
without overwhelming anyone.

XML snippet of how this should look like (also seen as part of the commit):

  <cache>
    <bank id='0' level='3' type='both' size='8192' unit='KiB' cpus='0-7'/>
  </cache>

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add missing cache data for vircaps2xmltest
Martin Kletzander [Mon, 27 Mar 2017 06:27:38 +0000 (08:27 +0200)]
tests: Add missing cache data for vircaps2xmltest

Commit a0fdd2f6f9a0cc77ae285c289e2c16d314b6a907 added some data from
the system but forgot 3 files for each cache.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Test vircaps2xmldata XMLs in virschematest
Martin Kletzander [Thu, 30 Mar 2017 12:55:12 +0000 (14:55 +0200)]
tests: Test vircaps2xmldata XMLs in virschematest

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Remove virsysfs and instead enhance virFileReadValue* functions
Martin Kletzander [Wed, 5 Apr 2017 14:13:52 +0000 (16:13 +0200)]
util: Remove virsysfs and instead enhance virFileReadValue* functions

It is no longer needed thanks to the great virfilewrapper.c.  And this
way we don't have to add a new set of functions for each prefixed
path.

While on that, add two functions that weren't there before, string and
scaled integer reading ones.  Also increase the length of the string
being read by one to accompany for the optional newline at the
end (i.e. change INT_STRLEN_BOUND to INT_BUFSIZE_BOUND).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add virfilewrapper -- the new super "mock"
Martin Kletzander [Mon, 3 Apr 2017 12:29:45 +0000 (14:29 +0200)]
tests: Add virfilewrapper -- the new super "mock"

This mock (which is actually not mock at all, see later) can redirect
all accesses to a path into another path.  There is no need to
create mocks for particular directories, you just create a directory
with all the data a redirect the test there.

In the future, this should also be able to register callbacks for
calls/paths, e.g. when the test is going to write into anything under
"/sys/devices", call function fce();  Then in the open() call we would
add information about the fd into some structure and in write() we
would call fce() with parameters like @path to write to, @data to
be written and pointer to optional return value, so that fce() itself
could stop the call from happening or change its behaviour.  But
that's an idea for a latter day.

This is not a mock because it will not be preloaded, but compiled in
the test itself.  See future patches for usage.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agomdev: Cleanup code after commits @daf5081b and @2739a983
Erik Skultety [Thu, 4 May 2017 13:36:37 +0000 (15:36 +0200)]
mdev: Cleanup code after commits @daf5081b and @2739a983

So, because mingw is somehow OK with dereferencing a pointer within a
VIR_DEBUG macro, compared to outside of it to which it complained with a
"potential NULL pointer dereference" error (still a false positive), we
can make the code a tiny bit cleaner.

Sighed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoDon't use ceph-devel on Fedora
Daniel P. Berrange [Mon, 8 May 2017 09:54:08 +0000 (10:54 +0100)]
Don't use ceph-devel on Fedora

A previous commit changed the spec to use librbd1-devel on
RHEL-7, since this replaces ceph-devel from RHEL-6:

  commit 6cfc8834c858849cc74c3082078dc91fb1cbae38
  Author: Peter Krempa <pkrempa@redhat.com>
  Date:   Thu Mar 5 11:40:54 2015 +0100

    spec: Enable RBD storage driver in RHEL-7

    Use correct package names too as they differ.

RHEL-7 inherited this rename from Fedora though, so it should
have also made Fedora use the new names.

This was missed, because Fedora still provides a (deprecated)
back-compat RPM for ceph-devel that just pulls in librbd1-devel
(and others).

Fixing this stops libvirt pulling Java into the build root in
Fedora.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoHACKING: Document developer tooling
Andrea Bolognani [Fri, 28 Apr 2017 16:30:07 +0000 (18:30 +0200)]
HACKING: Document developer tooling

Advertise some of the useful developer tooling libvirt
integrates with out of the box.

8 years agoAdd YouCompleteMe support
Andrea Bolognani [Fri, 21 Apr 2017 14:47:02 +0000 (16:47 +0200)]
Add YouCompleteMe support

YouCompleteMe[1] is a vim plugin that implements semantic
code completion using libclang.

For non-trivial projects such as libvirt, the plugin needs
some help figuring out where to find the various header
files: generate its configuration file at configure time
so that the plugin works out of the box.

[1] http://valloric.github.io/YouCompleteMe/

8 years agoAdd color_coded support
Andrea Bolognani [Fri, 21 Apr 2017 14:05:19 +0000 (16:05 +0200)]
Add color_coded support

color_coded[1] is a vim plugin that implements semantic
syntax highlighting using libclang.

For non-trivial projects such as libvirt, the plugin needs
some help figuring out where to find the various header
files: generate its configuration file at configure time
so that the plugin works out of the box.

[1] https://github.com/jeaye/color_coded

8 years agoPost-release version bump to 3.4.0
Erik Skultety [Tue, 9 May 2017 07:17:54 +0000 (09:17 +0200)]
Post-release version bump to 3.4.0

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconfigure: enforce presence of python for build
Daniel P. Berrange [Mon, 8 May 2017 10:35:17 +0000 (11:35 +0100)]
configure: enforce presence of python for build

The API docs extractor, ESX code generator and keycodemapdb tools
rely on python. Historically every platform that this present, but
with switch to Python3 by default, we're increasingly seeing
installs without a /usr/bin/python.

This tightens up the check during configure, so it exits immediately
if python is missing, rather than leaving an empty $(PYTHON) make
variable which leads to more obscure errors later.

Also add it as a build dep for Mingw, since Fedora build roots no
longer get python2 by default. This was not previously a major
problem, since both ESX & API generated files were included in
EXTRA_DIST, but the keycodemapdb generated files are not, so we
require python all the time now.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoRelease of libvirt-3.3.0
Daniel Veillard [Fri, 5 May 2017 19:38:00 +0000 (21:38 +0200)]
Release of libvirt-3.3.0

* docs/news.xml: updated for release
* po/*.po*: regenerated

8 years agovirNWFilterObjListFree: Don't leak nwfilters->objs
Michal Privoznik [Thu, 4 May 2017 15:25:09 +0000 (17:25 +0200)]
virNWFilterObjListFree: Don't leak nwfilters->objs

When adding a nwfilter onto the list in
virNWFilterObjListAssignDef() this array is re-allocated to match
demand for new size. However, it is never freed leading to a
leak:

==26535== 136 bytes in 1 blocks are definitely lost in loss record 1,079 of 1,250
==26535==    at 0x4C2E2BE: realloc (vg_replace_malloc.c:785)
==26535==    by 0x54BA28E: virReallocN (viralloc.c:245)
==26535==    by 0x54BA384: virExpandN (viralloc.c:294)
==26535==    by 0x54BA657: virInsertElementsN (viralloc.c:436)
==26535==    by 0x55DB011: virNWFilterObjListAssignDef (virnwfilterobj.c:362)
==26535==    by 0x55DB530: virNWFilterObjListLoadConfig (virnwfilterobj.c:503)
==26535==    by 0x55DB635: virNWFilterObjListLoadAllConfigs (virnwfilterobj.c:539)
==26535==    by 0x2AC5A28B: nwfilterStateInitialize (nwfilter_driver.c:250)
==26535==    by 0x5621C64: virStateInitialize (libvirt.c:770)
==26535==    by 0x124379: daemonRunStateInit (libvirtd.c:881)
==26535==    by 0x554AC78: virThreadHelper (virthread.c:206)
==26535==    by 0x8F5F493: start_thread (in /lib64/libpthread-2.23.so)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agovirPerfEventIsEnabled: Accept NULL @perf
Michal Privoznik [Thu, 4 May 2017 14:27:45 +0000 (16:27 +0200)]
virPerfEventIsEnabled: Accept NULL @perf

After bdcf6e481 there is a crasher in libvirt. The commit assumes
that priv->perf is always set. That is not true. For inactive
domains, the priv->perf is not allocated as it is set in
qemuProcessLaunch(). Now, usually we differentiate between
accesses to inactive and active definition and it works just
fine. Except for 'domstats'. There priv->perf is accessed without
prior check for domain inactivity. While we could check for that,
more robust solution is to make virPerfEventIsEnabled() accept
NULL.

How to reproduce:
1) ensure you have at least one inactive domain
2) virsh domstats

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
8 years agomdev: Fix mingw build by adding a check for non-NULL pointer
Erik Skultety [Thu, 4 May 2017 09:26:10 +0000 (11:26 +0200)]
mdev: Fix mingw build by adding a check for non-NULL pointer

This patch fixes the following MinGW error (although actually being a
false positive):

../../src/util/virmdev.c: In function 'virMediatedDeviceListMarkDevices':
../../src/util/virmdev.c:453:21: error: potential null pointer
dereference [-Werror=null-dereference]
          const char *mdev_path = mdev->path;
                      ^~~~~~~~~

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agonews: Fix typo
Andrea Bolognani [Thu, 4 May 2017 11:16:37 +0000 (13:16 +0200)]
news: Fix typo

Pointed-out-during-review-by: Ján Tomko <jtomko@redhat.com>
Not-fixed-before-pushing-by: Andrea Bolognani <abologna@redhat.com>
8 years agonews: Add even more v3.3.0 entries
Andrea Bolognani [Wed, 3 May 2017 16:01:58 +0000 (18:01 +0200)]
news: Add even more v3.3.0 entries

8 years agomdev: Fix daemon crash on domain shutdown after reconnect
Erik Skultety [Fri, 28 Apr 2017 07:24:31 +0000 (09:24 +0200)]
mdev: Fix daemon crash on domain shutdown after reconnect

The problem resides in virHostdevUpdateActiveMediatedDevices which gets
called during qemuProcessReconnect. The issue here is that
virMediatedDeviceListAdd takes a pointer to the item to be added to the
list to which VIR_APPEND_ELEMENT is used, which also clears the pointer.
However, in this case only the local copy of the pointer got cleared,
leaving the original pointing to valid memory. To sum it up, during
cleanup phase, the original pointer is freed and the daemon crashes
basically any time it would access it.

Backtrace:
0x00007ffff3ccdeba in __strcmp_sse2_unaligned
0x00007ffff72a444a in virMediatedDeviceListFindIndex
0x00007ffff7241446 in virHostdevReAttachMediatedDevices
0x00007fffc60215d9 in qemuHostdevReAttachMediatedDevices
0x00007fffc60216dc in qemuHostdevReAttachDomainDevices
0x00007fffc6046e6f in qemuProcessStop
0x00007fffc6091596 in processMonitorEOFEvent
0x00007fffc6091793 in qemuProcessEventHandler
0x00007ffff7294bf5 in virThreadPoolWorker
0x00007ffff7294184 in virThreadHelper
0x00007ffff3fdc3c4 in start_thread () from /lib64/libpthread.so.0
0x00007ffff3d269cf in clone () from /lib64/libc.so.6

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
8 years agoutil: mdev: Use a local variable instead of a direct pointer access
Erik Skultety [Fri, 28 Apr 2017 05:52:52 +0000 (07:52 +0200)]
util: mdev: Use a local variable instead of a direct pointer access

Use a local variable to hold data, rather than accessing the pointer
after calling virMediatedDeviceListAdd (therefore VIR_APPEND_ELEMENT).
Although not causing an issue at the moment, this change is a necessary
prerequisite for tweaking virMediatedDeviceListAdd in a separate patch,
which will take a reference for the source pointer (instead of pointer
value) and will clear it along the way.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemuDomainDetachDeviceUnlink: Don't unlink files we haven't created
Michal Privoznik [Fri, 28 Apr 2017 11:17:04 +0000 (13:17 +0200)]
qemuDomainDetachDeviceUnlink: Don't unlink files we haven't created

Even though there are several checks before calling this function
and for some scenarios we don't call it at all (e.g. on disk hot
unplug), it may be possible to sneak in some weird files (e.g. if
domain would have RNG with /dev/shm/some_file as its backend). No
matter how improbable, we shouldn't unlink it as we would be
unlinking a file from the host which we haven't created in the
first place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
8 years agoqemuDomainAttachDeviceMknodRecursive: Don't try to create devices under preserved...
Michal Privoznik [Fri, 28 Apr 2017 09:28:53 +0000 (11:28 +0200)]
qemuDomainAttachDeviceMknodRecursive: Don't try to create devices under preserved mount points

Just like in previous commit, this fixes the same issue for
hotplug.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
8 years agoqemuDomainCreateDeviceRecursive: Don't try to create devices under preserved mount...
Michal Privoznik [Fri, 28 Apr 2017 08:45:45 +0000 (10:45 +0200)]
qemuDomainCreateDeviceRecursive: Don't try to create devices under preserved mount points

While the code allows devices to already be there (by some
miracle), we shouldn't try to create devices that don't belong to
us. For instance, we shouldn't try to create /dev/shm/file
because /dev/shm is a mount point that is preserved. Therefore if
a file is created there from an outside (e.g. by mgmt application
or some other daemon running on the system like vhostmd), it
exists in the qemu namespace too as the mount point is the same.
It's only /dev and /dev only that is different. The same
reasoning applies to all other preserved mount points.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
8 years agoqemuDomainCreateDeviceRecursive: pass a structure instead of bare path
Michal Privoznik [Fri, 28 Apr 2017 07:30:23 +0000 (09:30 +0200)]
qemuDomainCreateDeviceRecursive: pass a structure instead of bare path

Currently, all we need to do in qemuDomainCreateDeviceRecursive() is to
take given @device, get all kinds of info on it (major & minor numbers,
owner, seclabels) and create its copy at a temporary location @path
(usually /var/run/libvirt/qemu/$domName.dev), if @device live under
/dev. This is, however, very loose condition, as it also means
/dev/shm/* is created too. Therefor, we will need to pass more arguments
into the function for better decision making (e.g. list of mount points
under /dev). Instead of adding more arguments to all the functions (not
easily reachable because some functions are callback with strictly
defined type), lets just turn this one 'const char *' into a 'struct *'.
New "arguments" can be then added at no cost.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
8 years agoqemuDomainBuildNamespace: Move /dev/* mountpoints later
Michal Privoznik [Thu, 27 Apr 2017 14:29:21 +0000 (16:29 +0200)]
qemuDomainBuildNamespace: Move /dev/* mountpoints later

When setting up mount namespace for a qemu domain the following
steps are executed:

1) get list of mountpoints under /dev/
2) move them to /var/run/libvirt/qemu/$domName.ext
3) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
4) move the mountpoint of the new device tree to /dev
5) restore original mountpoints from step 2)

Note the problem with this approach is that if some device in step
3) requires access to a mountpoint from step 2) it will fail as
the mountpoint is not there anymore. For instance consider the
following domain disk configuration:

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/dev/shm/vhostmd0'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>

In this case operation fails as we are unable to create vhostmd0
in the new device tree because after step 2) there is no /dev/shm
anymore. Leave aside fact that we shouldn't try to create devices
living in other mountpoints. That's a separate bug that will be
addressed later.

Currently, the order described above is rearranged to:

1) get list of mountpoints under /dev/
2) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
3) move them to /var/run/libvirt/qemu/$domName.ext
4) move the mountpoint of the new device tree to /dev
5) restore original mountpoints from step 3)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
8 years agonews: Add more v3.3.0 entries
Andrea Bolognani [Tue, 2 May 2017 15:20:16 +0000 (17:20 +0200)]
news: Add more v3.3.0 entries

These entries cover a number of features, improvements and
bug fixes that had not been documented during the development
cycle.

8 years agonews: Tweak existing v3.3.0 entries
Andrea Bolognani [Tue, 2 May 2017 13:52:02 +0000 (15:52 +0200)]
news: Tweak existing v3.3.0 entries

Some of the content was not following the (loosely established)
style, and some of the XML was not aligned properly.

8 years agoclient: Report proper close reason
Jiri Denemark [Tue, 2 May 2017 14:39:57 +0000 (16:39 +0200)]
client: Report proper close reason

When we get a POLLHUP or VIR_EVENT_HANDLE_HANGUP event for a client, we
still want to read from the socket to process any accumulated data. But
doing so inevitably results in an error and a call to
virNetClientMarkClose before we get to processing the hangup event (and
another call to virNetClientMarkClose). However the close reason passed
to the second virNetClientMarkClose call is ignored because another one
was already set. We need to pass the correct close reason when marking
the socket to be closed for the first time.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Fix persistent migration of transient domains
Jiri Denemark [Tue, 2 May 2017 16:01:04 +0000 (18:01 +0200)]
qemu: Fix persistent migration of transient domains

While fixing a bug with incorrectly freed memory in commit
v3.1.0-399-g5498aa29a, I accidentally broke persistent migration of
transient domains. Before adding qemuDomainDefCopy in the path, the code
just took NULL from vm->newDef and used it as the persistent def, which
resulted in no persistent XML being sent in the migration cookie. This
scenario is perfectly valid and the destination correctly handles it by
using the incoming live definition and storing it as the persistent one.

After the mentioned commit libvirtd would just segfault in the described
scenario.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoFix padding of encrypted data
Daniel P. Berrange [Tue, 2 May 2017 10:32:43 +0000 (11:32 +0100)]
Fix padding of encrypted data

If we are encoding a block of data that is 16 bytes in length,
we cannot leave it as 16 bytes, we must pad it out to the next
block boundary, 32 bytes. Without this padding, the decoder will
incorrectly treat the last byte of plain text as the padding
length, as it can't distinguish padded from non-padded data.

The problem exhibited itself when using a 16 byte passphrase
for a LUKS volume

  $ virsh secret-set-value 55806c7d-8e93-456f-829b-607d8c198367 \
       $(echo -n 1234567812345678 | base64)
  Secret value set

  $ virsh start demo
  error: Failed to start domain demo
  error: internal error: process exited while connecting to monitor: >>>>>>>>>>Len 16
  2017-05-02T10:35:40.016390Z qemu-system-x86_64: -object \
    secret,id=virtio-disk1-luks-secret0,data=SEtNi5vDUeyseMKHwc1c1Q==,\
    keyid=masterKey0,iv=zm7apUB1A6dPcH53VW960Q==,format=base64: \
    Incorrect number of padding bytes (56) found on decrypted data

Notice how the padding '56' corresponds to the ordinal value of
the character '8'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: Don't reset "events" migration capability
Jiri Denemark [Fri, 28 Apr 2017 13:56:44 +0000 (15:56 +0200)]
qemu: Don't reset "events" migration capability

When creating v3.2.0-77-g8be3ccd04 commit, I completely forgot that one
migration capability is very special. It's the "events" capability which
tells QEMU to report "MIGRATION" events. Since libvirt always wants the
events, it is enabled in qemuConnectMonitor and the rest of the code
should not touch it.

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

Messed-up-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agovirsh-domain-monitor: add human readable output for 'domblkinfo'.
Julio Faracco [Mon, 1 May 2017 22:35:55 +0000 (19:35 -0300)]
virsh-domain-monitor: add human readable output for 'domblkinfo'.

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

The virsh command 'domblkinfo' returns the capacity, allocation and phisycal
size of the devices attached in a domain. Usually, this sizes are very big
and hard to understand and calculate. This commits introduce a human readable
support to check the size of each field easilly.

For example, the command before:

virsh # domblkinfo my_domain hda
Capacity:       21474836480
Allocation:     14875545600
Physical:       21474836480

and after this patch:

virsh # domblkinfo my_domain hda --human
Capacity:       20.000G
Allocation:     13.900G
Physical:       20.000G

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonews: Document libxl nested HVM support
Jim Fehlig [Thu, 27 Apr 2017 21:02:36 +0000 (15:02 -0600)]
news: Document libxl nested HVM support

Nested HVM support in the libxl driver is a news-worthy
improvement for libvirt 3.3.0.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agoutil: rename/move VIR_NET_GENERATED_PREFIX to be consistent
Laine Stump [Tue, 25 Apr 2017 18:43:24 +0000 (14:43 -0400)]
util: rename/move VIR_NET_GENERATED_PREFIX to be consistent

... with VIR_NET_GENERATED_MACV???_PREFIX, which is defined in
util/virnetdevmacvlan.h.

Since VIR_NET_GENERATED_PREFIX is used for plain tap devices, it is
renamed to VIR_NET_GENERATED_TAP_PREFIX and moved to virnetdev.h

8 years agoconf: don't ignore <target dev='blah'/> for macvtap interfaces
Laine Stump [Mon, 27 Mar 2017 01:57:54 +0000 (21:57 -0400)]
conf: don't ignore <target dev='blah'/> for macvtap interfaces

The parser had been clearing out *all* suggested device names for
type='direct' (aka macvtap) interfaces. All of the code implementing
macvtap allows for a user-specified device name, so we should allow
it. In the case that an interface name starts with "macvtap" or
"macvlan" though, we do still clear it out, just as we do with "vnet"
(which is the prefix used for automatically generated tap device
names), since those are the prefixes for the names we autogenerate for
macvtap and macvlan devices.

Resolves: https://bugzilla.redhat.com/1335798

8 years agoutil: make macvtap/macvlan generated name #defines available to other files
Laine Stump [Tue, 25 Apr 2017 18:09:45 +0000 (14:09 -0400)]
util: make macvtap/macvlan generated name #defines available to other files

MACVTAP_NAME_PREFIX and MACVLAN_NAME_PREFIX could be useful to other
files if they were defined in virnetdevmacvlan.h instead of
virnetdevmacvlan.c, so do that (while slightly renaming them and also
adding yet another #define that chooses between macvlan/macvtap based
on flags).

This is a prerequisite to fix: https://bugzilla.redhat.com/1335798

8 years agonetwork: better log message when network is inactive during reconnect
Laine Stump [Tue, 25 Apr 2017 16:26:43 +0000 (12:26 -0400)]
network: better log message when network is inactive during reconnect

If the network isn't active during networkNotifyActualDevice(), we
would log an error message stating that the bridge device didn't
exist. This patch adds a check to see if the network is active, making
the logs more useful in the case that it isn't.

Partially resolves: https://bugzilla.redhat.com/1442700

8 years agoqemu: don't kill qemu process on restart if networkNotify fails
Laine Stump [Tue, 25 Apr 2017 16:20:30 +0000 (12:20 -0400)]
qemu: don't kill qemu process on restart if networkNotify fails

Nothing that could happen during networkNotifyActualDevice() could
justify unceremoniously killing the qemu process, but that's what we
were doing.

In particular, new code added in commit 85bcc022 (first appearred in
libvirt-3.2.0) attempts to reattach tap devices to their assigned
bridge devices when libvirtd restarts (to make it easier to recover
from a restart of a libvirt network). But if the network has been
stopped and *not* restarted, the bridge device won't exist and
networkNotifyActualDevice() will fail.

This patch changes networkNotifyActualDevice() and
qemuProcessNotifyNets() to return void, so that qemuProcessReconnect()
will soldier on regardless of what happens (any errors will still be
logged though).

Partially resolves: https://bugzilla.redhat.com/1442700

8 years agoconf: format only relevant attributes for graphics based on listen type
Pavel Hrdina [Wed, 26 Apr 2017 10:47:49 +0000 (12:47 +0200)]
conf: format only relevant attributes for graphics based on listen type

This patch changes following output:

    ...
    <graphics type='vnc' port='-1' autoport='yes'>
      <listen type='none'/>
    </graphics>
    ...

into this output:

    ...
    <graphics type='vnc'>
      <listen type='none'/>
    </graphics>
    ...

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoiohelper: Remove unused mode
Michal Privoznik [Fri, 7 Apr 2017 14:50:31 +0000 (16:50 +0200)]
iohelper: Remove unused mode

After 1eb6647979f8c nobody calls the iohelper with 6 arguments.
Everybody uses the other mode. Well, the only user of iohelper
after the previous commit is virFileWrapperFd really.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agovirfdstream: Drop iohelper in favour of a thread
Michal Privoznik [Thu, 6 Apr 2017 16:21:39 +0000 (18:21 +0200)]
virfdstream: Drop iohelper in favour of a thread

Currently we use iohelper for virFDStream implementation. This is
because UNIX I/O can lie sometimes: even though a FD for a
file/block device is set as unblocking, actual read()/write() can
block. To avoid this, a pipe is created and one end is kept for
read/write while the other is handed over to iohelper to
write/read the data for us. Thus it's iohelper which gets blocked
and not our event loop.

This approach has two problems:
1) we are spawning a new process.
2) any exchange of information between daemon and iohelper can be
done only through the pipe.

Therefore, iohelper is replaced with an implementation in thread
which is created just for the stream lifetime. The data are still
transferred through pipe (for now), but both problems described
above are solved.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agovirFDStreamData: Turn into virObjectLockable
Michal Privoznik [Thu, 16 Jun 2016 10:07:41 +0000 (12:07 +0200)]
virFDStreamData: Turn into virObjectLockable

While this is no functional change, it makes the code look a bit
nicer. Moreover, it prepares ground for future work.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agofdstream: s/struct virFDStreamData */virFDStreamDataPtr/
Michal Privoznik [Thu, 16 Jun 2016 09:54:42 +0000 (11:54 +0200)]
fdstream: s/struct virFDStreamData */virFDStreamDataPtr/

There is really no reason why we should have to have 'struct'
everywhere.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agofdstreamtest: Print more info on read failure
Michal Privoznik [Tue, 11 Apr 2017 07:51:41 +0000 (09:51 +0200)]
fdstreamtest: Print more info on read failure

It helps with debugging if we know what's the return value of
saferead().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agofdstreamtest: Rename tempdir
Michal Privoznik [Tue, 11 Apr 2017 07:50:26 +0000 (09:50 +0200)]
fdstreamtest: Rename tempdir

Because of copy-paste the temporary directory used for this test
is called "fakesysdir". That's probably misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: use qemu-xhci USB controller by default for ppc64 and aarch64
Pavel Hrdina [Thu, 27 Apr 2017 15:56:41 +0000 (17:56 +0200)]
qemu: use qemu-xhci USB controller by default for ppc64 and aarch64

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
8 years agoqemu: add support for qemu-xhci USB controller
Pavel Hrdina [Thu, 13 Apr 2017 10:25:25 +0000 (12:25 +0200)]
qemu: add support for qemu-xhci USB controller

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
8 years agoqemu: introduce QEMU_CAPS_DEVICE_QEMU_XHCI
Pavel Hrdina [Fri, 28 Apr 2017 08:44:03 +0000 (10:44 +0200)]
qemu: introduce QEMU_CAPS_DEVICE_QEMU_XHCI

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
8 years agoqemu: use nec-usb-xhci as a default controller for aarch64 if available
Pavel Hrdina [Thu, 27 Apr 2017 15:53:51 +0000 (17:53 +0200)]
qemu: use nec-usb-xhci as a default controller for aarch64 if available

This is a USB3 controller and it's a better choice than piix3-uhci.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
8 years agoqemu: change the logic of setting default USB controller
Pavel Hrdina [Thu, 27 Apr 2017 15:41:56 +0000 (17:41 +0200)]
qemu: change the logic of setting default USB controller

The new logic will set the piix3-uhci if available regardless of
any architecture and it will be updated to better model based on
architecture and device existence.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
8 years agotests: genericxml2xml: Add test case for HTTP based disk
Peter Krempa [Mon, 24 Apr 2017 13:56:31 +0000 (15:56 +0200)]
tests: genericxml2xml: Add test case for HTTP based disk

8 years agoconf: Extract formatting of network disk source into separate function
Peter Krempa [Mon, 24 Apr 2017 12:54:02 +0000 (14:54 +0200)]
conf: Extract formatting of network disk source into separate function

8 years agodocs: schemas: Split up definitions for NBD and gluster
Peter Krempa [Fri, 21 Apr 2017 13:41:29 +0000 (15:41 +0200)]
docs: schemas: Split up definitions for NBD and gluster

NBD does not mandate a "filename". Gluster can have more servers. Split
them so that we can tighten the schema.

8 years agodocs: schemas: Split out simple network protocols
Peter Krempa [Fri, 21 Apr 2017 10:19:46 +0000 (12:19 +0200)]
docs: schemas: Split out simple network protocols

ftp/tftp/sheepdog have a mandatory filename and support only one host.
There are no additional options for them.

8 years agodocs: schemas: Extract HTTP disk source specification
Peter Krempa [Thu, 20 Apr 2017 14:41:17 +0000 (16:41 +0200)]
docs: schemas: Extract HTTP disk source specification

Make the schema more strict for HTTP disks requiring a name and
mandating exactly one source host.

ftp/tftp entries were not moved here, since http transport also will
support cookies and other options, which will be added later.

8 years agodocs: schemas: Extract RBD-specific data
Peter Krempa [Fri, 21 Apr 2017 09:48:12 +0000 (11:48 +0200)]
docs: schemas: Extract RBD-specific data

RBD driver supports specifying a snapshot image name or config file.
Create a define for RBD and move the specifics there.

8 years agodocs: schemas: Move the interleave definition into network disk source
Peter Krempa [Fri, 21 Apr 2017 09:43:56 +0000 (11:43 +0200)]
docs: schemas: Move the interleave definition into network disk source

Move it to the place where actually interleaving elements can be placed.

8 years agodocs: schemas: Extract disk source host specification
Peter Krempa [Thu, 20 Apr 2017 14:20:26 +0000 (16:20 +0200)]
docs: schemas: Extract disk source host specification

'diskSourceNetwork' schema define was rather big and it would be hard to
simplify it. Split out the host portion subelement into a separate
define.

8 years agodocs: schemas: Remove <interleave> from file/block/dir/volume disks
Peter Krempa [Thu, 20 Apr 2017 15:32:42 +0000 (17:32 +0200)]
docs: schemas: Remove <interleave> from file/block/dir/volume disks

They don't contain any elements to interleave.

8 years agoqemu: Don't fail if physical size can't be updated in qemuDomainGetBlockInfo
Peter Krempa [Thu, 20 Apr 2017 09:16:42 +0000 (11:16 +0200)]
qemu: Don't fail if physical size can't be updated in qemuDomainGetBlockInfo

Since commit c5f6151390 qemuDomainBlockInfo tries to update the
"physical" storage size for all network storage and not only block
devices.

Since the storage driver APIs to do this are not implemented for certain
storage types (RBD, iSCSI, ...) the code would fail to retrieve any data
since the failure of qemuDomainStorageUpdatePhysical is fatal.

Since it's desired to return data even if the total size can't be
updated we need to ignore errors from that function and return plausible
data.

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

8 years agoqemu: Move freeing of PCI address list to qemuProcessStop
Peter Krempa [Wed, 26 Apr 2017 08:27:49 +0000 (10:27 +0200)]
qemu: Move freeing of PCI address list to qemuProcessStop

Rather than freeing the list before starting a new VM clear it after
stopping the old instance when the data becomes invalid.

8 years agoqemu: process: Clean up priv->migTLSAlias
Peter Krempa [Wed, 26 Apr 2017 10:46:03 +0000 (12:46 +0200)]
qemu: process: Clean up priv->migTLSAlias

The alias would be leaked, since it's not freed on the vm stop path.

8 years agoqemu: process: Don't leak priv->usbaddrs after VM restart
Peter Krempa [Wed, 26 Apr 2017 07:57:39 +0000 (09:57 +0200)]
qemu: process: Don't leak priv->usbaddrs after VM restart

Since the private data structure is not freed upon stopping a VM, the
usbaddrs pointer would be leaked:

==15388== 136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 893 of 1,019
==15388==    at 0x4C2CF55: calloc (vg_replace_malloc.c:711)
==15388==    by 0x54BF64A: virAlloc (viralloc.c:144)
==15388==    by 0x5547588: virDomainUSBAddressSetCreate (domain_addr.c:1608)
==15388==    by 0x144D38A2: qemuDomainAssignUSBAddresses (qemu_domain_address.c:2458)
==15388==    by 0x144D38A2: qemuDomainAssignAddresses (qemu_domain_address.c:2515)
==15388==    by 0x144ED1E3: qemuProcessPrepareDomain (qemu_process.c:5398)
==15388==    by 0x144F51FF: qemuProcessStart (qemu_process.c:5979)
[...]

8 years agoqemu: process: Clean automatic NUMA/cpu pinning information on shutdown
Peter Krempa [Tue, 25 Apr 2017 13:17:34 +0000 (15:17 +0200)]
qemu: process: Clean automatic NUMA/cpu pinning information on shutdown

Clean the stale data after shutting down the VM. Otherwise the data
would be leaked on next VM start. This happens due to the fact that the
private data object is not freed on destroy of the VM.

8 years agoxlconfigtest: add tests for 'nestedhvm' support
Wim ten Have [Mon, 24 Apr 2017 13:07:01 +0000 (15:07 +0200)]
xlconfigtest: add tests for 'nestedhvm' support

Testing various configuration schemas targeting postive and negative
nestedhvm under libvirt <cpu mode="host-passthrough"> configuration.

Mode "host-passthrough" generates nestedhvm=1 in/from xl format where

Intel virtualization (VT-x):
<feature policy='disable' name='vmx'/>

    or

AMD virtualization (AMD-V):
<feature policy='disable' name='svm'/>

disables virtualization mode under guest domains.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agoxenconfig: add conversions for xen-xl
Wim ten Have [Mon, 24 Apr 2017 13:07:00 +0000 (15:07 +0200)]
xenconfig: add conversions for xen-xl

Per xen-xl conversions from and to native under host-passthrough
mode we take care for Xen (nestedhvm = mode) applied and inherited
settings generating or processing correct feature policy:

[On Intel (VT-x) architectures]
<feature policy='disable' name='vmx'/>

or

[On AMD (AMD-V) architectures]
<feature policy='disable' name='svm'/>

It will then generate (or parse) for nestedhvm=1 in/from xl format.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
8 years agolibxl: set nestedhvm for mode host-passthrough
Wim ten Have [Mon, 24 Apr 2017 13:06:59 +0000 (15:06 +0200)]
libxl: set nestedhvm for mode host-passthrough

Xen feature nestedhvm is the option on Xen 4.4+ which enables
nested virtualization when mode host-passthrough is applied.

nested HVM is enabled by adding below on the target domain;
<cpu mode='host-passthrough'/>

Virtualization on target domain can be disabled by specifying
such under feature policy rule on target name;

[On Intel (VT-x) architecture]
<feature policy='disable' name='vmx'/>

or:

[On AMD (AMD-V) architecture]
<feature policy='disable' name='svm'/>

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
8 years agoqemu: Add support for guest CPU cache
Jiri Denemark [Tue, 25 Apr 2017 17:07:19 +0000 (19:07 +0200)]
qemu: Add support for guest CPU cache

This patch maps /domain/cpu/cache element into -cpu parameters:

- <cache mode='passthrough'/> is translated to host-cache-info=on
- <cache level='3' mode='emulate'/> is transformed into l3-cache=on
- <cache mode='disable'/> is turned in host-cache-info=off,l3-cache=off

Any other <cache> element is forbidden.

The tricky part is detecting whether QEMU supports the CPU properties.

The 'host-cache-info' property is introduced in v2.4.0-1389-ge265e3e480,
earlier QEMU releases enabled host-cache-info by default and had no way
to disable it. If the property is present, it defaults to 'off' for any
QEMU until at least 2.9.0.

The 'l3-cache' property was introduced later by v2.7.0-200-g14c985cffa.
Earlier versions worked as if l3-cache=off was passed. For any QEMU
until at least 2.9.0 l3-cache is 'off' by default.

QEMU 2.9.0 was the first release which supports probing both properties
by running device-list-properties with typename=host-x86_64-cpu. Older
QEMU releases did not support device-list-properties command for CPU
devices. Thus we can't really rely on probing them and we can just use
query-cpu-model-expansion QMP command as a witness.

Because the cache property probing is only reliable for QEMU >= 2.9.0
when both are already supported for quite a few releases, we let QEMU
report an error if a specific cache mode is explicitly requested. The
other mode (or both if a user requested CPU cache to be disabled) is
explicitly turned off for QEMU >= 2.9.0 to avoid any surprises in case
the QEMU defaults change. Any older QEMU already turns them off so not
doing so explicitly does not make any harm.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoAdd support for CPU cache specification
Jiri Denemark [Mon, 24 Apr 2017 13:40:07 +0000 (15:40 +0200)]
Add support for CPU cache specification

This patch introduces

    <cache level='N' mode='emulate'/>
    <cache mode='passthrough'/>
    <cache mode='disable'/>

sub element of /domain/cpu. Currently only a single <cache> element is
allowed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoconf: Rename mode parameter in virCPUDefParseXML
Jiri Denemark [Mon, 24 Apr 2017 13:38:41 +0000 (15:38 +0200)]
conf: Rename mode parameter in virCPUDefParseXML

The type of this parameter is virCPUType so calling it 'mode' is pretty
strange, 'type' is a much better name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Report VIR_DOMAIN_JOB_OPERATION
Jiri Denemark [Wed, 26 Apr 2017 10:00:09 +0000 (12:00 +0200)]
qemu: Report VIR_DOMAIN_JOB_OPERATION

Not all async jobs are visible via virDomainGetJobStats (either they are
too fast or getting the stats is not allowed during the job), but
forcing all of them to advertise the operation is easier than hunting
the jobs for which fetching statistics is allowed. And we won't need to
think about this when we add support for getting stats for more jobs.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoAdd VIR_DOMAIN_JOB_OPERATION typed parameter
Jiri Denemark [Wed, 26 Apr 2017 09:59:59 +0000 (11:59 +0200)]
Add VIR_DOMAIN_JOB_OPERATION typed parameter

The parameter is reported by virDomainGetJobStats API and
VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event and it can be used to identify
the operation (migration, snapshot, ...) to which the reported
statistics belong.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Remove extra messages for vhost-scsi hotplug
Eric Farman [Wed, 26 Apr 2017 21:10:01 +0000 (17:10 -0400)]
qemu: Remove extra messages for vhost-scsi hotplug

As with virtio-scsi, the "internal error" messages after
preparing a vhost-scsi hostdev overwrites more meaningful
error messages deeper in the callchain.  Remove it too.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
8 years agoqemu: Remove extra messages from virtio-scsi hotplug
Eric Farman [Wed, 26 Apr 2017 21:10:00 +0000 (17:10 -0400)]
qemu: Remove extra messages from virtio-scsi hotplug

I tried to attach a SCSI LUN to two different guests, and forgot
to specify "shareable" in the hostdev XML.  Attaching the device
to the second guest failed, but the message was not helpful in
telling me what I was doing wrong:

  $ cat scsi_scratch_disk.xml
    <hostdev mode='subsystem' type='scsi'>
      <source>
        <adapter name='scsi_host3'/>
        <address bus='0' target='15' unit='1074151456'/>
      </source>
    </hostdev>

  $ virsh attach-device dasd_sles_d99c scsi_scratch_disk.xml
  Device attached successfully

  $ virsh attach-device dasd_fedora_0e1e scsi_scratch_disk.xml
  error: Failed to attach device from scsi_scratch_disk.xml
  error: internal error: Unable to prepare scsi hostdev: scsi_host3:0:15:1074151456

I eventually discovered my error, but thought it was weird that
Libvirt doesn't provide something more helpful in this case.
Looking over the code we had just gone through, I commented out
the "internal error" message, and got something more useful:

  $ virsh attach-device dasd_fedora_0e1e scsi_scratch_disk.xml
  error: Failed to attach device from scsi_scratch_disk.xml
  error: Requested operation is not valid: SCSI device 3:0:15:1074151456 is already in use by other domain(s) as 'non-shareable'

Looking over the error paths here, we seem to issue better
messages deeper in the callchain so these "internal error"
messages overwrite any of them.  Remove them, so that the
more detailed errors are seen.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
8 years agoqemu: Check return code from qemuHostdevPrepareSCSIDevices
Eric Farman [Wed, 26 Apr 2017 21:09:59 +0000 (17:09 -0400)]
qemu: Check return code from qemuHostdevPrepareSCSIDevices

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
8 years agoqemu: migration: fix race on cancelling drive mirror
Nikolay Shirokovskiy [Fri, 7 Apr 2017 11:06:25 +0000 (14:06 +0300)]
qemu: migration: fix race on cancelling drive mirror

0feebab2 adds calling qemuBlockNodeNamesDetect for completed job
on updating block jobs. This affects cancelling drive mirror logic as
this function drops vm lock. Now we have to recheck all disks
before the disk with the completed block job before going
to wait for block job events.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: take current async job into account in qemuBlockNodeNamesDetect
Nikolay Shirokovskiy [Fri, 7 Apr 2017 11:06:24 +0000 (14:06 +0300)]
qemu: take current async job into account in qemuBlockNodeNamesDetect

Becase it can be called during migration out (namely on cancelling
blockjobs).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: numa: Don't return automatic nodeset for inactive domain
Peter Krempa [Wed, 26 Apr 2017 07:01:30 +0000 (09:01 +0200)]
qemu: numa: Don't return automatic nodeset for inactive domain

qemuDomainGetNumaParameters would return the automatic nodeset even for
the persistent config if the domain was running. This is incorrect since
the automatic nodeset will be re-queried upon starting the vm.

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

8 years agolib: Fix c99 style comments
Michal Privoznik [Thu, 27 Apr 2017 06:47:19 +0000 (08:47 +0200)]
lib: Fix c99 style comments

We prefer c89 style of comments.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Properly reset non-p2p migration
Jiri Denemark [Wed, 26 Apr 2017 19:46:28 +0000 (21:46 +0200)]
qemu: Properly reset non-p2p migration

While peer-to-peer migration enters the Confirm phase even if the
Perform phase fails, the client which initiated a non-p2p migration will
never call virDomainMigrateConfirm* API if the Perform phase failed.
Thus we need to explicitly reset migration before reporting a failure
from the Perform phase API.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoutil: Drop unused var @errbuf from virPCIGetDeviceAddressFromSysfsLink
Wang King [Thu, 27 Apr 2017 01:52:52 +0000 (09:52 +0800)]
util: Drop unused var @errbuf from virPCIGetDeviceAddressFromSysfsLink

Commit @a7035662 forgot to remove it when doing a refactor.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agolocking: Add support for sanlock_strerror
Jiri Denemark [Fri, 31 Mar 2017 19:42:22 +0000 (21:42 +0200)]
locking: Add support for sanlock_strerror

The recently added sanlock_strerror function can be used to translate
sanlock's numeric errors into human readable strings.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Ignore missing query-migrate-parameters
Jiri Denemark [Wed, 26 Apr 2017 21:18:35 +0000 (23:18 +0200)]
qemu: Ignore missing query-migrate-parameters

Migration with old QEMU which does not support query-migrate-parameters
would fail because the QMP command is called unconditionally since the
introduction of TLS migration. Previously it was only called if the user
explicitly requested a feature which uses QEMU migration parameters. And
even then the situation was not ideal, instead of reporting an
unsupported feature we'd just complain about missing QMP command.

Trivially no migration parameters are supported when
query-migrate-parameters QMP command is missing. There's no need to
report an error if it is missing, the callers will report better error
if needed.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotests: update QEMU 2.9.0 caps data to final version
Pavel Hrdina [Wed, 26 Apr 2017 17:19:50 +0000 (19:19 +0200)]
tests: update QEMU 2.9.0 caps data to final version

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agosecret: Generate configDir during driver initialization
John Ferlan [Wed, 19 Apr 2017 20:40:45 +0000 (16:40 -0400)]
secret: Generate configDir during driver initialization

Rather than waiting for the first save to fail, let's generate the
directory with the correct privs during initialization.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Combine virSecretObjListAdd with Locked function
John Ferlan [Thu, 20 Apr 2017 11:33:26 +0000 (07:33 -0400)]
secret: Combine virSecretObjListAdd with Locked function

There's no need to separate, so just have one.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Split apart NumOfSecrets and GetUUIDs callback function
John Ferlan [Mon, 3 Apr 2017 13:03:47 +0000 (09:03 -0400)]
secret: Split apart NumOfSecrets and GetUUIDs callback function

Rather than overloading one function - split apart the logic to have
separate interfaces and local/private structures to manage the data
for which the helper is collecting.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Rename 'filter' to 'aclfilter'
John Ferlan [Tue, 25 Apr 2017 15:22:09 +0000 (11:22 -0400)]
secret: Rename 'filter' to 'aclfilter'

Makes it a bit more clear what it is.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Change variable names for list traversals
John Ferlan [Wed, 19 Apr 2017 12:34:04 +0000 (08:34 -0400)]
secret: Change variable names for list traversals

Rather than 'nuuids' it should be 'maxuuids' and rather than 'got'
it should be 'nuuids'.  Alter the logic of the list traversal to
utilize those names.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Alter cleanup path for virSecretObjListGetUUIDs
John Ferlan [Tue, 25 Apr 2017 13:51:29 +0000 (09:51 -0400)]
secret: Alter cleanup path for virSecretObjListGetUUIDs

Rather than using "ret = -1" and cleanup processing, alter the return
path on failure to goto error and then just return the data.got.

In the error path, we no longer check for ret < 0, we just can free
anything added to the array and return -1 directly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Use virSecretDefPtr rather than deref from virSecretObjPtr
John Ferlan [Mon, 3 Apr 2017 12:11:32 +0000 (08:11 -0400)]
secret: Use virSecretDefPtr rather than deref from virSecretObjPtr

Rather than dereferencing obj->def->X, create a local 'def' variable
that will dereference the def and use directly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Use consistent naming for variables
John Ferlan [Sat, 1 Apr 2017 15:46:36 +0000 (11:46 -0400)]
secret: Use consistent naming for variables

When processing a virSecretPtr use 'secret' as a variable name.

When processing a virSecretObjPtr use 'obj' as a variable name.

When processing a virSecretDefPtr use 'def' as a variable name,
unless a distinction needs to be made with a 'newdef' such as
virSecretObjListAddLocked (which also used the VIR_STEAL_PTR macro
for the configFile and base64File).

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Add NULL obj check to virSecretObjListRemove
John Ferlan [Tue, 25 Apr 2017 13:17:22 +0000 (09:17 -0400)]
secret: Add NULL obj check to virSecretObjListRemove

Rather than have the caller check if !obj before calling, just check
in the function for !obj and return.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agosecret: Make some virSecretObj* functions static
John Ferlan [Wed, 5 Apr 2017 20:58:32 +0000 (16:58 -0400)]
secret: Make some virSecretObj* functions static

Make various virSecretObjList*Locked functions static and make
virSecretObjNew static since they're only called within virtsecretobj.c.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonwfilter: Move save of config until after successful assign
John Ferlan [Thu, 20 Apr 2017 15:51:22 +0000 (11:51 -0400)]
nwfilter: Move save of config until after successful assign

Only save the config when using a generated UUID if we were able to
create an object for the def. There could have been "other reasons"
for the assignment to fail, so saving the config could be incorrect.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonwfilter: Move creation of configDir to driver initialization
John Ferlan [Wed, 19 Apr 2017 20:20:27 +0000 (16:20 -0400)]
nwfilter: Move creation of configDir to driver initialization

Rather than "wait" for the first config file to be created, force creation
of the configDir during driver state initialization.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonwfilter: Replace virNWFilterSaveDef with virNWFilterSaveConfig
John Ferlan [Wed, 19 Apr 2017 18:19:41 +0000 (14:19 -0400)]
nwfilter: Replace virNWFilterSaveDef with virNWFilterSaveConfig

Essentially virNWFilterSaveDef executed in a different order the same
sequence of calls, so let's just make one point of reference.

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