]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agonode_device: refactor address retrieval of node device
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:41 +0000 (18:59 +0100)] 
node_device: refactor address retrieval of node device

Use switch statements instead of if-else condition in the method
nodeDeviceFindAddressByName to retrieve address of a node device.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirsh: nodedev: filter by AP Matrix capability
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:40 +0000 (18:59 +0100)] 
virsh: nodedev: filter by AP Matrix capability

Add support to filter by 'ap_matrix' capability.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: AP matrix node device
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:39 +0000 (18:59 +0100)] 
tests: AP matrix node device

Add tests to verify libvirt node device driver support for AP matrix
device.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: detect AP matrix device
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:38 +0000 (18:59 +0100)] 
nodedev: detect AP matrix device

Add support for AP matrix device in libvirt node device driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#the-design

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirsh: nodedev: Filter by AP card and AP queue capabilities
Farhan Ali [Thu, 3 Dec 2020 17:59:37 +0000 (18:59 +0100)] 
virsh: nodedev: Filter by AP card and AP queue capabilities

Add support to filter by 'ap_card' and 'ap_queue' capabilities.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: AP queue node device
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:36 +0000 (18:59 +0100)] 
tests: AP queue node device

Add tests to verify libvirt node device driver support for AP queues

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: detect AP queues
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:35 +0000 (18:59 +0100)] 
nodedev: detect AP queues

Each AP card device can support upto 256 AP queues.  AP queues are
also detected by udev, so add support for libvirt nodedev driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: AP card node device
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:34 +0000 (18:59 +0100)] 
tests: AP card node device

Add tests to verify libvirt node device driver support for AP card
device.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: detect AP card device
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:33 +0000 (18:59 +0100)] 
nodedev: detect AP card device

Introduce support for the Adjunct Processor (AP) crypto card device.
Udev already detects the device, so add support for libvirt nodedev
driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodomain_conf.c: move idmapEntry checks to domain_validate.c
Daniel Henrique Barboza [Mon, 7 Dec 2020 12:48:08 +0000 (09:48 -0300)] 
domain_conf.c: move idmapEntry checks to domain_validate.c

Create a new function called virDomainDefIdMapValidate() and
use it to move these checks out of virDomainIdmapDefParseXML()
and virDomainDefParseXML().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move pci-root/pcie-root address check to domain_validate.c
Daniel Henrique Barboza [Tue, 8 Dec 2020 21:01:37 +0000 (18:01 -0300)] 
domain_conf: move pci-root/pcie-root address check to domain_validate.c

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move virDomainPCIControllerOpts checks to domain_validate.c
Daniel Henrique Barboza [Fri, 4 Dec 2020 21:11:51 +0000 (18:11 -0300)] 
domain_conf: move virDomainPCIControllerOpts checks to domain_validate.c

virDomainControllerDefParseXML() does a lot of checks with
virDomainPCIControllerOpts parameters that can be moved to
virDomainControllerDefValidate, sharing the logic with other use
cases that does not rely on XML parsing.

'pseries-default-phb-numa-node' parse error was changed to reflect
the error that is being thrown by qemuValidateDomainDeviceDefController()
via deviceValidateCallback, that is executed before
virDomainControllerDefValidate().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move virDomainControllerDefValidate() to domain_validate.c
Daniel Henrique Barboza [Tue, 8 Dec 2020 20:52:24 +0000 (17:52 -0300)] 
domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c

Next patch will add more validations to this function. Let's move
it to domain_validate.c beforehand.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move blkio path check to domain_validate.c
Daniel Henrique Barboza [Fri, 4 Dec 2020 14:28:31 +0000 (11:28 -0300)] 
domain_conf.c: move blkio path check to domain_validate.c

Move this check to a new virDomainDefTunablesValidate(), which
is called by virDomainDefValidateInternal().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move smartcard address check to domain_validate.c
Daniel Henrique Barboza [Tue, 8 Dec 2020 20:37:28 +0000 (17:37 -0300)] 
domain_conf.c: move smartcard address check to domain_validate.c

This check is not tied to XML parsing and can be moved to
virDomainSmartcardDefValidate().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move all ChrSource checks to domain_validate.c
Daniel Henrique Barboza [Tue, 8 Dec 2020 20:32:23 +0000 (17:32 -0300)] 
domain_conf: move all ChrSource checks to domain_validate.c

Next patch will move a validation to virDomainSmartcardDefValidate(),
but this function can't be moved alone to domain_validate.c without
making virDomainChrSourceDefValidate(), from domain_conf.c, public.

Given that the idea is to eventually move all validations to domain_validate.c
anyways, let's move all ChrSource related validations in a single punch.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_validate.c: rename virSecurityDeviceLabelDefValidateXML()
Daniel Henrique Barboza [Tue, 8 Dec 2020 20:21:38 +0000 (17:21 -0300)] 
domain_validate.c: rename virSecurityDeviceLabelDefValidateXML()

The function isn't doing XML validation of any sort. Rename it to
be compatible with its actual use.

While we're at it, change the VIR_ERR_XML_ERROR error being thrown
in the function to VIR_ERR_CONFIG_UNSUPPORTED.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move vendor, product and tray checks to domain_validate.c
Daniel Henrique Barboza [Thu, 3 Dec 2020 16:54:58 +0000 (13:54 -0300)] 
domain_conf: move vendor, product and tray checks to domain_validate.c

The 'tray' check isn't a XML parse specific code and can be pushed
to the validate callback, in virDomainDiskDefValidate().

'vendor' and 'product' string sizes are already checked by the
domaincommon.rng schema, but can be of use in the validate callback
since not all scenarios will go through the XML parsing.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move virDomainDiskDefValidate() to domain_validate.c
Daniel Henrique Barboza [Tue, 8 Dec 2020 20:04:05 +0000 (17:04 -0300)] 
domain_conf: move virDomainDiskDefValidate() to domain_validate.c

Next patch will add more validations to the function. Let's move
it beforehand to domain_validate.c.

virSecurityDeviceLabelDefValidateXML() is still used inside
domain_conf.c, so make it public for now until its current
caller (virDomainChrSourceDefValidate()) is also moved to
domain_validate.c.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move QXL attributes check to virDomainVideoDefValidate()
Daniel Henrique Barboza [Wed, 2 Dec 2020 20:36:28 +0000 (17:36 -0300)] 
domain_conf.c: move QXL attributes check to virDomainVideoDefValidate()

These checks are not related to XML parsing and can be moved to the
validate callback. Errors were changed from VIR_ERR_XML_ERROR to
VIR_ERR_CONFIG_UNSUPPORTED.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move virDomainVideoDefValidate() to domain_validate.c
Daniel Henrique Barboza [Tue, 8 Dec 2020 19:45:25 +0000 (16:45 -0300)] 
domain_conf.c: move virDomainVideoDefValidate() to domain_validate.c

We'll add more video validations into the function in the next
patch. Let's move it beforehand to domain_validate.c.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move primary video check to validate callback
Daniel Henrique Barboza [Wed, 2 Dec 2020 20:23:02 +0000 (17:23 -0300)] 
domain_conf.c: move primary video check to validate callback

This check isn't exclusive to XML parsing. Let's move it to
virDomainDefVideoValidate() in domain_validate.c

We don't have a failure test for this scenario, so a new test called
'video-multiple-primaries' was added to test this failure case.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move boot timeouts check to domain_validate.c
Daniel Henrique Barboza [Wed, 2 Dec 2020 19:48:34 +0000 (16:48 -0300)] 
domain_conf: move boot timeouts check to domain_validate.c

This patch creates a new function, virDomainDefBootValidate(), to host
the validation of boot menu timeout and rebootTimeout outside of parse
time. The checks in virDomainDefParseBootXML() were changed to throw
VIR_ERR_XML_ERROR in case of parse error of those values.

In an attempt to alleviate the amount of code being stacked inside
domain_conf.c, let's put this new function in a new domain_validate.c
file that will be used to place these validations.

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: Fix logic bug in inactive snapshot deletion
Peter Krempa [Wed, 9 Dec 2020 09:08:53 +0000 (10:08 +0100)] 
qemu: Fix logic bug in inactive snapshot deletion

Commit 926563dc3a6 which refactored the function call deleting the
snapshot's on disk state introduced a logic bug, which skips over the
deletion of libvirt metadata after the disk state deletion is done.

To fix it we must not return early.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/109
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Simplify size check for ppc64 NVDIMMs
Andrea Bolognani [Wed, 2 Dec 2020 18:08:45 +0000 (19:08 +0100)] 
qemu: Simplify size check for ppc64 NVDIMMs

We already calculated the guest area, which is what is subject
to minimum size requirements, a few lines earlier.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: validate: Prefer existing qemuCaps
Peter Krempa [Tue, 8 Dec 2020 13:27:59 +0000 (14:27 +0100)] 
qemu: validate: Prefer existing qemuCaps

The validation callback always fetched a fresh copy of 'qemuCaps' to use
for validation which is wrong in cases when the VM is already running,
such as device hotplug. The newly-fetched qemuCaps may contain flags
which weren't originally in use when starting the VM e.g. on a libvirtd
upgrade.

Since the post-parse/validation machinery has a per-run 'parseOpaque'
field filled with qemuCaps of the actual process we can reuse the caps
in cases when we get them.

The code still fetches a fresh copy if parseOpaque doesn't have a
per-run copy to preserve existing functionality.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuValidateDomainDeviceDefFS: Fix block indentation
Peter Krempa [Tue, 8 Dec 2020 13:22:51 +0000 (14:22 +0100)] 
qemuValidateDomainDeviceDefFS: Fix block indentation

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: validate: Don't check that qemuCaps is non-NULL
Peter Krempa [Tue, 8 Dec 2020 13:22:18 +0000 (14:22 +0100)] 
qemu: validate: Don't check that qemuCaps is non-NULL

The validation callbacks always fetch latest qemuCaps so it won't ever
be NULL. Remove the tautological conditions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainDefValidate: Add per-run 'opaque' data
Peter Krempa [Tue, 8 Dec 2020 13:11:13 +0000 (14:11 +0100)] 
virDomainDefValidate: Add per-run 'opaque' data

virDomainDefPostParse infrastructure has apart from the global opaque
data also per-run data, but this was not duplicated into the validation
callbacks.

This is important when drivers want to use correct run-state for the
validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agogitlab: replace "libvirt-" prefix with "ci-" in dockerfiles
Daniel P. Berrangé [Tue, 1 Dec 2020 15:22:09 +0000 (15:22 +0000)] 
gitlab: replace "libvirt-" prefix with "ci-" in dockerfiles

This makes the dockerfile name match the output container name

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agogitlab: refresh containers with lcitool for fully minimized base
Daniel P. Berrangé [Mon, 23 Nov 2020 18:20:57 +0000 (18:20 +0000)] 
gitlab: refresh containers with lcitool for fully minimized base

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agogitlab: re-generate container images from lcitool
Daniel P. Berrangé [Mon, 23 Nov 2020 18:03:36 +0000 (18:03 +0000)] 
gitlab: re-generate container images from lcitool

This introduces Fedora 33 and removes some redundant packages.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemuBlockJobInfoTranslate: Take job type from qemuBlockJobDataPtr
Peter Krempa [Mon, 7 Dec 2020 16:53:21 +0000 (17:53 +0100)] 
qemuBlockJobInfoTranslate: Take job type from qemuBlockJobDataPtr

Commit f5e8715a8b4 added logic which adds some fake job info when qemu
didn't return anything but in such case the job type would not be set.

Since we already have the proper job type recorded in qemuBlockJobDataPtr
which the caller fetched, we can use this it and also remove the lookup
from the disk which was necessary prior to the conversion to
qemuBlockJobDataPtr.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuxml2argvtest: Add 'nvme' disks into the 'disk-slices' case
Peter Krempa [Tue, 14 Apr 2020 08:45:46 +0000 (10:45 +0200)] 
qemuxml2argvtest: Add 'nvme' disks into the 'disk-slices' case

Test slices on top of nvme-backed disks.

Note that the changes in seemingly irrelevant parts of the output are
due to re-naming the nodenames.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: backup: Format index of 'store'
Peter Krempa [Mon, 7 Dec 2020 11:38:50 +0000 (12:38 +0100)] 
conf: backup: Format index of 'store'

Similarly to other disk-related stuff, the index is useful when you want
to refer to the image in APIs such as virDomainSetBlockThreshold.

For internal use we also need to parse it inside of the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainGetStorageSourceByDevstr: Lookup also backup 'store' nodenames
Peter Krempa [Mon, 7 Dec 2020 11:38:43 +0000 (12:38 +0100)] 
qemuDomainGetStorageSourceByDevstr: Lookup also backup 'store' nodenames

Nodename may be asociated to a disk backup job, add support to looking
up in that chain too. This is specifically useful for the
BLOCK_WRITE_THRESHOLD event which can be registered for any nodename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainDiskLookupByNodename: Lookup also backup 'store' nodenames
Peter Krempa [Mon, 7 Dec 2020 11:38:43 +0000 (12:38 +0100)] 
qemuDomainDiskLookupByNodename: Lookup also backup 'store' nodenames

Nodename may be asociated to a disk backup job, add support to looking
up in that chain too. This is specifically useful for the
BLOCK_WRITE_THRESHOLD event which can be registered for any nodename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainBackupDiskDefParseXML: Use virDomainStorageSourceParseBase
Peter Krempa [Mon, 7 Dec 2020 13:03:22 +0000 (14:03 +0100)] 
virDomainBackupDiskDefParseXML: Use virDomainStorageSourceParseBase

Don't duplicate code to parse the virStorageSource basics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agobackup: Move file format check from parser to qemu driver
Peter Krempa [Mon, 7 Dec 2020 16:05:40 +0000 (17:05 +0100)] 
backup: Move file format check from parser to qemu driver

It's a technical detail in qemu that QCOW2 is needed for a pull-mode
backup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainGetStorageSourceByDevstr: Avoid logged errors
Peter Krempa [Mon, 7 Dec 2020 12:19:18 +0000 (13:19 +0100)] 
qemuDomainGetStorageSourceByDevstr: Avoid logged errors

'virStorageFileChainLookup' reports an error when the lookup of the
backing chain entry is unsuccessful. Since we possibly use it multiple
times when looking up backing for 'disk->mirror' the function can report
error which won't be actually reported.

Replace the call to virStorageFileChainLookup by lookup in the chain by
index.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainGetStorageSourceByDevstr: Use virDomainDiskByTarget
Peter Krempa [Mon, 7 Dec 2020 12:04:29 +0000 (13:04 +0100)] 
qemuDomainGetStorageSourceByDevstr: Use virDomainDiskByTarget

The function replaces the open-coded block.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainDiskLookupByNodename: Simplify node name lookup
Peter Krempa [Mon, 7 Dec 2020 11:24:31 +0000 (12:24 +0100)] 
qemuDomainDiskLookupByNodename: Simplify node name lookup

Use dummy variable to fill 'src' so that access to it doesn't need to be
conditionalized and use temporary variable for 'disk' rather than
dereferencing the array multiple times.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh: cmdSetUserSSHKeys: Error early if the file doesn't contain any keys
Michal Privoznik [Tue, 8 Dec 2020 12:42:40 +0000 (13:42 +0100)] 
virsh: cmdSetUserSSHKeys: Error early if the file doesn't contain any keys

When removing SSH keys via set-user-sshkeys virsh command, then
files to remove are read from passed file. But when
experimenting, I've passed /dev/null as the file which resulted
in API checks which caught that @keys argument of
virDomainAuthorizedSSHKeysSet() can't be NULL. This is because if
the file is empty then its content is an empty string and thus
the buffer the file was read in to is not NULL.

Long story short, error is reported correctly, but it's not
necessary to go through public API to catch it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh: Fix logical error in cmdSetUserSSHKeys()
Michal Privoznik [Tue, 8 Dec 2020 12:42:28 +0000 (13:42 +0100)] 
virsh: Fix logical error in cmdSetUserSSHKeys()

In v6.10.0-rc1~104 I've added a virsh command that exposes
virDomainAuthorizedSSHKeysSet() API under "set-user-sshkeys"
command. The command accepts mutually exclusive "--reset" and
"--remove" options (among others). While the former controls the
VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_APPEND flag, the latter
controls the VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_REMOVE flag.
These flags are also mutually exclusive. But the code that sets
them has a logical error which may result in both flags being
set. In fact, this results in user being not able to set just the
remove flag.

Fixes: 87d12effbea8b414c250b6fefd93154c62a99370
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1904674
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: add missing FSF copyright statement
Daniel P. Berrangé [Tue, 8 Dec 2020 09:35:15 +0000 (09:35 +0000)] 
util: add missing FSF copyright statement

We previous added code for passing FDs which was explicitly derived from
gnulib's passfd code:

  commit 17460825f3c78e1635f2beb0165c5a19e3b09f7d
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Fri Jan 17 11:57:17 2020 +0000

    src: implement APIs for passing FDs over UNIX sockets

    This is a simplified variant of gnulib's passfd module
    without the portability code that we do not require.

while the license was unchanged, we mistakenly failed to copy the FSF
copyright header which is required by the license terms.

Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoxen: recognize device_model_override
Olaf Hering [Fri, 20 Nov 2020 12:29:14 +0000 (13:29 +0100)] 
xen: recognize device_model_override

Since Xen 4.2 libxl expects device_model_override="/path" instead of
device_model="/path". Adjust the code to parse this as <emulator>.

While libxl also recognizes device_model_version="", this knob is not
required for libvirt. A runtime detection exists in libvirt to select
either "qemu-xen" or "qemu-xen-traditional".
Since qemu-xen-traditional is marked as supported just for stubdoms
there is no need to handle it.

Test data files with 'device_model' were adjusted to use
'device_model_override' instead.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
4 years agolxc: Set default security model in XML parser config
Jim Fehlig [Thu, 3 Dec 2020 18:55:24 +0000 (11:55 -0700)] 
lxc: Set default security model in XML parser config

Attempting to create a lxc domain with <seclabel type='none'/> fails

virsh --connect lxc:/// create distro_nosec.xml
error: Failed to create domain from distro_nosec.xml
error: unsupported configuration: Security driver model '(null)' is not available

Commit 638ffa2228 adjusted the logic for setting a driver's default
security model.

The lxc driver does not set a default security driver model in the XML
parser config, causing seclabels of type='none' to have a null model.
The lxc driver's security manager is initialized in lxcStateInitialize()
by calling lxcSecurityInit(). Use the model of this manager as the
default in the XML parser config.

For the record, this is a regression caused by commit 638ffa2228, which
changed the logic for setting a driver's default security model. The
qemu driver was adjusted accordingly, but a similar change was missed
in the lxc driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: sync_qemu_cpu_i386: Detect features missing in libvirt
Tim Wiederhake [Mon, 23 Nov 2020 14:14:29 +0000 (15:14 +0100)] 
cpu_map: sync_qemu_cpu_i386: Detect features missing in libvirt

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: sync_qemu_cpu_i386: Add missing features to translation table
Tim Wiederhake [Mon, 23 Nov 2020 14:14:28 +0000 (15:14 +0100)] 
cpu_map: sync_qemu_cpu_i386: Add missing features to translation table

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: sync_qemu_cpu_i386: Simplify ignore features
Tim Wiederhake [Mon, 23 Nov 2020 14:14:27 +0000 (15:14 +0100)] 
cpu_map: sync_qemu_cpu_i386: Simplify ignore features

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: sync_qemu_cpu_i386: Translate features in model versions
Tim Wiederhake [Mon, 23 Nov 2020 14:14:26 +0000 (15:14 +0100)] 
cpu_map: sync_qemu_cpu_i386: Translate features in model versions

If a feature is added (or removed) in a QEMU CPU model version, we
get to see the QEMU pretty name for the feature, not the name of
the macro.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: sync_qemu_cpu_i386: Factor out translation of features
Tim Wiederhake [Mon, 23 Nov 2020 14:14:25 +0000 (15:14 +0100)] 
cpu_map: sync_qemu_cpu_i386: Factor out translation of features

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: sync_qemu_cpu_i386: Factor out translation of vendors
Tim Wiederhake [Mon, 23 Nov 2020 14:14:24 +0000 (15:14 +0100)] 
cpu_map: sync_qemu_cpu_i386: Factor out translation of vendors

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agorpm: convert mingw spec to meson
Daniel P. Berrangé [Wed, 2 Dec 2020 11:29:25 +0000 (11:29 +0000)] 
rpm: convert mingw spec to meson

The meson build system is configured to only ever build shared
libraries, so we delete the -static sub-RPMs.

The few driver conditionals are deleted as there was never any
scenario in which their value changed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibvirt-guests: Remove obsolete Windows comment
Kevin Locke [Sun, 6 Dec 2020 16:00:07 +0000 (09:00 -0700)] 
libvirt-guests: Remove obsolete Windows comment

The comment that

> For instance, qemu-ga doesn't support guest time synchronization on
> Windows guests, but Linux ones.

Was correct at the time, but has since been addressed by
qemu/qemu@105fad6bb22, which added support for set-time without a time
argument, as used by `virsh domtime --sync` by libvirt-guests.sh.  I can
confirm that `virsh domtime --sync` works correctly on a Windows 10
guest, as does `SYNC_TIME=1`.  (Note that there can be a significant
delay between when the command completes and when the guest time
finishes synchronizing due to QEMU GA calling `w32tm` with `/nowait`,
which complicates testing.)

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
4 years agoqemu: Don't cache NUMA caps
Michal Privoznik [Wed, 2 Dec 2020 08:26:30 +0000 (09:26 +0100)] 
qemu: Don't cache NUMA caps

In v6.0.0-rc1~439 (and friends) we tried to cache NUMA
capabilities because we assumed they are immutable. And to some
extent they are (NUMA hotplug is not a thing, is it). However,
our capabilities contain also some runtime info that can change,
e.g. hugepages pool allocation sizes or total amount of memory
per node (host side memory hotplug might change the value).

Because of the caching we might not be reporting the correct
runtime info in 'virsh capabilities'.

The NUMA caps are used in three places:

  1) 'virsh capabilities'
  2) domain startup, when parsing numad reply
  3) parsing domain private data XML

In cases 2) and 3) we need NUMA caps to construct list of
physical CPUs that belong to NUMA nodes from numad reply. And
while this may seem static, it's not really because of possible
CPU hotplug on physical host.

There are two possible approaches:

  1) build a validation mechanism that would invalidate the
     cached NUMA caps, or
  2) drop the caching and construct NUMA caps from scratch on
     each use.

In this commit, the latter approach is implemented, because it's
easier.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1819058
Fixes: 1a1d848694f6c2f1d98a371124928375bc3bb4a3
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemuDomainGetBlockJobInfo: Work stats for unfinished pre-blockdev blockjob
Peter Krempa [Fri, 4 Dec 2020 15:08:02 +0000 (16:08 +0100)] 
qemuDomainGetBlockJobInfo: Work stats for unfinished pre-blockdev blockjob

If the job has finished, but we didn't yet process the completion fake
that it's still incomplete so that apps which decided to poll
qemuDomainGetBlockJobInfo rather than use events can be sure that the
XML update was completed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: monitor: Remove unused qemuMonitorGetBlockJobInfo
Peter Krempa [Fri, 4 Dec 2020 15:08:01 +0000 (16:08 +0100)] 
qemu: monitor: Remove unused qemuMonitorGetBlockJobInfo

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuDomainGetBlockJobInfo: Use qemuMonitorGetAllBlockJobInfo
Peter Krempa [Fri, 4 Dec 2020 15:08:00 +0000 (16:08 +0100)] 
qemuDomainGetBlockJobInfo: Use qemuMonitorGetAllBlockJobInfo

Replace qemuMonitorGetBlockJobInfo by qemuMonitorGetAllBlockJobInfo and
hash table lookup. This basically open-codes qemuMonitorGetBlockJobInfo,
but it will be removed in next patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuBlockJobInfoTranslate: Use explicit comparison against 0
Peter Krempa [Fri, 4 Dec 2020 15:07:59 +0000 (16:07 +0100)] 
qemuBlockJobInfoTranslate: Use explicit comparison against 0

Using ! on integers is misleading.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorBlockJobInfo: Store 'ready' and 'ready_present' separately
Peter Krempa [Fri, 4 Dec 2020 15:07:58 +0000 (16:07 +0100)] 
qemuMonitorBlockJobInfo: Store 'ready' and 'ready_present' separately

Don't make the logic confusing by representing the 3 options using an
integer with negative values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainGetBlockJobInfo: Reword docs for fallback values
Peter Krempa [Fri, 4 Dec 2020 15:07:57 +0000 (16:07 +0100)] 
virDomainGetBlockJobInfo: Reword docs for fallback values

Explicitly state that if 'end == 1' the data doesn't represent actual
progress in most cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainGetBlockJobInfo: Discourage polling for block job completion detection
Peter Krempa [Fri, 4 Dec 2020 15:07:56 +0000 (16:07 +0100)] 
virDomainGetBlockJobInfo: Discourage polling for block job completion detection

Add a note saying that polling virDomainGetBlockJobInfo is not a good
idea. Use events instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agolxc: Cleanup after failed startup
Michal Privoznik [Wed, 11 Nov 2020 12:51:21 +0000 (13:51 +0100)] 
lxc: Cleanup after failed startup

If starting an container fails, the virLXCProcessStop() is
called. But since vm->def->id is not set until libvirt_lxc is
spawned (the domain's ID is PID of that process),
virLXCProcessStop() returns early as virDomainObjIsActive()
returns false. But doing so leaves behind resources reserved for
the containers during the startup process. Most notably, hostdevs
are not re-attached to the host, the domain's transient XML is
not removed, etc.

To resolve this, virLXCProcessCleanup() is called in this case.
However, it is modified to accept @flags which allows caller to
run only specific cleanups (depending how far in container
creation the failure occurred). There is plenty of cleanups which
don't need this guard because either they detect a NULL pointer
or try to release an unique resource.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoqemu_monitor_json: Don't leak "option" in qemuMonitorJSONGetCommandLineOptions()
Michal Privoznik [Mon, 7 Dec 2020 08:32:27 +0000 (09:32 +0100)] 
qemu_monitor_json: Don't leak "option" in qemuMonitorJSONGetCommandLineOptions()

In recent commit of bf8bd93df0 (and friends) we switched the way
we process queried command line arguments: from string lists to
virJSONValue stored in a hash table. To achieve this
qemuMonitorJSONGetCommandLineOptions() helper was introduced
which executes the "query-command-line-options" monitor command
and then calls virJSONValueArrayForeachSteal() to process the
output. The array process function is also given
qemuMonitorJSONGetCommandLineOptionsWorker() as the callback
which is called over each item of the returned array. This
callback then steals "parameters" attribute of each array iteam
storing it in the hash table, but it leaves behind "option"
attribute (because it's g_strdup()-ed). After all of this, the
callback returns 0 which is a signal to the array processing
function that the callback took ownership of the array item. But
this is not true. While it removed "parameters" it did not take
the rest ("option" for instance). And therefore, it leads to a
memory leak:

 5,347 (1,656 direct, 3,691 indirect) bytes in 69 blocks are definitely lost in loss record 2,752 of 2,794
 at 0x483BEC5: calloc (vg_replace_malloc.c:760)
 by 0x4E25A10: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6400.5)
 by 0x4943317: virJSONValueNewObject (virjson.c:569)
 by 0x4945692: virJSONParserHandleStartMap (virjson.c:1768)
 by 0x5825A86: yajl_do_parse (in /usr/lib64/libyajl.so.2.1.0)
 by 0x4945BFA: virJSONValueFromString (virjson.c:1896)
 by 0xAF5C115: qemuMonitorJSONIOProcessLine (qemu_monitor_json.c:224)
 by 0xAF5C45E: qemuMonitorJSONIOProcess (qemu_monitor_json.c:279)
 by 0xAF4BB6C: qemuMonitorIOProcess (qemu_monitor.c:342)
 by 0xAF4C444: qemuMonitorIO (qemu_monitor.c:574)
 by 0x4FEF846: socket_source_dispatch (in /usr/lib64/libgio-2.0.so.0.6400.5)
 by 0x4E1F727: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.5)

The callback must return 1 so that the array item is properly
freed.

Fixes: ebeff6cd57d07c89d42e191ed0085a9dd89835c5
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodomain_conf, qemu: move virDomainNVDimmAlignSizePseries to qemu_domain.c
Daniel Henrique Barboza [Fri, 4 Dec 2020 19:08:56 +0000 (16:08 -0300)] 
domain_conf, qemu: move virDomainNVDimmAlignSizePseries to qemu_domain.c

Since the function is now only used in qemu_domain.c, move it from
domain_conf.c and rename it.

This reverts the work done in commit ace5931553c87beebb6b3cd994061742b3f88238
(conf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c).

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu_domain.c: align all pSeries mem modules when PARSE_ABI_UPDATE
Daniel Henrique Barboza [Wed, 18 Nov 2020 19:58:34 +0000 (16:58 -0300)] 
qemu_domain.c: align all pSeries mem modules when PARSE_ABI_UPDATE

qemuDomainAlignMemorySizes() has an operation order problem. We are
calculating 'initialmem' without aligning the memory modules first.
Since we're aligning the dimms afterwards this can create inconsistencies
in the end result. x86 has alignment of 1-2MiB and it's not severely
impacted by it, but pSeries works with 256MiB alignment and the difference
is noticeable.

This is the case of the existing 'memory-hotplug-ppc64-nonuma' test.
The test consists of a 2GiB (aligned value) guest with 2 ~520MiB dimms,
both unaligned. 'initialmem' is calculated by taking total_mem and
subtracting the dimms size (via virDomainDefGetMemoryInitial()), which
wil give us 2GiB - 520MiB - 520MiB, ending up with a little more than
an 1GiB of 'initialmem'. Note that this value is now unaligned, and
will be aligned up via VIR_ROUND_UP(), and we'll end up with 'initialmem'
of 1GiB + 256MiB. Given that the dimms are aligned later on, the end
result for QEMU is that the guest will have a 'mem' size of 1310720k,
plus the two 512 MiB dimms, exceeding in 256MiB the desired 2GiB
memory and currentMemory specified in the XML.

Existing guests can't be fixed without breaking ABI, but we have
code already in place to align pSeries NVDIMM modules for new guests.
Let's extend it to align all pSeries mem modules.

A new test, 'memory-hotplug-ppc64-nonuma-abi-update', a copy of the
existing 'memory-hotplug-ppc64-nonuma', was added to demonstrate the
result for new pSeries guests. For the same unaligned XML mentioned
above, after applying this patch:

- starting QEMU mem size without PARSE_ABI_UPDATE:
    -m size=1310720k,slots=16,maxmem=4194304k \ (no changes)

- starting QEMU mem size with PARSE_ABI_UPDATE:
    -m size=1048576k,slots=16,maxmem=4194304k \ (size fixed)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu_domain.c: post parse pSeries NVDIMM align with PARSE_ABI_UPDATE
Daniel Henrique Barboza [Wed, 18 Nov 2020 19:58:33 +0000 (16:58 -0300)] 
qemu_domain.c: post parse pSeries NVDIMM align with PARSE_ABI_UPDATE

A previous patch removed the pSeries NVDIMM align that wasn't
being done properly. This patch reintroduces it in the right
fashion, making it reliant on VIR_DOMAIN_DEF_PARSE_ABI_UPDATE.
This makes it complying with the intended design defined by
commit c7d7ba85a624.

Since the PARSE_ABI_UPDATE is more restrictive than checking for
!migrate && !snapshot, like is being currently done with
qemuDomainAlignMemorySizes(), this means that we'll align the
pSeries NVDIMMs in two places - in post parse time for new
guests, and in qemuDomainAlignMemorySizes() for all guests
that aren't migrating or in a snapshot.

Another difference is that the logic is now in the QEMU driver
instead of domain_conf.c. This was necessary because all
considerations made about the PARSE_ABI_UPDATE flag were done
under QEMU. Given that no other driver supports ppc64 there is no
impact in this change.

A new test was added to exercise what we're doing. It consists
of a a copy of the existing 'memory-hotplug-nvdimm-ppc64' xml2xml
test, called with the PARSE_ABI_UPDATE flag. As intended, we're
not changing QEMU command line or any XML without the flag,
while the pseries NVDIMM memory is being aligned when the
flag is used.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoRevert "domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse()"
Daniel Henrique Barboza [Wed, 18 Nov 2020 19:58:31 +0000 (16:58 -0300)] 
Revert "domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse()"

The code to align ppc64 NVDIMMs on post parse was introduced in
commit d3f3c2c97f9b. That commit failed to realize that we
can't align memory unconditionally. As of commit c7d7ba85a624
("qemu: command: Align memory sizes only on fresh starts"),
all memory alignment should be executed only when we're not
migrating or in a snapshot.

This revert does not break any guests in the wild, given that
ppc64 NVDIMMs are still being aligned in qemuDomainAlignMemorySizes().

Next patch will introduce a mechanism where we can have post
parse NVDIMM alignment for pSeries without breaking the
intended design, as defined by c7d7ba85a624.

This reverts commit d3f3c2c97f9b92c982ff809479495f44614edb88.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoapparmor: Drop needless check in AppArmorSetMemoryLabel()
Michal Privoznik [Fri, 4 Dec 2020 15:04:16 +0000 (16:04 +0100)] 
apparmor: Drop needless check in AppArmorSetMemoryLabel()

The AppArmorSetMemoryLabel() is a callback that is called from
qemuSecuritySetMemoryLabel() which never passes NULL as @mem.
Therefore, there is no need to check whether @mem is NULL. Also,
no other driver does that and just dereference it immediately.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Drop @qemuCaps argument from qemuDomainDefValidateMemoryHotplug()
Michal Privoznik [Fri, 4 Dec 2020 13:50:48 +0000 (14:50 +0100)] 
qemu: Drop @qemuCaps argument from qemuDomainDefValidateMemoryHotplug()

After previous cleanup the @qemuCaps argument in
qemuDomainDefValidateMemoryHotplug() is unused and thus doesn't
need to be passed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agolibvirt_recover_xattrs: Allow fixing multiple PATHs
Peter Krempa [Wed, 2 Dec 2020 09:55:01 +0000 (10:55 +0100)] 
libvirt_recover_xattrs: Allow fixing multiple PATHs

Loop for multiple PATH arguments to support shell pattern expansion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolibvirt_recover_xattrs: Add unsafe operation mode
Peter Krempa [Thu, 26 Nov 2020 16:19:43 +0000 (17:19 +0100)] 
libvirt_recover_xattrs: Add unsafe operation mode

In some cases you want to fix a certain directory while you don't really
care whether there are other VMs running. Add a option to disable the
check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolibvirt_recover_xattrs: Use only the correct xattr prefix
Peter Krempa [Wed, 2 Dec 2020 09:24:21 +0000 (10:24 +0100)] 
libvirt_recover_xattrs: Use only the correct xattr prefix

Linux and FreeBSD have different prefix. In the current state we've
tried to reset the labels for both systems which resulted in errors like
this:

Fixing /tmp/bitmaps2.qcow2
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported

The 6 failed 'setfattrs' correspond to the wrong prefix.

Select the correct prefix based on the kernel name and modify the code
appropriately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolibvirt_recover_xattrs: Avoid backticks for subshell
Peter Krempa [Wed, 2 Dec 2020 08:57:30 +0000 (09:57 +0100)] 
libvirt_recover_xattrs: Avoid backticks for subshell

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_command: Move dimm into qemuBuildDeviceAddressStr()
Michal Privoznik [Tue, 3 Nov 2020 16:31:27 +0000 (17:31 +0100)] 
qemu_command: Move dimm into qemuBuildDeviceAddressStr()

So far our memory modules could go only into DIMM slots. But with
virtio model this assumption is no longer true - virtio-pmem goes
onto PCI bus. But for formatting PCI address onto command line we
already have a function - qemuBuildDeviceAddressStr(). Therefore,
mode DIMM address generation into it so that we don't have to
special case address building later on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agoqemu: Move mem validation into post parse validator
Michal Privoznik [Fri, 20 Nov 2020 08:49:18 +0000 (09:49 +0100)] 
qemu: Move mem validation into post parse validator

There is this function qemuDomainDefValidateMemoryHotplug() which
is called explicitly from hotplug path and the qemu's domain def
validator. This is not really necessary because we can move the
part that validates feature against qemuCaps into device
validator which is called implicitly (from qemu driver's POV).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agovirDomainMemoryTargetDefFormat: Utilize virXMLFormatElement()
Michal Privoznik [Fri, 20 Nov 2020 11:16:58 +0000 (12:16 +0100)] 
virDomainMemoryTargetDefFormat: Utilize virXMLFormatElement()

The virDomainMemoryTargetDefFormat() uses good old style of
formatting child buffer (virBufferAdjustIndent()). When switched
to virXMLFormatElement() we can save a couple of lines

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agovirDomainMemorySourceDefFormat: Utilize virXMLFormatElement()
Michal Privoznik [Sun, 1 Nov 2020 10:08:32 +0000 (11:08 +0100)] 
virDomainMemorySourceDefFormat: Utilize virXMLFormatElement()

The virDomainMemorySourceDefFormat() uses good old style of
formatting child buffer (virBufferAdjustIndent()). When switched
to virXMLFormatElement() we can save a couple of lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agodomain_conf: Fix virDomainMemoryModel type
Michal Privoznik [Sat, 31 Oct 2020 20:24:08 +0000 (21:24 +0100)] 
domain_conf: Fix virDomainMemoryModel type

The virDomainMemoryModel structure has a @type member which is
really type of virDomainMemoryModel but we store it as int
because the virDomainMemoryModelTypeFromString() call stores its
retval right into it. Then, to have compiler do compile time
check for us, every switch() typecasts the @type. This is
needlessly verbose because the parses already has @val - a
variable to store temporary values. Switch @type in the struct to
virDomainMemoryModel and drop all typecasts.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agoconf: Require nvdimm path in validate step
Michal Privoznik [Wed, 4 Nov 2020 15:09:39 +0000 (16:09 +0100)] 
conf: Require nvdimm path in validate step

Our code expects that a nvdimm has a path defined always. And the
parser does check for that. Well, not fully - only when parsing
<source/> (which is an optional element). So if the element is
not in the XML then the check is not performed and the assumption
is broken. Verify in the memory def validator that a path was
set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agoqemu_domain_address: Reformat qemuDomainAssignS390Addresses()
Michal Privoznik [Tue, 3 Nov 2020 14:49:02 +0000 (15:49 +0100)] 
qemu_domain_address: Reformat qemuDomainAssignS390Addresses()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agodomain_conf: Check NVDIMM UUID in ABI stability
Michal Privoznik [Wed, 25 Nov 2020 10:38:22 +0000 (11:38 +0100)] 
domain_conf: Check NVDIMM UUID in ABI stability

The UUID is guest visible and thus shouldn't change if we want to
not break guest ABI.

Fixes: 08ed673901bb5b4f419b37bcce9b11d31ce370e6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agodocs: Fix nvdimm example wrt to <uuid/>
Michal Privoznik [Mon, 2 Nov 2020 10:59:08 +0000 (11:59 +0100)] 
docs: Fix nvdimm example wrt to <uuid/>

On PPC platform it is required that a NVDIMM has an UUID. If none
is provided then libvirt generates one during parsing (see
v6.2.0-rc1~96 and friends). However, the example provided in our
documentation is not valid XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agointernal.h: Introduce and use VIR_IS_POW2()
Michal Privoznik [Wed, 4 Nov 2020 18:41:27 +0000 (19:41 +0100)] 
internal.h: Introduce and use VIR_IS_POW2()

This macro checks whether given number is an integer power of
two. At the same time, I've identified two places where we check
for pow2 and I'm replacing them with the macro.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agoviruuid: Rework virUUIDIsValid()
Michal Privoznik [Tue, 24 Nov 2020 10:12:27 +0000 (11:12 +0100)] 
viruuid: Rework virUUIDIsValid()

The only test we do when checking for UUID validity is that
whether all bytes are the same (invalid UUID) or not (valid
UUID). The algorithm we use is needlessly complicated.

Also, the checked UUID is not modified and hence the argument can
be of 'const' type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agoconf: checkpoint: Don't require <domain> when redefining checkpoints
Peter Krempa [Wed, 2 Dec 2020 13:18:40 +0000 (14:18 +0100)] 
conf: checkpoint: Don't require <domain> when redefining checkpoints

The domain definition stored with a checkpoint isn't used currently
apart from matching disks when creating a new checkpoints.

As some users of the incremental backup API want to provide backups in
offline mode under their control (obviously while compying with our
documentation on how the on-disk state should be handled) and then want
to define the checkpoint for live use, supplying a <domain> sub-element
is overly complex and not actually needed by the code.

Relax the restriction when re-defining a checkpoint so that <domain> is
not necessary and add (alibistic) documentation saying that future
actions may not work if it's missing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: checkpoint: Prepare internals for missing domain definition
Peter Krempa [Wed, 2 Dec 2020 13:13:17 +0000 (14:13 +0100)] 
conf: checkpoint: Prepare internals for missing domain definition

Conditionalize code which assumes that the domain definition stored in
the checkpoint is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirDomainCheckpointRedefineCommit: Don't check ABI of definition in checkpoint
Peter Krempa [Wed, 2 Dec 2020 12:35:29 +0000 (13:35 +0100)] 
virDomainCheckpointRedefineCommit: Don't check ABI of definition in checkpoint

Checking the definition ABI when redefining checkpoints doesn't make
much sense for the following reasons:

* the domain definition in the checkpoint is mostly unused (a relic
  adopted from the snapshot code)

* can be very easily overridden by deleting the checkpoint metadata
  before redefinition

Rather than complicating the logic when we'll be taking into account
that the domain definition may be missing, let's just remove the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirDomainCheckpointDefParse: Use 'unsigned int' for flags
Peter Krempa [Wed, 2 Dec 2020 13:33:21 +0000 (14:33 +0100)] 
virDomainCheckpointDefParse: Use 'unsigned int' for flags

Fix the type for a variable holding flags to the usual 'unsigned int'
and change the name to be more appropriate to its use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirDomainCheckpointDefParse: Don't extract unused domain type
Peter Krempa [Wed, 2 Dec 2020 13:29:30 +0000 (14:29 +0100)] 
virDomainCheckpointDefParse: Don't extract unused domain type

We can extract './domain' directly and let the parser deal with the
type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: Simplify some ppc64 tests
Andrea Bolognani [Wed, 2 Dec 2020 19:02:52 +0000 (20:02 +0100)] 
tests: Simplify some ppc64 tests

We can leave out things like USB controller, memballoon device,
kernel and initrd since they're not the focus of the tests.

Propagating some information from the output files back to the
input files makes it easier to compare them, as it reduces the
resulting diff, and in the case of the qemuxml2xml test for
memory-hotplug-ppc64-nonuma it allows us to convert the output
file into a symlink, since in the specific case the XML doesn't
change at all.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: Sync some ppc64 tests
Andrea Bolognani [Wed, 2 Dec 2020 18:56:57 +0000 (19:56 +0100)] 
tests: Sync some ppc64 tests

The ppc64 tests

  memory-hotplug-ppc64-nonuma
  memory-hotplug-nvdimm-ppc64

are not passed the same information for qemuxml2argv and
qemuxml2xml tests; the former, in particular, doesn't show up
at all in qemuxml2xml. Address this inconsistency.

Note that one of the new output files had been introduced with
5540acb9a2bd despite not being actually used as of that commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agocpu_map: Fix Icelake Server model number
Tim Wiederhake [Wed, 2 Dec 2020 10:38:22 +0000 (11:38 +0100)] 
cpu_map: Fix Icelake Server model number

See arch/x86/include/asm/intel-family.h in the Kernel:
  #define INTEL_FAM6_ICELAKE_X 0x6A

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoapparmor: Allow lxc processes to receive signals from libvirt
Jim Fehlig [Wed, 2 Dec 2020 23:24:21 +0000 (16:24 -0700)] 
apparmor: Allow lxc processes to receive signals from libvirt

LXC processes confined by apparmor are not permitted to receive signals
from libvirtd. Attempting to destroy such a process fails

virsh --connect lxc:/// destroy distro_apparmor
 error: Failed to destroy domain distro_apparmor
 error: Failed to kill process 29491: Permission denied

And from /var/log/audit/audit.log

type=AVC msg=audit(1606949706.142:6345): apparmor="DENIED"
operation="signal" profile="libvirt-314b7109-fdce-48dc-ad28-7c47958a27c1"
pid=29390 comm="libvirtd" requested_mask="receive" denied_mask="receive"
signal=term peer="libvirtd"

Similar to the libvirt-qemu abstraction, add a rule to the libvirt-lxc
abstraction allowing reception of signals from libvirtd.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agoqemuxml2xmltest.c: honor ARG_PARSEFLAGS
Daniel Henrique Barboza [Wed, 18 Nov 2020 16:28:09 +0000 (13:28 -0300)] 
qemuxml2xmltest.c: honor ARG_PARSEFLAGS

At this moment,  it is not possible to create a test specifying
ARG_PARSEFLAGS because info->parseFlags is not being forwarded to
testCompareDomXML2XMLFiles(). Let's fix it now so next patch can
make use of it.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: move memory size align to qemuProcessPrepareDomain()
Daniel Henrique Barboza [Wed, 18 Nov 2020 18:12:51 +0000 (15:12 -0300)] 
qemu: move memory size align to qemuProcessPrepareDomain()

qemuBuildCommandLine() is calling qemuDomainAlignMemorySizes(),
which is an operation that changes live XML and domain and has
little to do with the command line build process.

Move it to qemuProcessPrepareDomain() where we're supposed to
make live XML and domain changes before launch. qemuProcessStart()
is setting VIR_QEMU_PROCESS_START_NEW if !migrate && !snapshot,
same conditions used in qemuBuildCommandLine() to call
qemuDomainAlignMemorySizes(), making this change seamless.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu_process.c: check migrateURI when setting VIR_QEMU_PROCESS_START_NEW
Daniel Henrique Barboza [Wed, 18 Nov 2020 17:56:24 +0000 (14:56 -0300)] 
qemu_process.c: check migrateURI when setting VIR_QEMU_PROCESS_START_NEW

qemuProcessCreatePretendCmdPrepare() is setting the
VIR_QEMU_PROCESS_START_NEW regardless of whether this is
a migration case or not. This behavior differs from what we're
doing in qemuProcessStart(), where the flag is set only
if !migrate && !snapshot.

Fix it by making the flag setting consistent with what we're
doing in qemuProcessStart().

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: Pass / fill niothreads for qemuMonitorGetIOThreads
John Ferlan [Wed, 2 Dec 2020 17:34:24 +0000 (12:34 -0500)] 
qemu: Pass / fill niothreads for qemuMonitorGetIOThreads

Let's pass along / fill @niothreads rather than trying to make dual
use as a return value and thread count.

This resolves a Coverity issue detected in qemuDomainGetIOThreadsMon
where if qemuDomainObjExitMonitor failed, then a -1 was returned and
overwrite @niothreads causing a memory leak.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: squelch G_DEFINE_TYPE volatile warnings with GCC 11
Daniel P. Berrangé [Thu, 3 Dec 2020 11:33:29 +0000 (11:33 +0000)] 
util: squelch G_DEFINE_TYPE volatile warnings with GCC 11

In this previous commit:

  commit 65491a2dfe00bfcf9f09a8d6eab60234b56c8cc4
  Author: Martin Kletzander <mkletzan@redhat.com>
  Date:   Thu Nov 12 13:58:53 2020 +0100

    Do not disable incompatible-pointer-types-discards-qualifiers

We selectively rewrite G_DEFINE_TYPE to avoid warnings about
mismatched volatile/non-volatile pointers that appeared with
CLang when using GLib2 >= 2.67

We have now just hit the reverse problem, GCC >= 11 has started
warning about mismatched volatile/non-volatile pointers but only
with GLib2 < 2.67. The new GLib2 avoids the warning, as does
older GCC.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>