]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

8 years agolib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
Peter Krempa [Thu, 23 Feb 2017 12:09:12 +0000 (13:09 +0100)]
lib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD

The new API can be used to configure the threshold when
VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD should be fired.

8 years agoqemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event
Peter Krempa [Wed, 22 Feb 2017 16:51:26 +0000 (17:51 +0100)]
qemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event

Bind it to qemu's BLOCK_WRITE_THRESHOLD event. Look up the disk by
nodename and construct the string to return.

8 years agoqemu: domain: Add helper to generate indexed backing store names
Peter Krempa [Thu, 23 Feb 2017 17:13:02 +0000 (18:13 +0100)]
qemu: domain: Add helper to generate indexed backing store names

The code is currently simple, but if we later add node names, it will be
necessary to generate the names based on the node name. Add a helper so
that there's a central point to fix once we add self-generated node
names.

8 years agoqemu: domain: Add helper to lookup disk by node name
Peter Krempa [Wed, 22 Feb 2017 16:51:05 +0000 (17:51 +0100)]
qemu: domain: Add helper to lookup disk by node name

Looks up a disk and its corresponding backing chain element by node
name.

8 years agoqemu: monitor: Add support for BLOCK_WRITE_THRESHOLD event
Peter Krempa [Wed, 22 Feb 2017 15:52:22 +0000 (16:52 +0100)]
qemu: monitor: Add support for BLOCK_WRITE_THRESHOLD event

The event is fired when a given block backend node (identified by the
node name) experiences a write beyond the bound set via
block-set-write-threshold QMP command. This wires up the monitor code to
extract the data and allow us receiving the events and the capability.

8 years agolib: Introduce event for tracking disk backing file write threshold
Peter Krempa [Tue, 21 Feb 2017 14:03:07 +0000 (15:03 +0100)]
lib: Introduce event for tracking disk backing file write threshold

When using thin provisioning, management tools need to resize the disk
in certain cases. To avoid having them to poll disk usage introduce an
event which will be fired when a given offset of the storage is written
by the hypervisor. Together with the API which will be added later, it
will allow registering thresholds for given storage backing volumes and
this event will then notify management if the threshold is exceeded.

8 years agoutil: storage: Add variables for node names into virStorageSource
Peter Krempa [Wed, 22 Feb 2017 15:20:00 +0000 (16:20 +0100)]
util: storage: Add variables for node names into virStorageSource

'nodeformat' should be used for strings which describe the storage
format object, and 'nodebacking' for the actual storage object itself.

8 years agoutil: storage: Split out useful bits of virStorageFileParseChainIndex
Peter Krempa [Thu, 23 Feb 2017 16:10:43 +0000 (17:10 +0100)]
util: storage: Split out useful bits of virStorageFileParseChainIndex

The function has very specific semantics. Split out the part that parses
the backing store specification string into a separate helper so that it
can be reused later while keeping the wrapper with existing semantics.

Note that virStorageFileParseChainIndex is pretty well covered by the
test suite.

8 years agoutil: buffer: Add API to set indentation level to a given value
Peter Krempa [Thu, 9 Mar 2017 16:02:19 +0000 (17:02 +0100)]
util: buffer: Add API to set indentation level to a given value

It will be useful to set indentation level to 0 after formatting a
nested structure rather than having to track the depth.

8 years agoqemu: driver: Don't call qemuDomainDetermineDiskChain on block jobs
Peter Krempa [Wed, 15 Mar 2017 16:10:41 +0000 (17:10 +0100)]
qemu: driver: Don't call qemuDomainDetermineDiskChain on block jobs

Our code calls it when starting or re-starting the domain or when
hotplugging the disk so there's nothing to be detected.

8 years agobhyve: add xhci tablet support
Roman Bogorodskiy [Mon, 20 Mar 2017 13:58:51 +0000 (17:58 +0400)]
bhyve: add xhci tablet support

Along with video and VNC support, bhyve has introduced USB tablet
support as an input device. This tablet is exposed to a guest
as a device on an XHCI controller.

At present, tablet is the only supported device on the XHCI controller
in bhyve, so to make things simple, it's allowed to only have a
single XHCI controller with a single tablet device.

In detail, this commit:

 - Introduces a new capability bit for XHCI support in bhyve
 - Adds an XHCI controller and tabled support with 1:1 mapping
   between them
 - Adds a couple of unit tests

8 years agobhyve: helper function to probe hypervisor caps
Roman Bogorodskiy [Sun, 19 Mar 2017 13:40:52 +0000 (17:40 +0400)]
bhyve: helper function to probe hypervisor caps

There are a number of functions in bhyve_capabilities.c that probe
hypervisor capabilities by executing the bhyve(1) binary with the
specific device arugment, checking error message (if any) and setting
proper capability bit. As those are extremely similar, move this logic
into a helper function and convert existing functions to use that.

8 years agodomaincapstest: add bhyve caps test
Roman Bogorodskiy [Sat, 18 Mar 2017 20:17:13 +0000 (00:17 +0400)]
domaincapstest: add bhyve caps test

 * Extract filling bhyve capabilities from virBhyveDomainCapsBuild()
   into a new function virBhyveDomainCapsFill() to make testing
   easier by not having to mock firmware directory listing and
   hypervisor capabilities probing
 * Also, just presence of the firmware files is not sufficient
   to enable os.loader.supported, hypervisor should support UEFI
   boot too
 * Add tests to domaincapstest for the main caps possible flows:
    - when UEFI bootrom is supported
    - when video (fbus) is supported
    - neither of above is supported

8 years agoschema: domaincaps: make machine element optional
Roman Bogorodskiy [Sun, 26 Mar 2017 14:35:14 +0000 (18:35 +0400)]
schema: domaincaps: make machine element optional

Commit df769041c made the 'machine' element in domaincaps
optional. Update the schema to reflect that.

8 years agoqemu: fix build with clang
Roman Bogorodskiy [Sun, 26 Mar 2017 04:29:49 +0000 (08:29 +0400)]
qemu: fix build with clang

qemuMigrationResetTLS() does not initialize 'ret' by default,
so when it jumps to 'cleanup' on error, the 'ret' variable will be
uninitialized, which clang complains about.

Set it to '-1' by default.

8 years agovirpci: fix build on non-Linux
Roman Bogorodskiy [Sat, 25 Mar 2017 13:12:42 +0000 (17:12 +0400)]
virpci: fix build on non-Linux

virPCIGetDeviceAddressFromSysfsLink() should return
virPCIDeviceAddressPtr, so return NULL in the stub instead of "-1".

8 years agodocs: Add news entry for Migration using TLS
John Ferlan [Sat, 18 Mar 2017 13:44:23 +0000 (09:44 -0400)]
docs: Add news entry for Migration using TLS

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Set up the migration TLS objects for source
John Ferlan [Thu, 16 Feb 2017 20:56:10 +0000 (15:56 -0500)]
qemu: Set up the migration TLS objects for source

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

If the migration flags indicate this migration will be using TLS,
then while we have connection in the Begin phase check and setup the
TLS environment that will be used by virMigrationRun during the Perform
phase for the source to configure TLS.

Processing adds an "-object tls-creds-x509,endpoint=client,..." and
possibly an "-object secret,..." to handle the passphrase response.

Then it sets the 'tls-creds' and possibly 'tls-hostname' migration
parameters.

The qemuMigrateCancel will clean up and reset the environment as it
was originally found.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Set up the migration TLS objects for target
John Ferlan [Fri, 3 Mar 2017 12:22:16 +0000 (07:22 -0500)]
qemu: Set up the migration TLS objects for target

If the migration flags indicate this migration will be using TLS,
then set up the destination during the prepare phase once the target
domain has been started to add the TLS objects to perform the migration.

This will create at least an "-object tls-creds-x509,endpoint=server,..."
for TLS credentials and potentially an "-object secret,..." to handle the
passphrase response to access the TLS credentials. The alias/id used for
the TLS objects will contain "libvirt_migrate".

Once the objects are created, the code will set the "tls-creds" and
"tls-hostname" migration parameters to signify usage of TLS.

During the Finish phase we'll be sure to attempt to clear the
migration parameters and delete those objects (whether or not they
were created). We'll also perform the same reset during recovery
if we've reached FINISH3.

If the migration isn't using TLS, then be sure to check if the
migration parameters exist and clear them if so.

8 years agoqemu: Add job for qemuDomain{Add|Del}TLSObjects
John Ferlan [Thu, 9 Mar 2017 14:20:27 +0000 (09:20 -0500)]
qemu: Add job for qemuDomain{Add|Del}TLSObjects

Add an asyncJob argument for add/delete TLS Objects. A future patch will
add/delete TLS objects from a migration which may have a job to join.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add TLS params to _qemuMonitorMigrationParams
John Ferlan [Thu, 16 Feb 2017 23:33:22 +0000 (18:33 -0500)]
qemu: Add TLS params to _qemuMonitorMigrationParams

Add the fields to support setting tls-creds and tls-hostname during
a migration (either source or target). Modify the query migration
function to check for the presence and set the field for future
consumers to determine which of 3 conditions is being met (NULL,
present and set to "", or present and sent to something). These
correspond to qemu commit id '4af245dc3' which added support to
default the value to "" and allow setting (or resetting) to ""
in order to disable. This reset option allows libvirt to properly
use the tls-creds and tls-hostname parameters.

Modify code paths that either allocate or use stack space in order
to call qemuMigrationParamsClear or qemuMigrationParamsFree for cleanup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoAdd new migration flag VIR_MIGRATE_TLS
John Ferlan [Wed, 15 Feb 2017 13:58:46 +0000 (08:58 -0500)]
Add new migration flag VIR_MIGRATE_TLS

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Update the TLS client verify descriptions for vnc and chardev
John Ferlan [Thu, 23 Mar 2017 19:11:51 +0000 (15:11 -0400)]
qemu: Update the TLS client verify descriptions for vnc and chardev

Update the descriptions to match the migrate option.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce migrate_tls_x509_cert_dir
John Ferlan [Fri, 24 Feb 2017 21:44:32 +0000 (16:44 -0500)]
conf: Introduce migrate_tls_x509_cert_dir

Add a new TLS X.509 certificate type - "migrate". This will handle the
creation of a TLS certificate capability (and possibly repository) to
be used for migrations. Similar to chardev's, credentials will be handled
via a libvirt secrets; however, unlike chardev's enablement and usage
will be via a CLI flag instead of a conf flag and a domain XML attribute.

The migrations using the *x509_verify flag require the client-cert.pem
and client-key.pem files to be present in the TLS directory - so let's
also be sure to note that in the qemu.conf file.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Replace macro usage of (false); with just (0)
John Ferlan [Thu, 23 Mar 2017 19:00:54 +0000 (15:00 -0400)]
qemu: Replace macro usage of (false); with just (0)

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Create #define for TLS configuration setup.
John Ferlan [Sun, 12 Feb 2017 14:54:48 +0000 (09:54 -0500)]
qemu: Create #define for TLS configuration setup.

Create GET_CONFIG_TLS_CERT to set up the TLS for 'chardev' TLS setting.
Soon to be reused.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: fix build on non-Linux
Roman Bogorodskiy [Sat, 25 Mar 2017 04:24:21 +0000 (08:24 +0400)]
util: fix build on non-Linux

Fix typo in virNetDevPFGetVF() stub:

  ATTRUBUTE_UNUSED -> ATTRIBUTE_UNUSED.

While here, use common indent style for arguments in
virNetDevGetVirtualFunctionIndex() stub.

8 years agoqemu: snapshot: Forbid internal snapshots with pflash firmware
Peter Krempa [Wed, 1 Mar 2017 08:15:33 +0000 (09:15 +0100)]
qemu: snapshot: Forbid internal snapshots with pflash firmware

If the variable store (<nvram>) file is raw qemu can't do a snapshot of
it and thus the snapshot fails. QEMU rejects such snapshot by a message
which would not be properly interpreted as an error by libvirt.

Additionally allowing to use a qcow2 variable store backing file would
solve this issue but then it would become eligible to become target of
the memory dump.

Offline internal snapshot would be incomplete too with either storage
format since libvirt does not handle the pflash file in this case.

Forbid such snapshot so that we can avoid problems.

8 years agonetwork: only check for IPv6 RA routes when the network has an IPv6 address
Laine Stump [Fri, 24 Mar 2017 00:18:25 +0000 (20:18 -0400)]
network: only check for IPv6 RA routes when the network has an IPv6 address

commit 00d28a78 added a check to see if there were any IPv6 routes
added by RA (Router Advertisement) via an interface that had accept_ra
set to something other than "2". The check was being done
unconditionally, but it's only relevant if IPv6 forwarding is going to
be turned on, and that will only happen if the network has an IPv6
address.

8 years agoRevert "qemu: forbid migration with an IOMMU device"
Ján Tomko [Fri, 24 Mar 2017 11:52:07 +0000 (12:52 +0100)]
Revert "qemu: forbid migration with an IOMMU device"

This reverts commit b7118623ad5a8e6ea75d693881c08873eefa3e28.

Migration was implemented by QEMU commit:
commit 8cdcf3c1e58d04b6811956d7608efeb66c42d719
Author: Peter Xu <peterx@redhat.com>
Date:   Fri Jan 6 12:06:13 2017 +0800

    intel_iommu: allow migration

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

8 years agoutil: new function virNetDevPFGetVF()
Laine Stump [Thu, 2 Mar 2017 19:55:01 +0000 (14:55 -0500)]
util: new function virNetDevPFGetVF()

Given an SRIOV PF netdev name (e.g. "enp2s0f0") and VF#, this new
function returns the netdev name of the referenced VF device
(e.g. "enp2s11f6"), or NULL if the device isn't bound to a net driver.

8 years agoutil: new internal function to permit silent failure of virNetDevSetMAC()
Laine Stump [Thu, 9 Mar 2017 19:04:16 +0000 (14:04 -0500)]
util: new internal function to permit silent failure of virNetDevSetMAC()

We will want to allow silent failure of virNetDevSetMAC() in the case
that the SIOSIFHWADDR ioctl fails with errno == EADDRNOTAVAIL. (Yes,
that is very specific, but we really *do* want a logged failure in all
other circumstances, and don't want to duplicate code in the caller
for the other possibilities).

This patch renames the 3 different virNetDevSetMAC() functions to
virNetDevSetMACInternal(), adding a 3rd arg called "quiet" and making
them static (because this extra control will only be needed within
virnetdev.c). A new global virNetDevSetMAC() is defined that calls
whichever of the three *Internal() functions gets compiled with quiet
= false. Callers in virnetdev.c that want to notice a failure with
errno == EADDRNOTAVAIL and retry with a different strategy rather than
immediately failing, can call virNetDevSetMACInternal(..., true).

8 years agoutil: new function virPCIDeviceRebind()
Laine Stump [Tue, 7 Mar 2017 17:58:15 +0000 (12:58 -0500)]
util: new function virPCIDeviceRebind()

This function unbinds a device from its driver, then immediately
rebinds it to its driver again. The code for this new function is just
the 2nd half of virPCIDeviceBindWithDriverOverride(), so that
function's 2nd half is replaced with a call to virPCIDeviceRebind().

8 years agoutil: make virPCIGetDeviceAddressFromSysfsLink() public
Laine Stump [Tue, 7 Mar 2017 19:23:01 +0000 (14:23 -0500)]
util: make virPCIGetDeviceAddressFromSysfsLink() public

This function will be useful in virnetdev.c, so promote it from static.

8 years agoutil: change virPCIGetNetName() to not return error if device has no net name
Laine Stump [Fri, 3 Mar 2017 16:54:59 +0000 (11:54 -0500)]
util: change virPCIGetNetName() to not return error if device has no net name

...and cleanup the callers to report it when it *is* an error.

In many cases It's useful for virPCIGetNetName() to not log an error
and simply return a NULL pointer when the given device isn't bound to
a net driver (e.g. we're looking at a VF that is permanently bound to
vfio-pci). The existing code would silently return an error in this
case, which could eventually lead to the dreaded "An error occurred
but the cause is unknown" log message.

This patch changes virPCIGetNetName() to still return success if the
device simply isn't bound to a net driver, and adjusts all the callers
that require a non-null netname to check for that condition and log an
error when it happens.

8 years agoutil: make virMacAddrParse more versatile
Laine Stump [Wed, 8 Mar 2017 20:27:05 +0000 (15:27 -0500)]
util: make virMacAddrParse more versatile

Previously the MAC address text was required to be terminated with a
NULL. After this, it can be terminated with a space or any control
character.

8 years agoutil: eliminate useless local variable
Laine Stump [Sun, 5 Mar 2017 22:32:15 +0000 (17:32 -0500)]
util: eliminate useless local variable

vf in virNetDevMacVLanDeleteWithVPortProfile() is initialized to -1
and never set. It's not set for a good reason - because it doesn't
make sense during macvtap device setup to refer to a VF device as
"PF:VF#". This patch replaces the two uses of "vf" with "-1", and
removes the local variable, so that it's more clear we are always
calling the utility functions with vf set to -1.

8 years agoutil: use cleanup label consistently in virHostdevNetConfigReplace()
Laine Stump [Sun, 26 Feb 2017 18:27:48 +0000 (13:27 -0500)]
util: use cleanup label consistently in virHostdevNetConfigReplace()

This will make an upcoming functional change more straightforward.

8 years agoutil: remove unused args from virNetDevSetVfConfig()
Laine Stump [Mon, 20 Feb 2017 03:06:33 +0000 (22:06 -0500)]
util: remove unused args from virNetDevSetVfConfig()

This function is only called in two places, and the ifindex,
nltarget_kernel, and getPidFunc args are never used (and never will
be).

ifindex - we always know the name of the device, and never know the
ifindex - if we really did need the ifindex we would have to get it
from the name using virNetDevGetIndex(). In practice, we just send -1
to virNetDevSetVfConfig(), which doesn't bother to learn the real
ifindex (you only need a name *or* an ifindex for the netlink command
to succeed, not both).

nltarget_kernel - messages to set the config of an SRIOV VF will
always go to netlink in the kernel, not to another user process, so
this arg is always true (there are other uses of netlink messages
where the message might need to go to another user process, but never
in the case of RTM_SETLINK for SRIOV).

getPidFunc - this arg is only used if nltarget_kernel is false, and it
never is.

None of this has any functional effect, it just makes it easier to
follow what's happening when virNetDevSetVfConfig() is called.

8 years agoutil: permit querying a VF MAC address or VLAN tag by itself
Laine Stump [Fri, 17 Feb 2017 19:28:55 +0000 (14:28 -0500)]
util: permit querying a VF MAC address or VLAN tag by itself

virNetDevParseVfConfig() assumed that both the MAC address and VLAN
tag pointers were valid, so even if you only wanted one or the other,
you would need a variable to hold the returned value for both. This
patch checks each for a NULL pointer before filling it in.

8 years agoqemu: forbid migration with an IOMMU device
Ján Tomko [Thu, 23 Mar 2017 10:14:42 +0000 (11:14 +0100)]
qemu: forbid migration with an IOMMU device

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

8 years agoqemu: Fix typo in __QEMU_CAPSPRIV_H_ALLOW__
Andrea Bolognani [Wed, 22 Mar 2017 15:22:15 +0000 (16:22 +0100)]
qemu: Fix typo in __QEMU_CAPSPRIV_H_ALLOW__

8 years agoutil: fix build on non-Linux
Roman Bogorodskiy [Thu, 23 Mar 2017 03:45:29 +0000 (07:45 +0400)]
util: fix build on non-Linux

Decorate unused arguments of the virNetDevGetMaster() stub
with ATTRIBUTE_UNUSED to fix build on systems where this
stub is used.

8 years agocpu: Remove NONNULL(1) for cpuBaseline
John Ferlan [Wed, 22 Mar 2017 12:38:40 +0000 (08:38 -0400)]
cpu: Remove NONNULL(1) for cpuBaseline

Since the code checks and handles a NULL 'cpus' anyway, so no need
for the NONNULL.

8 years agoutil: Remove NONNULL(1) for virNetDevMacVLanDeleteWithVPortProfile
John Ferlan [Wed, 22 Mar 2017 12:07:44 +0000 (08:07 -0400)]
util: Remove NONNULL(1) for virNetDevMacVLanDeleteWithVPortProfile

Since the source code checks 'ifname' for NULL before using, the prototype
doesn't need the NONNULL

8 years agoutil: Remove NONNULL's for virNetDevVPortProfile[Associate|Disassociate]
John Ferlan [Wed, 22 Mar 2017 11:58:05 +0000 (07:58 -0400)]
util: Remove NONNULL's for virNetDevVPortProfile[Associate|Disassociate]

The source code will check for NULL arguments for 'macvtap_macaddr' and
'vmuuid', so no need for the NONNULL in the prototypes. Following the stack
for both arguments to virNetDevVPortProfileOpSetLink also shows called
functions would handle a NULL value.

Additionally, modified the prototype to use the same 'macvtap_macaddr'
name as the source code for consistency.

8 years agoutil: Remove NONNULL(1) for virNetDevOpenvswitchGetVhostuserIfname
John Ferlan [Wed, 22 Mar 2017 11:25:32 +0000 (07:25 -0400)]
util: Remove NONNULL(1) for virNetDevOpenvswitchGetVhostuserIfname

Since the code checks and handles a NULL 'path', no need for the NONNULL

8 years agoutil: Remove NONNULL(2) for virNetDevBandwidthPlug
John Ferlan [Tue, 21 Mar 2017 18:56:03 +0000 (14:56 -0400)]
util: Remove NONNULL(2) for virNetDevBandwidthPlug

Since the code checks and handles a NULL 'net_bandwidth' parameter,
so no need for NONNNULL.

8 years agoutil: Remove NONNULL(1,3,4) from virTypedParamsFilter
John Ferlan [Tue, 21 Mar 2017 18:41:53 +0000 (14:41 -0400)]
util: Remove NONNULL(1,3,4) from virTypedParamsFilter

The API checks each parameter for NULL anyway and would error, so need
to add NONNULL on prototype.

8 years agoutil: Remove NONNULL(1) for virNetDevOpenvswitchSetMigrateData
John Ferlan [Tue, 21 Mar 2017 18:40:13 +0000 (14:40 -0400)]
util: Remove NONNULL(1) for virNetDevOpenvswitchSetMigrateData

The code checks and handles a NULL 'migrate', so no need for NONNULL

8 years agoutil: Remove NONNULL(1) for virHostdevReAttachDomainDevices
John Ferlan [Wed, 22 Mar 2017 12:30:15 +0000 (08:30 -0400)]
util: Remove NONNULL(1) for virHostdevReAttachDomainDevices

Since the function handles a NULL 'mgr' condition, no need for the NONNULL

8 years agoutil: Remove NONNULL(1) for virHostdevPrepareDomainDevices
John Ferlan [Tue, 21 Mar 2017 18:32:01 +0000 (14:32 -0400)]
util: Remove NONNULL(1) for virHostdevPrepareDomainDevices

Since the code checks 'mgr == NULL' anyway, no need for the prototype
to have the NONNULL arg check.  Also add an error message to indicate what
the failure is so that there isn't a failed for some reason error.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Remove NONNULL(2,3) for virHostdevReAttachSCSIVHostDevices
John Ferlan [Wed, 22 Mar 2017 11:23:46 +0000 (07:23 -0400)]
util: Remove NONNULL(2,3) for virHostdevReAttachSCSIVHostDevices

The comparison code used STREQ_NULLABLE anyway for both 'drv_name' and
'dom_name', so no need. Add a NULLSTR on the 'dom_name' too.

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