]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agovirt-aa-helper-test: Add test for aarch32 UEFI image path
dann frazier [Thu, 20 Jul 2017 19:56:56 +0000 (13:56 -0600)]
virt-aa-helper-test: Add test for aarch32 UEFI image path

Signed-off-by: dann frazier <dann.frazier@canonical.com>
7 years agoqemu: Add AAVMF32 to the list of known UEFIs
dann frazier [Thu, 20 Jul 2017 19:56:55 +0000 (13:56 -0600)]
qemu: Add AAVMF32 to the list of known UEFIs

Add a path for UEFI VMs for AArch32 VMs, based on the path Debian is using.
libvirt is the de facto canonical location for defining where distros
should place these firmware images, so let's define this path here to try
and minimize distro fragmentation.

7 years agoqemu: Remove duplicated code in qemuBuildSerialChrDeviceStr()
Andrea Bolognani [Thu, 22 Jun 2017 10:08:46 +0000 (18:08 +0800)]
qemu: Remove duplicated code in qemuBuildSerialChrDeviceStr()

The call to qemuBuildDeviceAddressStr() happens no matter
what, so we can move it to the outer possible scope inside
the function.

We can also move the call to virBufferAsprintf() after all
the checks have been performed, where it makes more sense.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Move some virDomainDeviceInfo functions
Andrea Bolognani [Tue, 27 Jun 2017 06:30:58 +0000 (08:30 +0200)]
conf: Move some virDomainDeviceInfo functions

The virDomainDeviceInfo struct is defined in device_conf,
so generic functions that operate on it should also be
defined there rather than in domain_conf.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Clean up virDomainHostdevDefNew()
Andrea Bolognani [Tue, 27 Jun 2017 08:28:22 +0000 (10:28 +0200)]
conf: Clean up virDomainHostdevDefNew()

Follow the same style as other similar functions.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Rename virDomainHostdevDefAlloc() to virDomainHostdevDefNew()
Andrea Bolognani [Sun, 25 Jun 2017 12:11:12 +0000 (14:11 +0200)]
conf: Rename virDomainHostdevDefAlloc() to virDomainHostdevDefNew()

All other virDomain*Def follow this naming convention for
their allocation function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Enable NUMA node tag in pci-root for PPC64
Shivaprasad G Bhat [Fri, 21 Jul 2017 08:03:15 +0000 (13:33 +0530)]
qemu: Enable NUMA node tag in pci-root for PPC64

This patch addresses the same aspects on PPC the bug 1103314 addressed
on x86.

PCI expander bus creates multiple primary PCI busses, where each of these
busses can be assigned a specific NUMA affinity, which, on x86 is
advertised through ACPI on a per-bus basis.

For SPAPR, a PHB's NUMA affinities are assigned on a per-PHB basis, and
there is no mechanism for advertising NUMA affinities to a guest on a
per-bus basis. So, even if qemu-ppc manages to get some sort of multi-bus
topology working using PXB, there is no way to expose the affinities
of these busses to the guest. It can only be exposed on a per-PHB/per-domain
basis.

So patch enables NUMA node tag in pci-root controller on PPC.

The way to set the NUMA node is through the numa_node option of
spapr-pci-host-bridge device. However for the implicit PHB, the only way
to set the numa_node is from the -global option. The -global option applies
to all the PHBs unless explicitly specified with the option on the
respective PHB of CLI. The default PHB has the emulated devices only, so
the patch prevents setting the NUMA node for the default PHB.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: capabilitity: Introduce QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE
Shivaprasad G Bhat [Fri, 21 Jul 2017 08:02:32 +0000 (13:32 +0530)]
qemu: capabilitity: Introduce QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE

The patch adds a capability for spapr-pci-host-bridge.numa_node.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoAdd capabilities for qemu-2.9.0 ppc64
Shivaprasad G Bhat [Fri, 21 Jul 2017 08:02:13 +0000 (13:32 +0530)]
Add capabilities for qemu-2.9.0 ppc64

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Clean up firmware list initialization
Andrea Bolognani [Fri, 21 Jul 2017 10:09:58 +0000 (12:09 +0200)]
qemu: Clean up firmware list initialization

Instead of going through two completely different code paths,
one of which repeats the same hardcoded bit of information
three times in rapid succession, depending on whether or not
a firmware list has been provided at configure time, just
provide a reasonable default value and remove the extra code.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agolibvirt-domain.h: Fix enum description placement
Michal Privoznik [Fri, 21 Jul 2017 10:46:18 +0000 (12:46 +0200)]
libvirt-domain.h: Fix enum description placement

There are only two acceptable places for describing enum values.
It's either:

    typedef enum {
        /* Some long description. Therefore it's placed before
         * the value. */
        VIR_ENUM_A_VAL = 1,
    } virEnumA;

or:

    typedef enum {
        VIR_ENUM_B_VAL = 1, /* Some short description */
    } virEnumB;

However, during review of a patch sent upstream I realized that
is not always the case. I went through all the public header
files and identified all the offenders. Luckily there were just
two of them.

Yes, this makes our HTML generated documentation broken, but
that's bug of the generator. Our header files shouldn't be forced
to use something we don't want to.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: process: Don't put memoryless NUMA nodes into autoNodeset
Peter Krempa [Wed, 12 Jul 2017 11:59:35 +0000 (13:59 +0200)]
qemu: process: Don't put memoryless NUMA nodes into autoNodeset

'numad' may return a nodeset which contains NUMA nodes without memory
for certain configurations. Since cgroups code will not be happy using
nodes without memory we need to store only numa nodes with memory in
autoNodeset.

On the other hand autoCpuset should contain cpus also for nodes which
do not have any memory.

7 years agoqemu: process: Extract gathering of 'numad' placement into a function
Peter Krempa [Wed, 12 Jul 2017 07:06:42 +0000 (09:06 +0200)]
qemu: process: Extract gathering of 'numad' placement into a function

Remove the code from qemuProcessPrepareDomain so that it won't get even
more bloated.

7 years agoqemu: domain: Store and restore autoCpuset to status XML
Peter Krempa [Wed, 12 Jul 2017 12:10:34 +0000 (14:10 +0200)]
qemu: domain: Store and restore autoCpuset to status XML

Decouple them by storing them in the XML separately rather than
regenerating them. This will simplify upcoming fixes.

7 years agoqemu: domain: Extract parsing and formatting of priv->autoNodeset
Peter Krempa [Wed, 12 Jul 2017 07:24:07 +0000 (09:24 +0200)]
qemu: domain: Extract parsing and formatting of priv->autoNodeset

Move the code to separate functions to avoid complicating the existing
ones with changes.

7 years agoutil: bitmap: Modify virBitmapSubtract to virBitmapIntersect
Peter Krempa [Wed, 12 Jul 2017 11:30:47 +0000 (13:30 +0200)]
util: bitmap: Modify virBitmapSubtract to virBitmapIntersect

Since virBitmapSubtract is unused modify it to perform bitmap
intersection.

7 years agotests: Free @fakerootdir in error path
John Ferlan [Thu, 20 Jul 2017 10:46:41 +0000 (06:46 -0400)]
tests: Free @fakerootdir in error path

Commit id 'dd9b29dad' added this new variable, but didn't free it in
one instance where status was returned to the caller.

Found by Coverity

7 years agodaemon: Don't conditionally free @origErr in daemonStreamEvent
John Ferlan [Thu, 20 Jul 2017 10:44:21 +0000 (06:44 -0400)]
daemon: Don't conditionally free @origErr in daemonStreamEvent

Commit id '0fe4aa149' added @origErr, but since it's assigned outside
the if condition, the free should be outside as well.

Found by Coverity

7 years agoHandle hotplug change on VLAN configuration using OVS
Antoine Millet [Mon, 17 Jul 2017 15:49:00 +0000 (17:49 +0200)]
Handle hotplug change on VLAN configuration using OVS

A new function virNetDevOpenvswitchUpdateVlan has been created to instruct
OVS of the changes. qemuDomainChangeNet has been modified to handle the
update of the VLAN configuration for a running guest and rely on
virNetDevOpenvswitchUpdateVlan to do the actual update if needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirnetdevopenvswitch: Move OVS VLAN configuration to a separate function
Antoine Millet [Mon, 17 Jul 2017 15:48:59 +0000 (17:48 +0200)]
virnetdevopenvswitch: Move OVS VLAN configuration to a separate function

This piece of code is going to be reused. So move it out to a
separate function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agosecurity: Don't overwrite error of GetProcessLabel
Cole Robinson [Wed, 19 Jul 2017 23:18:18 +0000 (19:18 -0400)]
security: Don't overwrite error of GetProcessLabel

Security impls of this function already raise errors, don't
overwrite them.

7 years agoqemu: separate virQEMUCapsInitCached out of virQEMUCapsNewForBinaryInternal
Pavel Hrdina [Tue, 18 Jul 2017 14:14:07 +0000 (16:14 +0200)]
qemu: separate virQEMUCapsInitCached out of virQEMUCapsNewForBinaryInternal

Preparation for switching to virFileCache where there are two callbacks,
one to get a new data and second one to load a cached data.

This also removes virQEMUCapsReset which is no longer required.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: don't pass qemuctime into virQEMUCapsIsValid
Pavel Hrdina [Thu, 22 Jun 2017 10:53:26 +0000 (12:53 +0200)]
qemu: don't pass qemuctime into virQEMUCapsIsValid

It's not required and following patches will change the code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: move libvirt ctime and version check into virQEMUCapsIsValid
Pavel Hrdina [Thu, 22 Jun 2017 10:52:35 +0000 (12:52 +0200)]
qemu: move libvirt ctime and version check into virQEMUCapsIsValid

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: move virQEMUCapsIsValid before its usage and make it static
Pavel Hrdina [Mon, 19 Jun 2017 12:03:06 +0000 (14:03 +0200)]
qemu: move virQEMUCapsIsValid before its usage and make it static

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: move libvirt ctime and version into _virQEMUCaps struct
Pavel Hrdina [Tue, 13 Jun 2017 15:55:45 +0000 (17:55 +0200)]
qemu: move libvirt ctime and version into _virQEMUCaps struct

Cleanups the code a little bit and reduces amount of arguments passed
throughout the functions.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoutil/virhash: add name parameter to virHashSearch
Pavel Hrdina [Tue, 13 Jun 2017 13:56:14 +0000 (15:56 +0200)]
util/virhash: add name parameter to virHashSearch

While searching for an element using a function it may be
desirable to know the element key for future operation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoinclude: nodedev: Fix a misleading comment about the used callback
Chen Hanxiao [Thu, 20 Jul 2017 09:01:57 +0000 (17:01 +0800)]
include: nodedev: Fix a misleading comment about the used callback

Actually we use virConnectNodeDeviceEventGenericCallback.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoqemu: shared disks with cache=directsync should be safe for migration
Hao Peng [Sat, 15 Jul 2017 15:01:25 +0000 (23:01 +0800)]
qemu: shared disks with cache=directsync should be safe for migration

At present shared disks can be migrated with either readonly or cache=none. But
cache=directsync should be safe for migration, because both cache=directsync and cache=none
don't use the host page cache, and cache=direct write through qemu block layer cache.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Reviewed-by: Wang Yechao <wang.yechao255@zte.com.cn>
7 years agoqemu: blockcopy: Refactor logic checking the target storage file
Peter Krempa [Tue, 11 Jul 2017 15:45:12 +0000 (17:45 +0200)]
qemu: blockcopy: Refactor logic checking the target storage file

Use virStorageSource accessors to check the file and call
virStorageFileAccess before even attempting to stat the target. This
will be helpful once we try to add network destinations for block copy,
since there will be no need to stat them.

7 years agoqemu: blockcopy: Split out checking of the target image file
Peter Krempa [Tue, 11 Jul 2017 15:43:19 +0000 (17:43 +0200)]
qemu: blockcopy: Split out checking of the target image file

Move the code into a separate function so that the flow of creating the
copy is more obvious and split into logical pieces.

7 years agoqemu: blockcopy: reuse storage driver APIs to pre-create copy target
Peter Krempa [Mon, 29 Feb 2016 12:36:16 +0000 (13:36 +0100)]
qemu: blockcopy: reuse storage driver APIs to pre-create copy target

Rather than using the local-file only implementation 'qemuOpenFile'
switch to the imagelabel aware storage driver implementation.

7 years agoqemu: blockcopy: Explicitly assert 'reuse' for block devices
Peter Krempa [Tue, 11 Jul 2017 06:23:38 +0000 (08:23 +0200)]
qemu: blockcopy: Explicitly assert 'reuse' for block devices

When copying to a block device, the block device will already exist. To
allow users using a block device without any preparation, they need to
use the block copy without VIR_DOMAIN_BLOCK_COPY_REUSE_EXT.

This means that if the target is an existing block device we don't need
to prepare it, but we can't reject it as being existing.

To avoid breaking this feature, explicitly assume that existing block
devices will be reused even without that flag explicitly specified,
while skipping attempts to create it.

qemuMonitorDriveMirror still needs to honor the flag as specified by the
user, since qemu overwrites the metadata otherwise.

7 years agoqemu: driver: Split out access to VIR_DOMAIN_BLOCK_COPY_REUSE_EXT
Peter Krempa [Tue, 11 Jul 2017 06:20:55 +0000 (08:20 +0200)]
qemu: driver: Split out access to VIR_DOMAIN_BLOCK_COPY_REUSE_EXT

Extract the presence of the flag into a boolean to simplify conditions
and allow further manipulation of the state of the flag.

7 years agoLXC: set the right var to NULL
Chen Hanxiao [Thu, 20 Jul 2017 02:02:30 +0000 (10:02 +0800)]
LXC: set the right var to NULL

   For attaching hosdev, we should set dev->data.hostdev
   rather than dev->data.disk

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agospec: Add support for building the zfs storage driver
Neal Gompa [Mon, 17 Jul 2017 15:32:46 +0000 (11:32 -0400)]
spec: Add support for building the zfs storage driver

Where it can be supported in Fedora, the driver is built and made
available as a subpackage.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
7 years agotests: virjson: Test nesting of JSON string into a JSON (string) property
Peter Krempa [Mon, 3 Jul 2017 14:39:21 +0000 (16:39 +0200)]
tests: virjson: Test nesting of JSON string into a JSON (string) property

Test that we are able to create a JSON object and nest it into a string
property of a JSON object and then correctly extract and parse it back.

7 years agotests: virjson: Test parsing and formatting of strings with escaped chars
Peter Krempa [Mon, 3 Jul 2017 14:39:21 +0000 (16:39 +0200)]
tests: virjson: Test parsing and formatting of strings with escaped chars

Make sure that JSON strings can contain characters which need to be
escaped (double quotes, backslashes, tabs, etc.).

7 years agophyp: Fix memory leak in phypUUIDTable_Push
ZhiPeng Lu [Wed, 19 Jul 2017 00:02:36 +0000 (08:02 +0800)]
phyp: Fix memory leak in phypUUIDTable_Push

@remote_file, allocated by virAsprintf, was not freed and leaked.

Signed-off-by: Zhipeng Lu <lu.zhipeng@zte.com.cn>
7 years agompath: Fix memory leak in virStorageBackendCreateVols
ZhiPeng Lu [Wed, 19 Jul 2017 00:36:54 +0000 (08:36 +0800)]
mpath: Fix memory leak in virStorageBackendCreateVols

@map_device, allocated by virAsprintf in virStorageBackendCreateVols,
was not freed and leaked.

Signed-off-by: Zhipeng Lu <lu.zhipeng@zte.com.cn>
7 years agotests: virjson: Test formatting along with parsing of JSON objects
Peter Krempa [Mon, 3 Jul 2017 13:37:21 +0000 (15:37 +0200)]
tests: virjson: Test formatting along with parsing of JSON objects

Format the parsed string back and compare it to the original (or
modified) string for back and forth comparison.

7 years agotests: virjson: Remove spaces from 'very-hard' parsing example
Peter Krempa [Mon, 3 Jul 2017 13:16:02 +0000 (15:16 +0200)]
tests: virjson: Remove spaces from 'very-hard' parsing example

The example is rather long and upcomming patch will check whether the
string can be formatted back. As the formatted string lacks spaces and
adding the 'expect' string with spaces would be rather long, just drop
spaces from this test case.

There are other test cases which do contain spaces.

7 years agotests: virjson: Modify logic in testJSONFromString
Peter Krempa [Mon, 3 Jul 2017 13:02:38 +0000 (15:02 +0200)]
tests: virjson: Modify logic in testJSONFromString

To allow better testing in case where the string was parsed, modify the
logic so that the regular code path is not included in a conditional
block.

7 years agotest/Makefile.am: drop WARN_CFLAGS from LDFLAGS
Ján Tomko [Wed, 29 Jun 2016 13:16:18 +0000 (15:16 +0200)]
test/Makefile.am: drop WARN_CFLAGS from LDFLAGS

Introduced by commit 0832c58, with the intention to link with
the stack protector library.

Another instance introduced by commit 4cbc15d which separated
commandhelper_LDADD from LDADDS.

Not needed because per commit 71b54636, automake should pass
all the CFLAGS to the linker.

7 years agoqemu: avoid deadlock on domain object enter monitor fail
Wang King [Wed, 19 Jul 2017 06:40:24 +0000 (14:40 +0800)]
qemu: avoid deadlock on domain object enter monitor fail

Should be followed with qemuDomainObjExitMonitor only if
qemuDomainObjEnterMonitorAsync returns 0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agosecurity: apparmor: Properly link with storage driver in helper program
Peter Krempa [Tue, 18 Jul 2017 07:43:41 +0000 (09:43 +0200)]
security: apparmor: Properly link with storage driver in helper program

The refactor to split up storage driver into modules broke the apparmor
helper program, since that did not initialize the storage driver
properly and thus detection of the backing chain could not work.

Register the storage driver backends explicitly. Unfortunately it's now
necessary to link with the full storage driver to satisfy dependencies
of the loadable modules.

Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agovirFileInData: Report an error if unable to reposition file
Michal Privoznik [Tue, 11 Jul 2017 08:56:19 +0000 (10:56 +0200)]
virFileInData: Report an error if unable to reposition file

The purpose of this function is to tell if the current position
in given FD is in data section or a hole and how much bytes there
is remaining until the end of the section. This is achieved by
couple of lseeks(). The most important part is that we reposition
the FD back, so that the position is unchanged from the caller
POV. And until now the final lseek() back to the original
position was done with no check for errors. And I was convinced
that that's okay since nothing can go wrong. However, review
feedback from a related series persuaded me, that it's better to
be safe than sorry. Therefore, lets check if the final lseek()
succeeded and if it doesn't report an error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: schema: make disk driver name attribute optional
Jim Fehlig [Tue, 18 Jul 2017 16:20:35 +0000 (10:20 -0600)]
docs: schema: make disk driver name attribute optional

/domain/devices/disk/driver/@name is not a required or mandatory
attribute according to formatdomain, and indeed it was agreed on
IRC that the attribute is "optional for input, recommended (but
not required) for output". Currently the schema requires the
attribute, causing virt-xml-validate to fail on disk config where
the driver name is not explicitly specified. E.g.

# cat test.xml | grep -A 5 cdrom
    <disk type='file' device='cdrom'>
      <driver type='raw'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

# virt-xml-validate test.xml
Relax-NG validity error : Extra element devices in interleave
test.xml:21: element devices: Relax-NG validity error : Element domain failed to validate content
test.xml fails to validate

Relaxing the name attribute to be optional fixes the validation

# virt-xml-validate test.xml
test.xml validates

7 years agowireshark: Adapt to tvb_new_subset() rename
Michal Privoznik [Tue, 18 Jul 2017 08:27:41 +0000 (10:27 +0200)]
wireshark: Adapt to tvb_new_subset() rename

In Wireshark commit of 7cd6906056922e4b8 (contained in v2.4.0)
the tvb_new_subset() function was renamed to
tvb_new_subset_length_caplen(). However, we can take the extra
step and rename to tvb_new_subset_remaining() directly (see
Wireshark commit 0ecfc7280cf3d7). The reasoning is that there is
no other protocol in the packet than libvirt. Therefore, from the
point that libvirt dissector takes over till the end of the
packet it's all libvirt packet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
7 years agotests: enable qemu 2.9 capabilities test for s390
Boris Fiuczynski [Mon, 10 Jul 2017 09:12:37 +0000 (11:12 +0200)]
tests: enable qemu 2.9 capabilities test for s390

Adjust qemu 2.9 s390 capabilites xml and enable qemu capabilities test.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
7 years agonodedev: Fix call to virNodeDeviceObjListFree in nodeStateReload
John Ferlan [Tue, 18 Jul 2017 11:19:05 +0000 (07:19 -0400)]
nodedev: Fix call to virNodeDeviceObjListFree in nodeStateReload

Commit id '9c5d98fd8' missed changing this call to use driver->devs
rather than @driver->devs.

7 years agonews: Update for hostdev isolation
Andrea Bolognani [Fri, 23 Jun 2017 14:58:26 +0000 (22:58 +0800)]
news: Update for hostdev isolation

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Isolate hostdevs on pSeries guests
Andrea Bolognani [Fri, 2 Jun 2017 13:19:04 +0000 (15:19 +0200)]
qemu: Isolate hostdevs on pSeries guests

All the pieces are now in place, so we can finally start
using isolation groups to achieve our initial goal, which is
separating hostdevs from emulated PCI devices while keeping
hostdevs that belong to the same host IOMMU group together.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Implement isolation rules
Andrea Bolognani [Thu, 15 Jun 2017 08:40:42 +0000 (16:40 +0800)]
conf: Implement isolation rules

These rules will make it possible for libvirt to
automatically assign PCI addresses in a way that
respects any isolation constraints devices might
have.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Introduce isolation groups
Andrea Bolognani [Thu, 15 Jun 2017 08:38:33 +0000 (16:38 +0800)]
conf: Introduce isolation groups

Isolation groups will eventually allow us to make sure certain
devices, eg. PCI hostdevs, are assigned to guest PCI buses in
a way that guarantees improved isolation, error detection and
recovery for machine types and hypervisors that support it,
eg. pSeries guest on QEMU.

This patch merely defines storage for the new information
we're going to need later on and makes sure it is passed from
the hypervisor driver (QEMU / bhyve) down to the generic PCI
address allocation code.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agonodedev: Convert virNodeDeviceObj to use virObjectLockable
John Ferlan [Mon, 15 May 2017 15:00:59 +0000 (11:00 -0400)]
nodedev: Convert virNodeDeviceObj to use virObjectLockable

Now that we have a bit more control, let's convert our object into
a lockable object and let that magic handle the create and lock/unlock.

This also involves creating a virNodeDeviceEndAPI in order to handle
the object cleanup for API's that use the Add or Find API's in order
to get a locked/reffed object. The EndAPI will unlock and unref the
object returning NULL to indicate to the caller to not use the obj.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Privatize _virNodeDeviceObj and _virNodeDeviceObjList
John Ferlan [Fri, 12 May 2017 17:56:14 +0000 (13:56 -0400)]
nodedev: Privatize _virNodeDeviceObj and _virNodeDeviceObjList

Move the structures to withing virnodedeviceobj.c

Move the typedefs from node_device_conf to virnodedeviceobj.h

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Introduce virNodeDeviceObjListFindSCSIHostByWWNs
John Ferlan [Fri, 12 May 2017 19:31:10 +0000 (15:31 -0400)]
nodedev: Introduce virNodeDeviceObjListFindSCSIHostByWWNs

In an overall effort to privatize access to virNodeDeviceObj and
virNodeDeviceObjList into the virnodedeviceobj module, move the
object list parsing from node_device_driver and replace with a
call to a virnodedeviceobj helper. This follows other similar
APIs/helpers which peruse the object list looking for some specific
data in order to get/return an @device (virNodeDevice) object to
the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Introduce virNodeDeviceGetSCSIHostCaps
John Ferlan [Thu, 25 May 2017 14:20:58 +0000 (10:20 -0400)]
nodedev: Introduce virNodeDeviceGetSCSIHostCaps

We're about to move the call to nodeDeviceSysfsGetSCSIHostCaps from
node_device_driver into virnodedeviceobj, so move the guts of the code
from the driver specific node_device_linux_sysfs into its own API
since virnodedeviceobj cannot callback into the driver.

Nothing in the code deals with sysfs anyway, as that's hidden by the
various virSCSIHost* and virVHBA* utility function calls.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Dereference the obj/def in virNodeDeviceObjListFind* APIs
John Ferlan [Mon, 15 May 2017 14:20:51 +0000 (10:20 -0400)]
nodedev: Dereference the obj/def in virNodeDeviceObjListFind* APIs

Create local @obj and @def for the API's rather than referencing the
devs->objs[i][->def->].  It'll make future patches easier to read.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Alter node device obj list function names
John Ferlan [Fri, 12 May 2017 18:47:17 +0000 (14:47 -0400)]
nodedev: Alter node device obj list function names

Ensure that any function that walks the node device object list is prefixed
by virNodeDeviceObjList.

Also, modify the @filter param name for virNodeDeviceObjListExport to
be @aclfilter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Introduce virNodeDeviceObjListNew
John Ferlan [Fri, 12 May 2017 17:51:25 +0000 (13:51 -0400)]
nodedev: Introduce virNodeDeviceObjListNew

In preparation to make things private, make the ->devs be pointers to a
virNodeDeviceObjList and then manage everything inside virnodedeviceobj

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Introduce virNodeDeviceObjNew
John Ferlan [Fri, 12 May 2017 17:34:23 +0000 (13:34 -0400)]
nodedev: Introduce virNodeDeviceObjNew

Create an allocator for the virNodeDeviceObjPtr - include setting up
the mutex, saving the virNodeDeviceDefPtr, and locking the return object.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Use consistent names for driver variables
John Ferlan [Fri, 12 May 2017 16:45:16 +0000 (12:45 -0400)]
nodedev: Use consistent names for driver variables

A virNodeDeviceObjPtr is an @obj

A virNodeDeviceObjListPtr is a @devs

A virNodeDevicePtr is a @device

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Use common naming for virnodedeviceobj
John Ferlan [Fri, 12 May 2017 15:17:26 +0000 (11:17 -0400)]
nodedev: Use common naming for virnodedeviceobj

A virNodeDeviceObjPtr is an @obj

A virNodeDeviceObjListPtr is an @devs

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agotest: Adjust cleanup/error paths for nodedev test APIs
John Ferlan [Fri, 12 May 2017 15:08:57 +0000 (11:08 -0400)]
test: Adjust cleanup/error paths for nodedev test APIs

 - In testDestroyVport rather than use a cleanup label, just return -1
   immediately since nothing else is needed.

 - In testStoragePoolDestroy, if !privpool, then just return -1 since
   nothing else will happen anyway.

 - Rather than "goto cleanup;" on failure to virNodeDeviceObjFindByName
   an @obj, just return directly.  This then allows the cleanup: label code
   to not have to check "if (obj)" before calling virNodeDeviceObjUnlock.
   This also simplifies some exit logic...

 - In testNodeDeviceObjFindByName use an error: label to handle the failure
   and don't do the ncaps++ within the VIR_STRDUP() source target index.
   Only increment ncaps after success. Easier on eyes at error label too.

 - In testNodeDeviceDestroy use "cleanup" rather than "out" for the goto

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Alter virNodeDeviceObjRemove
John Ferlan [Fri, 2 Jun 2017 13:04:29 +0000 (09:04 -0400)]
nodedev: Alter virNodeDeviceObjRemove

Rather than passing the object to be removed by reference, pass by value
and then let the caller decide whether or not the object should be free'd
and how to handle the logic afterwards. This includes free'ing the object
and/or setting the local variable to NULL to prevent subsequent unexpected
usage (via something like virNodeDeviceObjRemove in testNodeDeviceDestroy).

For now this function will just handle the remove of the object from the
list for which it was placed during virNodeDeviceObjAssignDef.

This essentially reverts logic from commit id '61148074' that free'd the
device entry on list, set *dev = NULL and returned. Thus fixing a bug in
node_device_hal.c/dev_refresh() which would never call dev_create(udi)
since @dev would have been set to NULL.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use the proper string in qemuBlock...JSONSocketAddress()
Martin Kletzander [Mon, 17 Jul 2017 12:05:53 +0000 (14:05 +0200)]
qemu: Use the proper string in qemuBlock...JSONSocketAddress()

Recent refactors made it so that the function may use uninitialized
pointer, but it actually wanted to use a different variable and value
at all.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoRevert "nwfilter: Move save of config until after successful assign"
John Ferlan [Sat, 15 Jul 2017 12:23:42 +0000 (08:23 -0400)]
Revert "nwfilter: Move save of config until after successful assign"

This reverts commit b3e71a8830b2683ee88fa10cb048eabb99a446c0.

As it turns out this ends up very badly as the @def could be Free'd
even though it's owned by @obj as a result of the AssignDef.

7 years agovirpcimock: Fix memory leak in pci_driver_new
ZhiPeng Lu [Sat, 15 Jul 2017 03:35:36 +0000 (11:35 +0800)]
virpcimock: Fix memory leak in pci_driver_new

driverpath, allocated by virAsprintfQuiet, was not freed and leaked.

Signed-off-by: Zhipeng Lu <lu.zhipeng@zte.com.cn>
7 years agonwfilter: Introduce virNWFilterObjListFindInstantiateFilter
John Ferlan [Tue, 30 May 2017 21:27:04 +0000 (17:27 -0400)]
nwfilter: Introduce virNWFilterObjListFindInstantiateFilter

Create a common API to handle the instantiation path filter lookup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Rename _virNWFilterInstantiateFilter
John Ferlan [Tue, 30 May 2017 19:59:24 +0000 (15:59 -0400)]
nwfilter: Rename _virNWFilterInstantiateFilter

New API will be virNWFilterInstantiateFilterInternal as it's called from
the virNWFilterInstantiateFilter and virNWFilterUpdateInstantiateFilter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Rename __virNWFilterInstantiateFilter
John Ferlan [Tue, 30 May 2017 19:30:42 +0000 (15:30 -0400)]
nwfilter: Rename __virNWFilterInstantiateFilter

Rename to virNWFilterInstantiateFilterUpdate and alter the callers to not
have one parameter per line.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Rename virNWFilterInstantiate
John Ferlan [Tue, 30 May 2017 19:23:42 +0000 (15:23 -0400)]
nwfilter: Rename virNWFilterInstantiate

Rename to virNWFilterDoInstantiate to better describe the action.

Also fix the @vmuuid parameter to not have the ATTRIBUTE_UNUSED since it
is used in the call to virNWFilterDHCPSnoopReq.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Consistently name virNWFilterPtr in driver
John Ferlan [Sun, 14 May 2017 13:00:27 +0000 (09:00 -0400)]
nwfilter: Consistently name virNWFilterPtr in driver

Use @nwfilter always for the name

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Clean up a couple nwfilter_driver error paths
John Ferlan [Sun, 14 May 2017 12:57:13 +0000 (08:57 -0400)]
nwfilter: Clean up a couple nwfilter_driver error paths

No need to goto cleanup and check "if (obj)" if we know (obj) isn't there,
so just return immediately.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Remove need for virNWFilterSaveXML
John Ferlan [Tue, 30 May 2017 17:26:58 +0000 (13:26 -0400)]
nwfilter: Remove need for virNWFilterSaveXML

Merge code into virNWFilterSaveConfig

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonwfilter: Fix return value comparison for virNWFilterTriggerVMFilterRebuild
John Ferlan [Thu, 25 May 2017 13:35:58 +0000 (09:35 -0400)]
nwfilter: Fix return value comparison for virNWFilterTriggerVMFilterRebuild

Should compare < 0 to be correct.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: formatdomain: Tweak disk discard= docs
Cole Robinson [Sat, 15 Jul 2017 17:09:53 +0000 (13:09 -0400)]
docs: formatdomain: Tweak disk discard= docs

Change from

  'controls whether to discard ... requests are ignored'

to

  'controls whether discard requests ... are ignored'

7 years agonews: Update for multiple PHBs
Andrea Bolognani [Fri, 23 Jun 2017 14:58:26 +0000 (22:58 +0800)]
news: Update for multiple PHBs

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Use PHBs when extending the guest PCI topology
Andrea Bolognani [Mon, 29 May 2017 15:18:35 +0000 (17:18 +0200)]
qemu: Use PHBs when extending the guest PCI topology

When looking for slots suitable for a PCI device, libvirt
might need to add an extra PCI controller: for pSeries guests,
we want that extra controller to be a PHB (pci-root) rather
than a PCI bridge.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Use PHBs to fill holes in PCI bus numbering
Andrea Bolognani [Fri, 26 May 2017 17:34:21 +0000 (19:34 +0200)]
qemu: Use PHBs to fill holes in PCI bus numbering

PCI bus has to be numbered sequentially, and no index can be
missing, so libvirt will fill in the blanks automatically for
the user.

Up until now, it has done so using either pci-bridge, for machine
types based on legacy PCI, or pcie-root-port, for machine types
based on PCI Express. Neither choice is good for pSeries guests,
where PHBs (pci-root) should be used instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Add baseline tests for automatic PHB usage
Andrea Bolognani [Fri, 26 May 2017 16:33:36 +0000 (18:33 +0200)]
tests: Add baseline tests for automatic PHB usage

These tests demonstrate that, while it's now possible for the
user to create PHB explicitly and manually assign devices to
them, libvirt still defaults to extending the guest PCI
topology using PCI bridges and making suboptimal device
placement choices.

The next few commits will improve on these behaviors and the
tests outputs will automatically be updated to reflect this.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Add tests for pSeries guests with multiple PHBs
Andrea Bolognani [Mon, 20 Feb 2017 17:20:26 +0000 (18:20 +0100)]
tests: Add tests for pSeries guests with multiple PHBs

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Take all PHBs into account while calculating memlock limits
Shivaprasad G Bhat [Fri, 30 Jun 2017 08:26:08 +0000 (13:56 +0530)]
qemu: Take all PHBs into account while calculating memlock limits

Now that the multi-phb support series is in, work on the TODO at
qemuDomainGetMemLockLimitBytes() to arrive at the correct memlock limit
value.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Format additional PHBs on the command line
Andrea Bolognani [Tue, 28 Feb 2017 09:50:01 +0000 (10:50 +0100)]
qemu: Format additional PHBs on the command line

Additional PHBs (pci-root controllers) will be created for
the guest using the spapr-pci-host-bridge QEMU device, if
available; the implicit default PHB, while present in the
guest configuration, will be skipped.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Deal with PHB naming conventions
Andrea Bolognani [Wed, 1 Mar 2017 14:49:31 +0000 (15:49 +0100)]
qemu: Deal with PHB naming conventions

Usually, a controller with alias 'x' will create a bus with the
same name; however, the bus created by a PHBs with alias 'x' will
be named 'x.0' instead, so we need to account for that.

As an exception to the exception, the implicit PHB that's added
automatically to every pSeries guest creates the 'pci.0' bus.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Introduce QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE
Andrea Bolognani [Mon, 20 Feb 2017 14:34:51 +0000 (15:34 +0100)]
qemu: Introduce QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE

This new capability can be used to detect whether a QEMU
binary supports the spapr-pci-host-bridge controller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Automatically pick target index and model for pci-root controllers
Andrea Bolognani [Tue, 28 Feb 2017 13:58:33 +0000 (14:58 +0100)]
qemu: Automatically pick target index and model for pci-root controllers

pSeries guests will soon need the new information; luckily,
we can figure it out automatically most of the time, so
users won't have to worry about it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Parse and format <target index='...'/>
Andrea Bolognani [Wed, 22 Feb 2017 10:42:19 +0000 (11:42 +0100)]
conf: Parse and format <target index='...'/>

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Add 'spapr-pci-host-bridge' controller model
Andrea Bolognani [Tue, 28 Feb 2017 13:58:08 +0000 (14:58 +0100)]
conf: Add 'spapr-pci-host-bridge' controller model

Adding it to the virDomainControllerPCIModelName enumeration
is enough for existing code to handle it, so parsing and
formatting will work without further tweaking.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Relax pci-root index requirement for pSeries guests
Andrea Bolognani [Mon, 27 Feb 2017 19:18:32 +0000 (20:18 +0100)]
qemu: Relax pci-root index requirement for pSeries guests

pSeries guests will soon be allowed to have multiple
PHBs (pci-root controllers), meaning the current check
on the controller index no longer applies to them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Move index number checking to drivers
Andrea Bolognani [Fri, 24 Feb 2017 15:45:13 +0000 (16:45 +0100)]
conf: Move index number checking to drivers

pSeries guests will soon be allowed to have multiple
PHBs (pci-root controllers), which of course means that
all but one of them will have a non-zero index; hence,
we'll need to relax the current check.

However, right now the check is performed in the conf
module, which is generic rather than tied to the QEMU
driver, and where we don't have information such as the
guest machine type available.

To make this change of behavior possible down the line,
we need to move the check from the XML parser to the
drivers. Luckily, only QEMU and bhyve are using PCI
controllers, so this doesn't result in much duplication.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Tweak index number checking
Andrea Bolognani [Tue, 28 Feb 2017 09:49:35 +0000 (10:49 +0100)]
qemu: Tweak index number checking

Moving the check and rewriting it this way doesn't alter
the current behavior, but will allow us to special-case
pci-root down the line.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Allow qemuBuildControllerDevStr() to return NULL
Andrea Bolognani [Tue, 28 Feb 2017 09:46:30 +0000 (10:46 +0100)]
qemu: Allow qemuBuildControllerDevStr() to return NULL

We will soon need to be able to return a NULL pointer
without the caller considering that an error: to make
it possible, change the return type to int and use
an out parameter for the string instead.

Add some documentation for the function as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Simplify slot allocation
Andrea Bolognani [Thu, 1 Jun 2017 13:18:50 +0000 (15:18 +0200)]
conf: Simplify slot allocation

The current algorithm for slot allocation tries to be clever
and avoid looking at buses / slots more than once unless it's
necessary. Unfortunately that makes the code more complex,
and it will cause problem later on in some situations unless
even more complex code is added.

Since the performance gains are going to be pretty modest
anyway, we can just get rid of the extra complexity and use a
completely  straighforward implementation instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Mock IOMMU groups
Andrea Bolognani [Thu, 1 Jun 2017 16:48:52 +0000 (18:48 +0200)]
tests: Mock IOMMU groups

Later on we're going to need access to information about IOMMU
groups for host devices. Implement the support in virpcimock,
and start using that mock library in a few QEMU test cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Update qemumemlock data
Andrea Bolognani [Thu, 1 Jun 2017 16:51:06 +0000 (18:51 +0200)]
tests: Update qemumemlock data

Use 0001:01:00.0 instead of 0000:04:02.0 as the source address
for the host device. This doesn't change anything at the moment,
but it will make a difference later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Clean up qemuDomainAttachHostPCIDevice()
Andrea Bolognani [Mon, 5 Jun 2017 13:29:40 +0000 (15:29 +0200)]
qemu: Clean up qemuDomainAttachHostPCIDevice()

We use hostdev->info frequently enough that having
a shorter name for it makes the code more readable.
We will also be adding even more uses later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Tweak virDomainPCIAddressGetNextAddr() signature
Andrea Bolognani [Mon, 29 May 2017 12:05:54 +0000 (14:05 +0200)]
conf: Tweak virDomainPCIAddressGetNextAddr() signature

Move @function after @flags to match other functions in the
same module like virDomainPCIAddressReserveNextAddr().

Also move virDomainPCIAddressReserveNextAddr() closer to
virDomainPCIAddressReserveAddr() in the header file.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>