Commit Graph

26833 Commits

Author SHA1 Message Date
Shivaprasad G Bhat
11b2ebf3e1 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>
2017-07-21 15:46:29 +02:00
Shivaprasad G Bhat
eb56cc6f88 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>
2017-07-21 15:46:29 +02:00
Andrea Bolognani
6c2c04e757 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>
2017-07-21 14:02:17 +02:00
Michal Privoznik
f4cb85c6af 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>
2017-07-21 12:46:18 +02:00
Peter Krempa
e04d1074f8 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.
2017-07-20 16:14:50 +02:00
Peter Krempa
9f3e65fc7a qemu: process: Extract gathering of 'numad' placement into a function
Remove the code from qemuProcessPrepareDomain so that it won't get even
more bloated.
2017-07-20 16:14:50 +02:00
Peter Krempa
95d5601018 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.
2017-07-20 16:14:50 +02:00
Peter Krempa
2dda319a9f qemu: domain: Extract parsing and formatting of priv->autoNodeset
Move the code to separate functions to avoid complicating the existing
ones with changes.
2017-07-20 16:14:50 +02:00
Peter Krempa
a908e9e45e util: bitmap: Modify virBitmapSubtract to virBitmapIntersect
Since virBitmapSubtract is unused modify it to perform bitmap
intersection.
2017-07-20 16:14:50 +02:00
John Ferlan
f4258298d3 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
2017-07-20 10:08:27 -04:00
John Ferlan
b913c8f453 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
2017-07-20 10:08:27 -04:00
Antoine Millet
e484cb3eca 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>
2017-07-20 15:15:03 +02:00
Antoine Millet
695611f99e 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>
2017-07-20 15:15:03 +02:00
Cole Robinson
efdfd1c5bf security: Don't overwrite error of GetProcessLabel
Security impls of this function already raise errors, don't
overwrite them.
2017-07-20 08:10:21 -04:00
Pavel Hrdina
7fb4c471d1 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>
2017-07-20 14:02:53 +02:00
Pavel Hrdina
56a047a67e 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>
2017-07-20 14:02:32 +02:00
Pavel Hrdina
7fcf66cf63 qemu: move libvirt ctime and version check into virQEMUCapsIsValid
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2017-07-20 14:02:14 +02:00
Pavel Hrdina
f2dd7259b4 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>
2017-07-20 14:02:14 +02:00
Pavel Hrdina
a63ef87709 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>
2017-07-20 14:02:14 +02:00
Pavel Hrdina
38e516a524 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>
2017-07-20 14:02:14 +02:00
Chen Hanxiao
84359339c5 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>
2017-07-20 13:21:54 +02:00
Hao Peng
fed9cc85ea 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>
2017-07-20 10:17:18 +01:00
Peter Krempa
703abf1d79 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.
2017-07-20 10:07:48 +02:00
Peter Krempa
5f14a0f2fb 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.
2017-07-20 10:07:48 +02:00
Peter Krempa
f8b6c11ab8 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.
2017-07-20 10:07:48 +02:00
Peter Krempa
060d4ec6a0 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.
2017-07-20 10:07:48 +02:00
Peter Krempa
a805320b67 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.
2017-07-20 10:07:48 +02:00
Chen Hanxiao
75107ae516 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>
2017-07-20 09:48:54 +02:00
Neal Gompa
9af764e86a 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>
2017-07-19 12:39:20 -04:00
Peter Krempa
99eac2668c 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.
2017-07-19 17:59:09 +02:00
Peter Krempa
6e51642bd2 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.).
2017-07-19 17:59:09 +02:00
ZhiPeng Lu
65bacb9181 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>
2017-07-19 16:49:51 +02:00
ZhiPeng Lu
8c1f25438e 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>
2017-07-19 16:47:10 +02:00
Peter Krempa
0c02071b56 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.
2017-07-19 15:24:10 +02:00
Peter Krempa
85f7620212 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.
2017-07-19 15:24:10 +02:00
Peter Krempa
0a2866b42a 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.
2017-07-19 15:24:10 +02:00
Ján Tomko
255cd95aab 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.
2017-07-19 10:27:07 +02:00
Wang King
057c2fba1c 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>
2017-07-19 10:07:21 +02:00
Peter Krempa
5e515b542d 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>
2017-07-19 09:54:51 +02:00
Michal Privoznik
8ae82e676a 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>
2017-07-19 09:46:17 +02:00
Jim Fehlig
b494e09d05 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
2017-07-18 11:39:52 -06:00
Michal Privoznik
ec91064169 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>
2017-07-18 15:37:38 +02:00
Boris Fiuczynski
d2f6bebf5c 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>
2017-07-18 13:52:48 +02:00
John Ferlan
0a957dd181 nodedev: Fix call to virNodeDeviceObjListFree in nodeStateReload
Commit id '9c5d98fd8' missed changing this call to use driver->devs
rather than @driver->devs.
2017-07-18 07:19:05 -04:00
Andrea Bolognani
5d32b5db3c news: Update for hostdev isolation
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2017-07-18 09:00:13 +02:00
Andrea Bolognani
b84b6ab502 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>
2017-07-18 09:00:13 +02:00
Andrea Bolognani
209dc615e8 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>
2017-07-18 09:00:13 +02:00
Andrea Bolognani
b8b6abbcd4 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>
2017-07-18 09:00:13 +02:00
John Ferlan
dae23ec345 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>
2017-07-17 10:40:24 -04:00
John Ferlan
960d665c1e 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>
2017-07-17 10:40:24 -04:00