]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agonews: Add logical overwrite
John Ferlan [Mon, 27 Mar 2017 16:52:32 +0000 (12:52 -0400)]
news: Add logical overwrite

8 years agological: Need to overwrite/clear more than just first 512 bytes
John Ferlan [Fri, 24 Mar 2017 16:25:27 +0000 (12:25 -0400)]
logical: Need to overwrite/clear more than just first 512 bytes

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

As it turns out some file headers (e.g. ext4) may be larger/longer than
the 512 bytes of zeros being written prior to a pvcreate, so let's write
out 2048 bytes similar to how the pvcreate sources would peek at the first
4 sectors of the device.

Make sure there is at enough bytes on the device to clear before doing
doing the clear - just to be sure.

8 years agoutil: Remove NONNULL from virHostdevReAttachMediatedDevices
John Ferlan [Mon, 27 Mar 2017 15:25:20 +0000 (11:25 -0400)]
util: Remove NONNULL from virHostdevReAttachMediatedDevices

Causes build failure when enabling static analysis

8 years agonews: Add <change> lost in merge
John Ferlan [Mon, 27 Mar 2017 15:20:58 +0000 (11:20 -0400)]
news: Add <change> lost in merge

Ensure to insert </change> <change> between items - lost during merge
resolution.

8 years agonetwork: better validation of devices in hostdev network pool
Laine Stump [Sat, 25 Mar 2017 18:00:13 +0000 (14:00 -0400)]
network: better validation of devices in hostdev network pool

This adds a few validations to the devices listed for a hostdev network:

* devices must be listed by PCI address, not by netdev name

* listing a device by PCI address is valid only for hostdev networks, not
  for other types of network (e.g. macvtap passthrough).

* each device in a hostdev pool must be an SR-IOV VF

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

8 years agoExpose Linux symbols only on Linux
Martin Kletzander [Mon, 27 Mar 2017 15:11:49 +0000 (17:11 +0200)]
Expose Linux symbols only on Linux

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirhostcpu: Make only defined symbols available
Martin Kletzander [Mon, 27 Mar 2017 14:15:45 +0000 (16:15 +0200)]
virhostcpu: Make only defined symbols available

That way you get the error from the compiler before the linker.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirhostcpu: Expose virHostCPUGetOnline on non-Linux
Martin Kletzander [Mon, 27 Mar 2017 14:16:43 +0000 (16:16 +0200)]
virhostcpu: Expose virHostCPUGetOnline on non-Linux

Previously, this function must've been called only on Linux in order
to fail gracefully.  That lead to #ifdef mess in callers, so the
function was redesigned so it failed gracefully on non-existing
files.  However that commit forgot to define the function outside the
__linux__ ifdef, it broke non-Linux builds.

Caused by c67e04e25fa58104e0fae41f5b874a8067557073.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Properly dereference cpus pointer in virnumamock.c
Martin Kletzander [Mon, 27 Mar 2017 13:47:58 +0000 (15:47 +0200)]
tests: Properly dereference cpus pointer in virnumamock.c

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirsh: reject more negative numbers
Ján Tomko [Mon, 27 Mar 2017 12:17:42 +0000 (14:17 +0200)]
virsh: reject more negative numbers

Be more positive and reject negative numbers where we don't
allow them by using the virStrToLong variants with 'p'.

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

8 years agostorage: reject negative capacity
Ján Tomko [Mon, 27 Mar 2017 12:33:16 +0000 (14:33 +0200)]
storage: reject negative capacity

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

8 years agobuild: Fix syntax check in VPATH
Jiri Denemark [Mon, 27 Mar 2017 14:48:19 +0000 (16:48 +0200)]
build: Fix syntax check in VPATH

Matching the beginning of a path in syntax check does not work because
each path is enriched with a prefix of the source tree.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agobuild: Fix sc_prohibit_exit_in_tests syntax check
Jiri Denemark [Mon, 27 Mar 2017 14:46:12 +0000 (16:46 +0200)]
build: Fix sc_prohibit_exit_in_tests syntax check

This check makes sense only in *.c files.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Add tests for virCPUUpdateLive API
Jiri Denemark [Thu, 16 Mar 2017 11:26:30 +0000 (12:26 +0100)]
cputest: Add tests for virCPUUpdateLive API

The test takes

  x86-cpuid-Something-guest.xml CPU (the CPU libvirt would use for
    host-model on a CPU described by x86_64-cpuid-Something.xml without
    talking to QEMU about what it supports on the host)

and updates it according to CPUID data from QEMU:

  x86_64-cpuid-Something-enabled.xml (reported as "feature-words"
    property of the CPU device)

and

  x86_64-cpuid-Something-disabled.xml (reported as "filtered-features"
    property of the CPU device).

The result is compared to

  x86_64-cpuid-Something-json.xml (the CPU libvirt would use as
    host-model based on the reply from query-cpu-model-expansion).

The comparison is a bit tricky because the *-json.xml CPU contains fewer
disabled features. Only the features which are included in the base CPU
model, but listed as disabled in *.json will be disabled in *-json.xml.
The CPU computed by virCPUUpdateLive from the test data will list all
features present in the host's CPUID data and not enabled in *.json as
disabled. The cpuTestUpdateLiveCompare function checks that the computed
and expected sets of enabled features match.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Disable "cmt" feature unknown to QEMU
Jiri Denemark [Fri, 17 Mar 2017 10:46:19 +0000 (11:46 +0100)]
cputest: Disable "cmt" feature unknown to QEMU

All CPU features which QEMU does not know about but libvirt knows them
(currently "cmt" is the only one) are implicitly disabled by QEMU and
should be present in x86_64-cpuid-*-disabled.xml.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Disable TSX on broken models
Jiri Denemark [Fri, 17 Mar 2017 10:29:02 +0000 (11:29 +0100)]
cputest: Disable TSX on broken models

Commit v3.1.0-26-gd60012b4e started filtering hle and rtm features from
broken Intel Haswell CPUs. QEMU implemented similar functionality and
thus it doesn't report rtm and hle features as enabled for Core i5-4670T
CPU anymore.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Generate data for virCPUUpdateLive
Jiri Denemark [Thu, 16 Mar 2017 11:26:05 +0000 (12:26 +0100)]
cputest: Generate data for virCPUUpdateLive

Generated with

    (cd tests/cputestdata; ./cpu-cpuid.py diff x86_64-cpuid-*.json)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Add "diff" command to cpu-cpuid.py
Jiri Denemark [Thu, 16 Mar 2017 11:25:30 +0000 (12:25 +0100)]
cputest: Add "diff" command to cpu-cpuid.py

The new command can be used to generate test data for virCPUUpdateLive.

When "cpu-cpuid.py diff x86-cpuid-Something.json" is run, it reads raw
CPUID data stored in x86-cpuid-Something.xml and CPUID data from QEMU
stored in x86-cpuid-Something.json to produce two more CPUID files:
x86-cpuid-Something-enabled.xml and x86-cpuid-Something-disabled.xml.

- x86-cpuid-Something-enabled.xml will contain CPUID bits present in
    x86-cpuid-Something.json (i.e., enabled by QEMU for the "host" CPU)

- x86-cpuid-Something-disabled.xml will contain all CPUID bits from
    x86-cpuid-Something.xml which are not present in
    x86-cpuid-Something.json (i.e., CPUID bits which the host CPU
    supports, but QEMU does not enable them for the "host" CPU)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Add cpuidLeaf helper to cpu-cpuid.py
Jiri Denemark [Wed, 15 Mar 2017 13:29:30 +0000 (14:29 +0100)]
cputest: Add cpuidLeaf helper to cpu-cpuid.py

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Add cpuidIsSet helper to cpu-cpuid.py
Jiri Denemark [Wed, 15 Mar 2017 13:21:48 +0000 (14:21 +0100)]
cputest: Add cpuidIsSet helper to cpu-cpuid.py

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Rename cpu-convert.py script as cpu-cpuid.py
Jiri Denemark [Wed, 15 Mar 2017 12:16:37 +0000 (13:16 +0100)]
cputest: Rename cpu-convert.py script as cpu-cpuid.py

The new script is going to be more general and the original
functionality can be requested by "cpu-cpuid.py convert".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocputest: Move instantiation of JSONDecoder in cpu-convert.py
Jiri Denemark [Wed, 15 Mar 2017 12:09:21 +0000 (13:09 +0100)]
cputest: Move instantiation of JSONDecoder in cpu-convert.py

Let's make the object local to the parseFeatureWords function which uses
it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Do not pass virConnectBaselineCPUFlags to cpuBaseline
Jiri Denemark [Fri, 17 Mar 2017 14:58:07 +0000 (15:58 +0100)]
cpu: Do not pass virConnectBaselineCPUFlags to cpuBaseline

The public API flags are handled by the cpuBaselineXML wrapper. The
internal cpuBaseline API only needs to know whether it is supposed to
drop non-migratable features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Move feature expansion out of cpuBaseline
Jiri Denemark [Fri, 17 Mar 2017 14:57:47 +0000 (15:57 +0100)]
cpu: Move feature expansion out of cpuBaseline

cpuBaseline is responsible for computing a baseline CPU while feature
expansion is done by virCPUExpandFeatures. The cpuBaselineXML wrapper
(used by hypervisor drivers to implement virConnectBaselineCPU API)
calls cpuBaseline followed by virCPUExpandFeatures if requested by
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES flag.

The features in the three changed test files had to be sorted using
"sort -k 3" because virCPUExpandFeatures returns a sorted list of
features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Drop unused flags from cpuArchDecode
Jiri Denemark [Thu, 16 Mar 2017 13:03:09 +0000 (14:03 +0100)]
cpu: Drop unused flags from cpuArchDecode

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Introduce virCPUExpandFeatures
Jiri Denemark [Thu, 16 Mar 2017 11:23:50 +0000 (12:23 +0100)]
cpu: Introduce virCPUExpandFeatures

Having to use cpuBaseline with VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
flag to expand CPU features is strange. Not to mention that cpuBaseline
can only expand host CPU definitions (i.e., it completely ignores
feature policies). The new virCPUExpandFeatures API is designed to work
with both host and guest CPU definitions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_conf: Introduce virCPUDefFreeFeatures
Jiri Denemark [Thu, 16 Mar 2017 11:21:58 +0000 (12:21 +0100)]
cpu_conf: Introduce virCPUDefFreeFeatures

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodocs: make interface start mode element optional
Laine Stump [Mon, 27 Mar 2017 04:40:18 +0000 (00:40 -0400)]
docs: make interface start mode element optional

This brings the libvirt version of this RNG file in line with the same
file in netcf (as soon as the corresponding patch there is ACKed and
pushed).

There's no reason to require it when defining an interface (the config
option it corresponds to is optional), and it isn't even output in the
status of an interface.

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

8 years agoconf: validate that PCI controller index is < 256
Laine Stump [Mon, 27 Mar 2017 00:47:17 +0000 (20:47 -0400)]
conf: validate that PCI controller index is < 256

This is the maximum for many reasons, for starters because index ==
bus number, and a controller's bus number is 8 bits.

This incidentally resolves: https://bugzilla.redhat.com/1329090

8 years agoutil: rename virHostdevNetConfigRestore() to virHostdevRestoreNetConfig()
Laine Stump [Mon, 13 Mar 2017 23:07:02 +0000 (19:07 -0400)]
util: rename virHostdevNetConfigRestore() to virHostdevRestoreNetConfig()

8 years agoutil: log all setting of MAC addresses and vlan tags
Laine Stump [Sat, 11 Mar 2017 15:29:29 +0000 (10:29 -0500)]
util: log all setting of MAC addresses and vlan tags

Having this information available will make it easier to determine the
culprit when MAC or vlan tag appear to not be set, eg.:

  https://bugzilla.redhat.com/1364073

(This patch doesn't fix that bug, just makes it easier to diagnose)

8 years agoutil: try *really* hard to set the MAC address of an SRIOV VF
Laine Stump [Tue, 7 Mar 2017 19:24:37 +0000 (14:24 -0500)]
util: try *really* hard to set the MAC address of an SRIOV VF

If an SRIOV VF has previously been used for VFIO device assignment,
the "admin MAC" that is stored in the PF driver's table of VF info
will have been set to the MAC address that the virtual machine wanted
the device to have. Setting the admin MAC for a VF also sets a flag in
the PF that is loosely called the "administratively set" flag. Once
that flag is set, it is no longer possible for the net driver of the
VF (either on the host or in a virtual machine) to directly set the
VF's MAC again; this flag isn't reset until the *PF* driver is
restarted, and that requires taking *all* VFs offline, so it's not
really feasible to do.

If the same SRIOV VF is later used for macvtap passthrough mode, the
VF's MAC address must be set, but normally we don't unbind the VF from
its host net driver (since we actually need the host net driver in
this case). Since setting the VF MAC directly will fail, in the past
"we" ("I") had tried to fix the problem by simply setting the admin MAC
(via the PF) instead. This *appeared* to work (and might have at one
time, due to promiscuous mode being turned on somewhere or something),
but it currently creates a non-working interface because only the
value for admin MAC is set to the desired value, *not* the actual MAC
that the VF is using.

Earlier patches in this series reverted that behavior, so that we once
again set the MAC of the VF itself for macvtap passthrough operation,
not the admin MAC. But that brings back the original bug - if the
interface has been used for VFIO device assignment, you can no longer
use it for macvtap passthrough.

This patch solves that problem by noticing when virNetDevSetMAC()
fails for a VF, and in that case it sets the desired MAC to the admin
MAC via the PF, then "bounces" the VF driver (by unbinding and the
immediately rebinding it to the VF). This causes the VF's MAC to be
reinitialized from the admin MAC, and everybody is happy (until the
*next* time someone wants to set the VF's MAC address, since the
"administratively set" bit is still turned on).

8 years agoutil: if setting admin MAC to 00:00:00:00:00:00 fails, try 02:00:00:00:00:00
Laine Stump [Mon, 6 Mar 2017 18:59:29 +0000 (13:59 -0500)]
util: if setting admin MAC to 00:00:00:00:00:00 fails, try 02:00:00:00:00:00

Some PF drivers allow setting the admin MAC (that is the MAC address
that the VF will be initialized to the next time the VF's driver is
loaded) to 00:00:00:00:00:00, and some don't. Multiple drivers
initialize the admin MACs to all 0, but don't allow setting it to that
very same value. It has been an uphill battle convincing the driver
people that it's reasonable to expect The argument that's used is
that an all 0 device MAC address on a device is invalid; however, from
an outsider's point of view, when the admin MAC is set to 0 at the
time the VF driver is loaded, the VF's MAC is *not* set to 0, but to a
random non-0 value. But that's beside the point - even if I could
convince one or two SRIOV driver maintainers to permit setting the
admin MAC to 0, there are still several other drivers.

So rather than fighting that losing battle, this patch checks for a
failure to set the admin MAC due to an all 0 value, and retries it
with 02:00:00:00:00:00. That won't result in a random value being set
in the VF MAC at next VF driver init, but that's okay, because we
always want to set a specific value anyway. Rather, the "almost 0"
setting makes it easy to visually detect from the output of "ip link
show" which VFs are currently in use and which are free.

8 years agoutil: remove unused functions from virnetdev.c
Laine Stump [Mon, 6 Mar 2017 15:01:02 +0000 (10:01 -0500)]
util: remove unused functions from virnetdev.c

The global functions virNetDevReplaceMacAddress(),
virNetDevReplaceNetConfig(), virNetDevRestoreMacAddress(), and
virNetDevRestoreNetConfig() are no longer used, as their functionality
has been replaced by virNetDev(Save|Read|Set)NetConfig().

The static functions virNetDevReplaceVfConfig() and
virNetDevRestoreVfConfig() were only used by the above-named global
functions that were removed.

8 years agoutil: after hostdev assignment, restore VF MAC address via setting admin MAC
Laine Stump [Mon, 6 Mar 2017 14:36:40 +0000 (09:36 -0500)]
util: after hostdev assignment, restore VF MAC address via setting admin MAC

It takes longer to explain this than to fix it...

In the past we weren't able to save the VF's own MAC address *at all*
when using it for hostdev assignment, because we had already unbound
the VF from the host net driver prior to saving its config. With the
previous patch, that problem has been solved, so we now have the VF's
MAC address saved and can move on to the *next* problem, which is twofold:

1) during teardown we restore the config before we've re-bound, so the
   VF doesn't have a net driver, and thus we can't set its MAC address
   directly.

2) even if we delay restoring the config until the VF is bound to a
   net driver, the request to set its MAC address would fail, since
   (during device setup) we had set the "admin MAC" for the VF via an
   RTM_SETLINK to the PF - once you've set the admin MAC for a VF, the
   VF driver (either on host or on guest) is not allowed to change the
   VF's MAC address "forever" (well, until you reload the PF driver,
   but that requires destroying and recreating every single VF, which
   isn't something you can require).

The solution is to keep the restoration of config at the same place,
but to set the *admin MAC* to the address you want the VF to have -
when the VF net driver is later initialized (as a part of re-binding
to the VF net driver) its MAC will be initialized to the current value
of the admin MAC.

8 years agoutil: save hostdev network device config before unbinding from host driver
Laine Stump [Tue, 28 Feb 2017 21:44:26 +0000 (16:44 -0500)]
util: save hostdev network device config before unbinding from host driver

In order to properly restore the original state of an SRIOV VF when
we're finished with it, we need to save the MAC address of the VF
itself (not just the admin MAC address for the VF that is stored in
the PF). But that can only be done when the VF is still bound to the
host's netdev driver, and we have always done the saving of device
config after the VF is already bound to vfio-pci. This patch prepares
us for adding a save of the VF's MAC by calling the function that
saves netconfig earlier in the device preparation, before we've
unbound it from the host netdev driver.

8 years agoutil: replace virHostdevNetConfigReplace with ...(Save|Set)NetConfig()
Laine Stump [Tue, 28 Feb 2017 18:47:12 +0000 (13:47 -0500)]
util: replace virHostdevNetConfigReplace with ...(Save|Set)NetConfig()

These two operations will need to be separated so that saving of the
original config is done before detaching the host net driver, and
setting the new config is done after attaching vfio-pci. This patch
splits the single function into two, but for now calls them together
(to make bisecting easier if there is a regression).

8 years agoutil: use new virNetDev*NetConfig() functions for hostdev setup/teardown
Laine Stump [Mon, 6 Mar 2017 01:28:08 +0000 (20:28 -0500)]
util: use new virNetDev*NetConfig() functions for hostdev setup/teardown

virHostdevNetConfigReplace() and virHostdevNetConfigRestore() are
modified to use the new virNetDev*NetConfig() functions.

Note that due to the VF's original MAC addresses being saved after it
has already been un-bound from the host net driver, the actual current
VF MAC address won't be saved (because it no longer exists) - only the
"admin MAC" will be saved. This reflects existing behavior that will
be fixed in an upcoming patch.

8 years agoutil: use new virNetDev*NetConfig() functions for macvtap setup/teardown
Laine Stump [Sun, 5 Mar 2017 22:43:39 +0000 (17:43 -0500)]
util: use new virNetDev*NetConfig() functions for macvtap setup/teardown

This patch modifies the macvtap passthrough setup to use
virNetDevSaveNetConfig()+virNetDevSetConfig() instead of
virNetDevReplaceNetConfig() or virNetDevReplaceMacAddress(), and the
teardown to use virNetDevReadNetConfig()+virNetDevSetConfig() instead
of virNetDevRestoreNetConfig() or virNetDevRestoreMacAddress().

Since the older functions only saved/restored the admin MAC and vlan
tag (which is incorrect) and the new functions save/restore the VF's
own MAC address and vlan tag (correct), this actually fixes a bug
(which was introduced by commit cb3fe38c7, which was itself supposed
to be a fix for https://bugzilla.redhat.com/1113474 ).

The downside to this patch is that it causes an *apparent* regression
in that bug (because there will once again be an error reported if the
interface had previously been used for VFIO device assignment), but in
reality, the code hasn't been working for *any* case before this
current patch (at least not with any recent kernel). Anyway, that
"regression" will be fixed with an upcoming patch that fixes it the
*right* way.

8 years agoutil: new functions virNetDev(Save|Read|Set)NetConfig()
Laine Stump [Mon, 20 Feb 2017 21:14:53 +0000 (16:14 -0500)]
util: new functions virNetDev(Save|Read|Set)NetConfig()

These three functions are destined to replace
virNetDev(Replace|Restore)NetConfig() and
virNetDev(Replace|Restore)MacAddress(), which both do the save and set
together as a single step. We need to separate the save, read, and set
steps because there will be situations where we need to do something
else in between (in particular, we will need to rebind a VF's driver
after save but before set).

This patch creates the new functions, but doesn't call them - that
will come in a subsequent patch. Note that the new functions to
read/write the file that stores the original network config now uses
JSON rather than plaintext (it still recognizes the old format as well
though, so it won't get confused during an upgrade).

8 years agoqemu: Log additional data from hyperv crash notifier
Peter Krempa [Mon, 20 Mar 2017 16:55:56 +0000 (17:55 +0100)]
qemu: Log additional data from hyperv crash notifier

The hyperv panic notifier reports additional data in form of 5 registers
that are reported in the crash event from qemu. Log them into the VM log
file and report them as a warning so that admins can see the cause of
crash of their windows VMs.

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

8 years agoqemu: monitor: Extract additional info from GUEST_PANICKED event
Peter Krempa [Mon, 20 Mar 2017 13:35:33 +0000 (14:35 +0100)]
qemu: monitor: Extract additional info from GUEST_PANICKED event

For certain kinds of panic notifiers (notably hyper-v) qemu is able to
report some data regarding the crash passed from the guest.

Make the data accessible to the callback in qemu so that it can be
processed further.

8 years agoqemu: driver: Fix formatting in processGuestPanicEvent
Peter Krempa [Wed, 1 Mar 2017 17:18:43 +0000 (18:18 +0100)]
qemu: driver: Fix formatting in processGuestPanicEvent

8 years agoqemu: driver: Remove useless forward declarations
Peter Krempa [Mon, 20 Mar 2017 13:39:33 +0000 (14:39 +0100)]
qemu: driver: Remove useless forward declarations

8 years agonews: Update our NEWS file about addition of the mdevs
Erik Skultety [Mon, 27 Mar 2017 13:42:06 +0000 (15:42 +0200)]
news: Update our NEWS file about addition of the mdevs

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agodocs: Document the new hostdev type 'mdev'
Erik Skultety [Fri, 3 Feb 2017 10:02:07 +0000 (11:02 +0100)]
docs: Document the new hostdev type 'mdev'

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agotest: Add some test cases for our test suite regarding the mdevs
Erik Skultety [Sat, 7 Jan 2017 12:27:34 +0000 (13:27 +0100)]
test: Add some test cases for our test suite regarding the mdevs

For now, these only cover the unmanaged, i.e. user pre-created devices.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Format mdevs on qemu command line
Erik Skultety [Fri, 3 Feb 2017 13:24:14 +0000 (14:24 +0100)]
qemu: Format mdevs on qemu command line

Format the mediated devices on the qemu command line as
-device vfio-pci,sysfsdev='/path/to/device/in/syfs'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Bump the memory locking limit for mdevs as well
Erik Skultety [Thu, 16 Feb 2017 16:18:35 +0000 (17:18 +0100)]
qemu: Bump the memory locking limit for mdevs as well

Since mdevs are just another type of VFIO devices, we should increase
the memory locking limit the same way we do for VFIO PCI devices.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: cgroup: Adjust cgroups' logic to allow mediated devices
Erik Skultety [Fri, 3 Feb 2017 13:13:25 +0000 (14:13 +0100)]
qemu: cgroup: Adjust cgroups' logic to allow mediated devices

As goes for all the other hostdev device types, grant the qemu process
access to /dev/vfio/<mediated_device_iommu_group>.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agohostdev: Maintain a driver list of active mediated devices
Erik Skultety [Fri, 3 Feb 2017 13:04:59 +0000 (14:04 +0100)]
hostdev: Maintain a driver list of active mediated devices

Keep track of the assigned mediated devices the same way we do it for
the rest of hostdevs. Methods like 'Prepare', 'Update', and 'ReAttach'
are introduced by this patch.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Assign PCI addresses for mediated devices as well
Erik Skultety [Fri, 3 Feb 2017 12:43:48 +0000 (13:43 +0100)]
qemu: Assign PCI addresses for mediated devices as well

So far, the official support is for x86_64 arch guests so unless a
different device API than vfio-pci is available let's only turn on
support for PCI address assignment. Once a different device API is
introduced, we can enable another address type easily.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconf: Enable cold-plug of a mediated device
Erik Skultety [Fri, 3 Feb 2017 12:29:37 +0000 (13:29 +0100)]
conf: Enable cold-plug of a mediated device

This merely introduces virDomainHostdevMatchSubsysMediatedDev method that
is supposed to check whether device being cold-plugged does not already
exist in the domain configuration.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agosecurity: Enable labeling of vfio mediated devices
Erik Skultety [Fri, 3 Feb 2017 12:25:57 +0000 (13:25 +0100)]
security: Enable labeling of vfio mediated devices

This patch updates all of our security driver to start labeling the
VFIO IOMMU devices under /dev/vfio/ as well.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconf: Introduce new hostdev device type mdev
Erik Skultety [Tue, 31 Jan 2017 16:26:36 +0000 (17:26 +0100)]
conf: Introduce new hostdev device type mdev

A mediated device will be identified by a UUID (with 'model' now being
a mandatory <hostdev> attribute to represent the mediated device API) of
the user pre-created mediated device. We also need to make sure that if
user explicitly provides a guest address for a mdev device, the address
type will be matching the device API supported on that specific mediated
device and error out with an incorrect XML message.

The resulting device XML:
<devices>
  <hostdev mode='subsystem' type='mdev' model='vfio-pci'>
    <source>
      <address uuid='c2177883-f1bb-47f0-914d-32a22e3a8804'>
    </source>
  </hostdev>
</devices>

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoutil: Introduce new module virmdev
Erik Skultety [Wed, 22 Mar 2017 14:50:33 +0000 (15:50 +0100)]
util: Introduce new module virmdev

Beside creation, disposal, getter, and setter methods the module exports
methods to work with lists of mediated devices.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconf: Introduce virDomainHostdevDefPostParse
Erik Skultety [Tue, 14 Feb 2017 14:42:40 +0000 (15:42 +0100)]
conf: Introduce virDomainHostdevDefPostParse

Just to make the code a bit cleaner, move hostdev specific post parse
code to its own function just in case it grows in the future.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconf: hostdev: Introduce virDomainHostdevSubsysSCSIClear
Erik Skultety [Thu, 9 Mar 2017 09:25:47 +0000 (10:25 +0100)]
conf: hostdev: Introduce virDomainHostdevSubsysSCSIClear

Just a tiny wrapper over the SCSI def clearing logic to drop some
if-else branches from a switch, mainly because extending the switch in
the future would render the current code with branching less readable.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconf: hostdev: Enforce enum-in-switch compile-time checks
Erik Skultety [Thu, 9 Mar 2017 09:20:42 +0000 (10:20 +0100)]
conf: hostdev: Enforce enum-in-switch compile-time checks

Enforce virDomainHostdevSubsysType checking during compilation. Again,
one of a few spots in our code where we should enforce the typecast to
the enum type, thus not forgetting to update *all* switch occurrences
dealing with the give enum.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoutil: fix build on RHEL 6
Eric Blake [Mon, 27 Mar 2017 13:11:26 +0000 (08:11 -0500)]
util: fix build on RHEL 6

We keep forgetting that older setups don't like 'index':

  CC     util/libvirt_util_la-virsysinfo.lo
cc1: warnings being treated as errors
util/virstoragefile.c: In function 'virStorageSourceFindByNodeName':
util/virstoragefile.c:3804: error: declaration of 'index' shadows a global declaration [-Wshadow]
/usr/include/string.h:489: error: shadowed declaration is here [-Wshadow]

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agotests: Enhance vircaps2xml test
Martin Kletzander [Fri, 24 Mar 2017 18:37:50 +0000 (19:37 +0100)]
tests: Enhance vircaps2xml test

Instead of generating all of the capabilities, let's test more of our
code by probing sysfs data.  This test needs quite some mocking for
now, but it paves the road for more future enhancements (hugepages
probing, for example).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add virnumamock
Martin Kletzander [Thu, 23 Mar 2017 16:01:41 +0000 (17:01 +0100)]
tests: Add virnumamock

All mocked functions are related to numactl/virNuma and rely only on
virsysfs, so the paths they touch can be nicely controlled.  And
because it is so nicely self-contained NUMA mock, it is named
numamock (instead of naming it after the test that will use it first).

We need top level API mock because some APIs might call libnuma
directly, e.g. virNumaIsAvailable(), virNumaGetMaxNode().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add linux-caches sysfs entries for vircaps2xmltest
Martin Kletzander [Sat, 11 Mar 2017 13:15:03 +0000 (14:15 +0100)]
tests: Add linux-caches sysfs entries for vircaps2xmltest

Bit more test data, this time with complete info copied, mainly with
cache information, so we can easily add tests for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add sysfs node/cpu topology for the only vircaps2xml testcase
Martin Kletzander [Sat, 11 Mar 2017 13:13:15 +0000 (14:13 +0100)]
tests: Add sysfs node/cpu topology for the only vircaps2xml testcase

We'll stop generating the data on the fly, but rather test more of our
APIs.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoChange virQEMUCapsInitPages to virCapabilitiesInitPages
Martin Kletzander [Sat, 11 Mar 2017 15:32:13 +0000 (16:32 +0100)]
Change virQEMUCapsInitPages to virCapabilitiesInitPages

This way more drivers can utilize the functionality without copying
the code.  And we can therefore test it in one place for all of them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Fix naming in util/virnodesuspend
Martin Kletzander [Tue, 7 Mar 2017 09:44:06 +0000 (10:44 +0100)]
util: Fix naming in util/virnodesuspend

That file has only two exported files and each one of them has
different naming.  virNode is what all the other files use, so let's
use it.  It wasn't used before because the clash with public API
naming, so let's fix that by shortening the name (there is no other
private variant of it anyway).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoRemove src/nodeinfo
Martin Kletzander [Tue, 7 Mar 2017 09:40:15 +0000 (10:40 +0100)]
Remove src/nodeinfo

There is no "node driver" as there was before, drivers have to do
their own ACL checking anyway, so they all specify their functions and
nodeinfo is basically just extending conf/capablities.  Hence moving
the code to src/conf/ is the right way to go.

Also that way we can de-duplicate some code that is in virsysfs and/or
virhostcpu that got duplicated during the virhostcpu.c split.  And
Some cleanup is done throughout the changes, like adding the vir*
prefix etc.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoMove src/fdstream to src/util/virfdstream
Martin Kletzander [Tue, 7 Mar 2017 09:34:47 +0000 (10:34 +0100)]
Move src/fdstream to src/util/virfdstream

There is no reason for it not to be in the utils, all global symbols
under that file already have prefix vir* and there is no reason for it
to be part of DRIVER_SOURCES because that is just a leftover from
older days (pre-driver modules era, I believe).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Adapt virhostcpu to the new virsysfs
Martin Kletzander [Tue, 7 Mar 2017 14:11:22 +0000 (15:11 +0100)]
util: Adapt virhostcpu to the new virsysfs

While on that, drop support for kernels from RHEL-5 era (missing
cpu/present file).  Also add some useful functions and export them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Add virsysfs for handling sysfs files
Martin Kletzander [Tue, 7 Mar 2017 09:02:46 +0000 (10:02 +0100)]
util: Add virsysfs for handling sysfs files

By using this we are able to easily switch the sysfs path being
used (fake it).  This will not only help tests in the future but can
be also used from files where the code is duplicated currently.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Add cpu/{online,present} files for old tests
Martin Kletzander [Tue, 7 Mar 2017 09:24:54 +0000 (10:24 +0100)]
tests: Add cpu/{online,present} files for old tests

The functionality these tests partially relied on (scanning the cpu
directory for cpu[0-9]+ subdirectories) is going to be removed, so we
need additional files that are present on all non-medieval systems.
Removing all these tests would be an option but we would lose the
ability to test the topologies.  Even though we just extract number of
sockets/cores/threads from all these directory trees.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirfile: Add helpers for reading simple values
Martin Kletzander [Tue, 7 Mar 2017 09:36:54 +0000 (10:36 +0100)]
virfile: Add helpers for reading simple values

These helpers are doing just a read and covert the value, but they
properly size the read limit, handle additional whitespace characters,
and unify error reporting.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Remove some unneeded files
Martin Kletzander [Sat, 11 Mar 2017 13:39:06 +0000 (14:39 +0100)]
tests: Remove some unneeded files

We are not using them at all and the directories are missing bunch of
files already.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoopenvz: Ditch openvzGetNodeCPUs
Martin Kletzander [Sat, 11 Mar 2017 15:14:17 +0000 (16:14 +0100)]
openvz: Ditch openvzGetNodeCPUs

There is particular function for this, there is no need to build whole
nodeinfo for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoSeparate syms based on files they are defined in
Martin Kletzander [Tue, 7 Mar 2017 09:27:54 +0000 (10:27 +0100)]
Separate syms based on files they are defined in

Commits eaf18f4c2bf1 and 86dd9fac0f1d separated util/host{cpu,mem}
stuff from nodeinfo, but did not adjust the syms file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovz: Do not use magic constants when building capabilities
Martin Kletzander [Tue, 14 Mar 2017 13:28:45 +0000 (14:28 +0100)]
vz: Do not use magic constants when building capabilities

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotests: Fix indentation in virhostcputest
Martin Kletzander [Tue, 7 Mar 2017 09:18:06 +0000 (10:18 +0100)]
tests: Fix indentation in virhostcputest

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agosyms: Add one newline to make things consistent
Martin Kletzander [Tue, 7 Mar 2017 09:45:18 +0000 (10:45 +0100)]
syms: Add one newline to make things consistent

It is everywhere else.  I even remember one of our scripts failing if
the newline is missing, but it doesn't happen currently.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agocpu: Don't use prefixes for no reason
Martin Kletzander [Sat, 11 Mar 2017 16:09:48 +0000 (17:09 +0100)]
cpu: Don't use prefixes for no reason

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovmware: Fix some initialization problems
Martin Kletzander [Wed, 15 Mar 2017 08:10:12 +0000 (09:10 +0100)]
vmware: Fix some initialization problems

Don't leak guest if adding it to virCapabilities fails.  Also return
NULL and not pointer to free'd object with zero references in such
case.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoExpose virCapabilitiesFreeGuest
Martin Kletzander [Wed, 15 Mar 2017 12:01:13 +0000 (13:01 +0100)]
Expose virCapabilitiesFreeGuest

Guests are handled in callers, but if something goes wrong (when it
cannot be added to virCapabilities, for example), there's no way for
them to free it properly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoIntroduce virCPUProbeHost
Martin Kletzander [Wed, 15 Mar 2017 08:07:38 +0000 (09:07 +0100)]
Introduce virCPUProbeHost

Both QEMU and bhyve are using the same function for setting up the CPU
in virCapabilities, so de-duplicate it, save code and time, and help
other drivers adopt it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoAdd virNumaGetNodeCPUs to private syms
Martin Kletzander [Thu, 23 Mar 2017 16:02:27 +0000 (17:02 +0100)]
Add virNumaGetNodeCPUs to private syms

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoFix build with GCC's static analysis
Martin Kletzander [Mon, 27 Mar 2017 10:29:27 +0000 (12:29 +0200)]
Fix build with GCC's static analysis

STREQ_NULLABLE returns true if both parameters are NULL.  And that's
not what we want here.  We just want to skop comparing source nodes
that don't have that info set.  The function wouldn't make much sense
with nodeName == NULL, so we don't need to check that.  Moreover, the
function's declaration uses ATTRIBUDE_NONNULL for nodeName, which not
only means that function expects the parameter not to be NULL, but
actually tells the compiler that it can optimize out the NULL checks.
That way it could end up calling strcmp on NULL (either nodeformat or
nodebacking).  GCC figures this out if libvirt is compiled with
lv_cv_static_analysis=yes, unfortunately not everyone uses that.

Caused by cbc6d53513568c9c9613b3eaae1c8a8230fd6aab.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: stats: Display the block threshold size in bulk stats
Peter Krempa [Thu, 16 Mar 2017 13:37:56 +0000 (14:37 +0100)]
qemu: stats: Display the block threshold size in bulk stats

Management tools may want to check whether the threshold is still set if
they missed an event. Add the data to the bulk stats API where they can
also query the current backing size at the same time.

8 years agoqemu: block: Add code to fetch block node data by node name
Peter Krempa [Thu, 16 Mar 2017 11:30:16 +0000 (12:30 +0100)]
qemu: block: Add code to fetch block node data by node name

To allow updating stats based on the node name, add a helper function
that will fetch the required data from 'query-named-block-nodes' and
return it in hash table for easy lookup.

8 years agoutil: json: Make function to free JSON values in virHash universal
Peter Krempa [Thu, 16 Mar 2017 09:19:32 +0000 (10:19 +0100)]
util: json: Make function to free JSON values in virHash universal

Move the helper that frees JSON entries put into hash tables into the
JSON module so that it does not have to be reimplemented.

8 years agoqemu: block: Add code to detect node names when necessary
Peter Krempa [Wed, 15 Mar 2017 12:03:21 +0000 (13:03 +0100)]
qemu: block: Add code to detect node names when necessary

Detect the node names when setting block threshold and when reconnecting
or when they are cleared when a block job finishes. This operation will
become a no-op once we fully support node names.

8 years agoqemu: monitor: Extract the top level format node when querying disks
Peter Krempa [Thu, 23 Feb 2017 18:36:52 +0000 (19:36 +0100)]
qemu: monitor: Extract the top level format node when querying disks

To allow matching the node names gathered via 'query-named-block-nodes'
we need to query and then use the top level nodes from 'query-block'.
Add the data to the structure returned by qemuMonitorGetBlockInfo.

8 years agotests: qemumonitorjson: Test node name detection on networked storage
Peter Krempa [Tue, 14 Mar 2017 17:07:29 +0000 (18:07 +0100)]
tests: qemumonitorjson: Test node name detection on networked storage

8 years agotests: qemumonitorjson: Add relative image names for node name detection
Peter Krempa [Tue, 14 Mar 2017 15:20:47 +0000 (16:20 +0100)]
tests: qemumonitorjson: Add relative image names for node name detection

oVirt uses relative names with directories in them. Test such
configuration. Also tests a snapshot done with _REUSE_EXTERNAL and a
relative backing file pre-specified in the qcow2 metadata.

8 years agotests: qemumonitorjson: Add case for two disks sharing a backing image
Peter Krempa [Tue, 14 Mar 2017 14:02:11 +0000 (15:02 +0100)]
tests: qemumonitorjson: Add case for two disks sharing a backing image

Since we have to match the images by filename a common backing image
will break the detection process. Add a test case to see that the code
correctly did not continue the detection process.

8 years agotests: qemumonitorjson: Add long backing chain test case for node name detection
Peter Krempa [Mon, 13 Mar 2017 11:48:32 +0000 (12:48 +0100)]
tests: qemumonitorjson: Add long backing chain test case for node name detection

8 years agotests: qemumonitorjson: Add test case for node name detection code
Peter Krempa [Mon, 13 Mar 2017 11:47:46 +0000 (12:47 +0100)]
tests: qemumonitorjson: Add test case for node name detection code

The code is rather magic so a test case will help making sure that
everything works well. The first case is a simple backing chain.

8 years agoqemu: block: Add code to allow detection of auto-allocated node names
Peter Krempa [Mon, 13 Mar 2017 11:46:18 +0000 (12:46 +0100)]
qemu: block: Add code to allow detection of auto-allocated node names

qemu for some time already sets node names automatically for the block
nodes. This patch adds code that attempts a best-effort detection of the
node names for the backing chain from the output of
'query-named-block-nodes'. The only drawback is that the data provided
by qemu needs to be matched by the filename as seen by qemu and thus
if two disks share a single backing store file the detection won't work.

This will allow us to use qemu commands such as
'block-set-write-threshold' which only accepts node names.

In this patch only the detection code is added, it will be used later.

8 years agoqemu: monitor: Add monitor infrastructure for query-named-block-nodes
Peter Krempa [Fri, 24 Feb 2017 13:59:40 +0000 (14:59 +0100)]
qemu: monitor: Add monitor infrastructure for query-named-block-nodes

Add monitor tooling for calling query-named-block-nodes. The monitor
returns the data as the raw JSON array that is returned from the
monitor.

Unfortunately the logic to extract the node names for a complete backing
chain will be so complex that I won't be able to extract any meaningful
subset of the data in the monitor code.

8 years agoqemu: capabilities: add capability for query-named-block-nodes qmp cmd
Peter Krempa [Wed, 15 Mar 2017 16:21:48 +0000 (17:21 +0100)]
qemu: capabilities: add capability for query-named-block-nodes qmp cmd

8 years agoqemu: implement qemuDomainSetBlockThreshold
Peter Krempa [Thu, 23 Feb 2017 12:50:24 +0000 (13:50 +0100)]
qemu: implement qemuDomainSetBlockThreshold

Add code to call the appropriate monitor command and code to lookup the
given disk backing chain member.

8 years agoqemu: domain: Add helper to look up disk soruce by the backing store string
Peter Krempa [Thu, 23 Feb 2017 18:14:47 +0000 (19:14 +0100)]
qemu: domain: Add helper to look up disk soruce by the backing store string

8 years agovirsh: Implement 'domblkthreshold' command to call virDomainSetBlockThreshold
Peter Krempa [Thu, 23 Feb 2017 12:27:18 +0000 (13:27 +0100)]
virsh: Implement 'domblkthreshold' command to call virDomainSetBlockThreshold

Add a simple wrapper which will allow to set the threshold for
delivering the event.