]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agonetdevmacvlan: Use helper function to create unique macvlan/macvtap name
Shi Lei [Mon, 14 Dec 2020 01:50:34 +0000 (09:50 +0800)] 
netdevmacvlan: Use helper function to create unique macvlan/macvtap name

Simplify ReserveName/GenerateName for macvlan and macvtap by using
common functions.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonetdevtap: Use common helper function to create unique tap name
Shi Lei [Mon, 14 Dec 2020 01:50:33 +0000 (09:50 +0800)] 
netdevtap: Use common helper function to create unique tap name

Simplify GenerateName/ReserveName for netdevtap by using common
functions.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoutil: Introduce helper functions for generating unique netdev name
Shi Lei [Mon, 14 Dec 2020 01:50:32 +0000 (09:50 +0800)] 
util: Introduce helper functions for generating unique netdev name

Extract ReserveName/GenerateName from netdevtap and netdevmacvlan as
common helper functions.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agolxc: don't try to reserve macvtap name for LXC domains
Laine Stump [Mon, 14 Dec 2020 21:19:26 +0000 (16:19 -0500)] 
lxc: don't try to reserve macvtap name for LXC domains

Commit 729a06c41 added code to the LXC driver (patterned after similar
code in the QEMU driver) that called
virNetDevMacVlanReserveName(net->ifname) for all type='direct'
interfaces during a libvirtd restart, to prevent other domains from
attempting to use a macvtap device name that was already in use by a
domain.

But, unlike a QEMU domain, when an LXC domain creates a macvtap
device, that device is almost immediately moved into the namespace of
the container (and it's then renamed, but that part isn't
important). Because of this, the LXC driver doesn't keep track (in
net->ifname) of the name used to create the device (as the QEMU driver
does).

The result of this is that if libvirtd is restarted while there is an
active LXC domain that has <interface type='direct'>, libvirtd will
segfault (since virNetDevMacVLanReserveName() doesn't check for a NULL
pointer).

The fix is to just not call that function in the case of the LXC
driver, since it is pointless anyway.

Fixes: 729a06c41afaab419a70841b6749646e2f8fad1d
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoci: containers: Refresh the Dockerfiles
Erik Skultety [Mon, 14 Dec 2020 15:24:37 +0000 (16:24 +0100)] 
ci: containers: Refresh the Dockerfiles

Contains changes utilizing "nosync" and "eatmydata" for speedup as well
as fixes for CentOS-8 repoid regression.
ci-commit: b098ec6631a85880f818f2dd25c437d509e53680

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: Relax validation for mem->access if guest has no NUMA
Michal Privoznik [Mon, 14 Dec 2020 11:20:07 +0000 (12:20 +0100)] 
qemu: Relax validation for mem->access if guest has no NUMA

In v6.8.0-27-g88957116c9 and friends I've switched the way the
default RAM is specified for QEMU (from plain -m to
memory-backend-*). This means, that even if a guest doesn't have
any NUMA nodes configured we can use memory-backend-* attributes
to translate user config requests. For instance, we can allow
memory to be shared (<access mode='shared'/> under
<memoryBacking/>). But what my original commits are missing is
allowing such configuration in our validator.

Fixes: 88957116c9d3cb4705380c3702c9d4315fb500bb
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1839034#c12
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodomain_validate.c: use VIR_ERR_CONFIG_UNSUPPORTED in validate functions
Daniel Henrique Barboza [Fri, 11 Dec 2020 13:04:04 +0000 (10:04 -0300)] 
domain_validate.c: use VIR_ERR_CONFIG_UNSUPPORTED in validate functions

Some functions in domain_validate.c are throwing VIR_ERR_XML_ERROR,
when in reality none of these errors are exclusive to XML parsing.

Change to VIR_ERR_CONFIG_UNSUPPORTED to be more adequate.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_validate.c: put IOMMU validation into a new function
Daniel Henrique Barboza [Fri, 11 Dec 2020 12:58:28 +0000 (09:58 -0300)] 
domain_validate.c: put IOMMU validation into a new function

All other validations from virDomainDefValidateInternal() are done
in their own functions. Take IOMMU validation out of the function
body and into its own function.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_validate.c: make virDomainDeviceDefValidateInternal() helpers static
Daniel Henrique Barboza [Fri, 11 Dec 2020 12:37:46 +0000 (09:37 -0300)] 
domain_validate.c: make virDomainDeviceDefValidateInternal() helpers static

After the move from the previous patch, these functions are now all
used in domain_validate.c and doesn't need to be public.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move virDomainDeviceDefValidate() to domain_validate.c
Daniel Henrique Barboza [Fri, 11 Dec 2020 12:27:17 +0000 (09:27 -0300)] 
domain_conf.c: move virDomainDeviceDefValidate() 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 all DeviceDefValidateInternal() helpers to domain_validate
Daniel Henrique Barboza [Fri, 11 Dec 2020 10:39:00 +0000 (07:39 -0300)] 
domain_conf: move all DeviceDefValidateInternal() helpers to domain_validate

Moving all remaining static helpers of virDomainDeviceDefValidateInternal()
will allow the next patch to move the function itself, and
virDomainDeviceDefValidate(), 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 net device validation to domain_validate.c
Daniel Henrique Barboza [Fri, 11 Dec 2020 00:38:07 +0000 (21:38 -0300)] 
domain_conf: move net device validation to domain_validate.c

The next objective is to move virDomainDeviceDefValidate() to
domain_validate.c. First let's move all the static helpers.

The net device validation functions are used across multiple
drivers, so let's move them separately first.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_validate.c: make local functions static
Daniel Henrique Barboza [Fri, 11 Dec 2020 00:12:16 +0000 (21:12 -0300)] 
domain_validate.c: make local functions static

virDomainDefValidateInternal() helpers can now be made static again
since they're all in the same file.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: move virDomainDeviceDefValidate() to domain_validate.c
Daniel Henrique Barboza [Thu, 10 Dec 2020 22:12:30 +0000 (19:12 -0300)] 
domain_conf.c: move virDomainDeviceDefValidate() to domain_validate.c

Move virDomainDeviceDefValidate() and all its helper functions 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 all virDomainDefValidateInternal() helpers to domain_validate.c
Daniel Henrique Barboza [Thu, 10 Dec 2020 20:36:27 +0000 (17:36 -0300)] 
domain_conf: move all virDomainDefValidateInternal() helpers to domain_validate.c

This patches moves the remaining static functions that
virDomainDefValidateInternal() uses to domain_validate.c. This
allows the next patch to move virDomainDefValidateInternal(),
and virDomainDefValidate(), without too much hassle.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move address validation functions to domain_validate.c
Daniel Henrique Barboza [Thu, 10 Dec 2020 18:58:44 +0000 (15:58 -0300)] 
domain_conf: move address validation functions to domain_validate.c

virDomainDefValidateAliases() is one of the static functions that
needs to be handled before moving virDomainDefValidateInternal().
Let's move all related validate functions to domain_validate.c
at the same time.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: rename virDomainDeviceInfoIterateInternal()
Daniel Henrique Barboza [Thu, 10 Dec 2020 19:10:33 +0000 (16:10 -0300)] 
domain_conf.c: rename virDomainDeviceInfoIterateInternal()

Next patch will move virDomainDefValidateAliases() to domain_validate.c,
which uses virDomainDeviceInfoIterateInternal(), meaning that this
function will be made public. Rename it now to remove the 'Internal'
of its name.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: move duplicate check functions to domain_validate.c
Daniel Henrique Barboza [Thu, 10 Dec 2020 18:32:43 +0000 (15:32 -0300)] 
domain_conf: move duplicate check functions to domain_validate.c

virDomainDefCheckDuplicateDiskInfo() and virDomainDefCheckDuplicateDriveAddresses()
are static functions used by virDomainDefValidateInternal(). Let's
move them to domain_validate.c to start clearing up the path to
move virDomainDefValidateInternal().

Change the functions name slightly to be more on par with their
new home.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoTranslated using Weblate (German)
Fabian Affolter [Mon, 14 Dec 2020 11:18:17 +0000 (12:18 +0100)] 
Translated using Weblate (German)

Currently translated at 51.1% (5342 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/de/

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
Signed-off-by: Fabian Affolter <mail@fabian-affolter.ch>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 14 Dec 2020 11:18:16 +0000 (12:18 +0100)] 
Translated using Weblate (Swedish)

Currently translated at 14.5% (1520 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 14.2% (1490 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 13.9% (1460 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 13.6% (1430 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 13.4% (1400 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
4 years agoTranslated using Weblate (Finnish)
Ricky Tigg [Mon, 14 Dec 2020 11:18:15 +0000 (12:18 +0100)] 
Translated using Weblate (Finnish)

Currently translated at 10.7% (1126 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/fi/

Co-authored-by: Ricky Tigg <ricky.tigg@gmail.com>
Signed-off-by: Ricky Tigg <ricky.tigg@gmail.com>
4 years agonode_device: pacify grumpy coverity due to addr override
Boris Fiuczynski [Thu, 10 Dec 2020 17:32:36 +0000 (18:32 +0100)] 
node_device: pacify grumpy coverity due to addr override

With commit 09364608b4 node_device: refactor address retrieval of node device
"if-else if" was replaced by "switch".
The contained break statement now is no longer in context of the for loop
but instead of the switch causing the legitimate grumpiness of coverity.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Suggested-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: remove redundant check for file length when determining PCIe vs. PCI
Laine Stump [Tue, 8 Dec 2020 19:44:30 +0000 (14:44 -0500)] 
qemu: remove redundant check for file length when determining PCIe vs. PCI

Now that virPCIDeviceIsPCIExpress() checks the length of the file when
the process lacks sufficient privilege to read the entire PCI config
file in sysfs, we can remove the open-coding for that case from its
consumer.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: make virPCIDeviceIsPCIExpress() more intelligent
Laine Stump [Tue, 8 Dec 2020 19:34:19 +0000 (14:34 -0500)] 
util: make virPCIDeviceIsPCIExpress() more intelligent

Until now there has been an extra bit of code in
qemuDomainDeviceCalculatePCIConnectFlag() (one of the two callers of
virPCIDeviceIsPCIExpress()) that tries to determine if a device is
PCIe by looking at the *length* of its sysfs config file; it only does
this when libvirt is running as a non-root process.

This patch takes advantage of our newfound ability to tell the
difference between "I read a 0 from the device PCI config file" and "I
couldn't read the PCI Express Capabilities because I don't have
sufficient permission" to put the file length check down in
virPCIDeviceIsPCIExpress(), and do that check any time we fail while
reading the config file (not only when the process is non-root).

Fixes: https://bugzilla.redhat.com/1901685
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: change call sequence for virPCIDeviceFindCapabilityOffset()
Laine Stump [Mon, 7 Dec 2020 20:46:54 +0000 (15:46 -0500)] 
util: change call sequence for virPCIDeviceFindCapabilityOffset()

Previously there was no way to differentiate between this function 1)
encountering an error while reading the pci config, and 2) determining
that the device in question is a conventional PCI device, and so has
no Express Capabilities.

The difference between these two conditions is important, because an
unprivileged libvirtd will be unable to read all of the pci config (it
can only read the first 64 bytes, and will get ENOENT when it tries to
seek past that limit) even though the device is in fact a PCIe device.

This patch changes virPCIDeviceFindCapabilityOffset() to put the
determined offset into an argument of the function (rather than
sending it back as the return value), and to return the standard "0 on
success, -1 on failure". Failure is determined by checking the value
of errno after each attemptd read of the config file (which can only
work reliably if errno is reset to 0 before each read, and after
virPCIDeviceFindCapabilityOffset() has finished examining it).

(NB: if the config file is read successfully, but no Express
Capabilities are found, then the function returns success, but the
returned offset will be 0 (which is an impossible offset for Express
Capabilities, and so easily recognizeable).

An upcoming patch will take advantage of the change made here.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: make read error of PCI config file more detailed
Laine Stump [Mon, 7 Dec 2020 01:26:01 +0000 (20:26 -0500)] 
util: make read error of PCI config file more detailed

The new message is more verbose/useful, but only logged at debug level
instead of as a warning (since it could easily happen in a non-error
situation).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: simplify call to virPCIDeviceDetectPowerManagementReset()
Laine Stump [Sun, 6 Dec 2020 21:20:23 +0000 (16:20 -0500)] 
util: simplify call to virPCIDeviceDetectPowerManagementReset()

This function returned an int, but would only return 0 or 1, and the
one place it was called would just use !! to convert that value to a
bool. Change the function to directly return bool instead.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: simplify calling of virPCIDeviceDetectFunctionLevelReset()
Laine Stump [Sun, 6 Dec 2020 21:05:03 +0000 (16:05 -0500)] 
util: simplify calling of virPCIDeviceDetectFunctionLevelReset()

This function returned an int, and that int was being checked for < 0
in its solitary caller, but within the function it would only ever
return 0 or 1. Change the function itself to return a bool, and the
caller to just directly set the flag in the virPCIDevice.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: use g_autoptr for a virPCIDevice
Laine Stump [Tue, 24 Nov 2020 21:56:52 +0000 (16:56 -0500)] 
qemu: use g_autoptr for a virPCIDevice

The one instance of a virPCIDevice in
qemuDomainDeviceCalculatePCIConnectFlags() needs to be converted to
use g_autoptr as a prerequisite for a bugfix. It's in this patch by
itself (rather than in a patch converting all virPCIDevice usages to
g_autoptr) to simplify any backport of said bugfix.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: qemucapabilities: Update capabilities for qemu-5.2 release (x86_64)
Peter Krempa [Thu, 19 Nov 2020 15:40:25 +0000 (16:40 +0100)] 
tests: qemucapabilities: Update capabilities for qemu-5.2 release (x86_64)

qemu-5.2 is out! Let's update the capabilities for the final version.

Note that the 'enable-fips' feature vanishing in this update is expected
as the removal was tied to a version check (see commit 7b1ed1cd733a0 ).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: Add capabilities for QEMU 5.2 on riscv64
Andrea Bolognani [Thu, 10 Dec 2020 13:12:59 +0000 (14:12 +0100)] 
tests: Add capabilities for QEMU 5.2 on riscv64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: Add capabilities for QEMU 5.2 on ppc64
Andrea Bolognani [Thu, 10 Dec 2020 12:51:53 +0000 (13:51 +0100)] 
tests: Add capabilities for QEMU 5.2 on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: Add capabilities for QEMU 5.2 on aarch64
Andrea Bolognani [Thu, 10 Dec 2020 12:51:43 +0000 (13:51 +0100)] 
tests: Add capabilities for QEMU 5.2 on aarch64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agospec: don't touch existing nwfilters on update
Nikolay Shirokovskiy [Mon, 7 Dec 2020 07:49:12 +0000 (10:49 +0300)] 
spec: don't touch existing nwfilters on update

Nwfilter can be edited by the user and we don't want to overwrite the editings.
Also the filters in %{datadir} does not have UUIDs and these are generated on
libvirtd start. Thus this patch also fixes regeneration of UUIDs on libvirtd
update.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agohyperv: remove duplicit addr check
Ján Tomko [Thu, 10 Dec 2020 09:03:42 +0000 (10:03 +0100)] 
hyperv: remove duplicit addr check

We already check addr is not negative right after filling
its value. There's no need to check it before using it too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: a7a1d1f59e8ba2d8a3ed920ef595ccdfb0d8feb6
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBuildMemoryDeviceStr: check return of qemuBuildDeviceAddressStr
Ján Tomko [Thu, 10 Dec 2020 08:49:07 +0000 (09:49 +0100)] 
qemuBuildMemoryDeviceStr: check return of qemuBuildDeviceAddressStr

Although the function currently only returns errors for PCI addresses,
check it here too, in case that changes in the future.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: virshAddressParse: check for malformed address
Ján Tomko [Thu, 10 Dec 2020 08:42:43 +0000 (09:42 +0100)] 
virsh: virshAddressParse: check for malformed address

The refactor left in the 'if (addr)' check,
but before 'addr' was the return value of strchr
and now it's the return value of virshAddressParse.

Check 'a' instead since that's the return of strchr now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 67bf91e1c38b6569357c22b1c83f7b090badba2b
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuDomainCheckpointLoad: Remove stale comment
Peter Krempa [Tue, 8 Dec 2020 15:28:40 +0000 (16:28 +0100)] 
qemuDomainCheckpointLoad: Remove stale comment

We decided to not do metadata-less checkpoints and checking whether the
metadata is consistent is done once the data is actually needed. Remove
the comment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainCheckpointLoad: Don't align disks when restoring config from disk
Peter Krempa [Tue, 8 Dec 2020 15:16:08 +0000 (16:16 +0100)] 
qemuDomainCheckpointLoad: Don't align disks when restoring config from disk

The alignment step is not really necessary once we've done it already
since we fully populate the definition. In case of checkpoints it was a
relic necessary for populating the 'idx' to match checkpoint disk to
definition disk, but that was already removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoNEWS: mention node device driver support for AP devices
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:44 +0000 (18:59 +0100)] 
NEWS: mention node device driver support for AP devices

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonode_device: detecting mdev_types capability on ap_matrix device
Boris Fiuczynski [Thu, 3 Dec 2020 17:59:43 +0000 (18:59 +0100)] 
node_device: detecting mdev_types capability on ap_matrix device

Add detection of mdev_types capability to Adjunct Processor Matrix device.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Jonathon Jongsma<jjongsma@redhat.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonode_device: mdev matrix support
Shalini Chellathurai Saroja [Thu, 3 Dec 2020 17:59:42 +0000 (18:59 +0100)] 
node_device: mdev matrix support

Allow mdev devices to be created on the 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 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>