]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 months agoqemu: Use C99 initializers for qemuMigrationParamsFlagMap
Jiri Denemark [Mon, 8 Jan 2024 15:36:34 +0000 (16:36 +0100)]
qemu: Use C99 initializers for qemuMigrationParamsFlagMap

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Document qemuMigrationParamsFlagMapItem fields
Jiri Denemark [Mon, 8 Jan 2024 14:08:05 +0000 (15:08 +0100)]
qemu: Document qemuMigrationParamsFlagMapItem fields

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 8 Jan 2024 06:04:24 +0000 (07:04 +0100)]
Translated using Weblate (Swedish)

Currently translated at 61.9% (6457 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 61.6% (6417 of 10417 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>
15 months agotests: Add xml->argv and xml->xml tests for the new iothread mapping feature
Peter Krempa [Wed, 1 Mar 2023 13:40:02 +0000 (14:40 +0100)]
tests: Add xml->argv and xml->xml tests for the new iothread mapping feature

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Implement support for configuring iothread to virtqueue mapping for disks
Peter Krempa [Wed, 1 Mar 2023 13:40:02 +0000 (14:40 +0100)]
qemu: Implement support for configuring iothread to virtqueue mapping for disks

Add validation and formatting of the commandline arguments for
'iothread-vq-mapping' parameter. The validation logic mirrors what qemu
allows.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoconf: Add possibility to configure multiple iothreads per disk
Peter Krempa [Thu, 23 Feb 2023 15:25:18 +0000 (16:25 +0100)]
conf: Add possibility to configure multiple iothreads per disk

Introduce a new <iothreads> sub-element of disk's <driver> which will
allow configuring multiple iothreads and also map them to specific
virt-queues of virtio devices.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: capabilities: Introduce QEMU_CAPS_VIRTIO_BLK_IOTHREAD_MAPPING
Peter Krempa [Thu, 23 Feb 2023 14:47:11 +0000 (15:47 +0100)]
qemu: capabilities: Introduce QEMU_CAPS_VIRTIO_BLK_IOTHREAD_MAPPING

The capability represents the support for mapping virtqueues to
iothreads for the 'virtio-blk' device.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: xml: Return GPtrArray from virXMLNodeGetSubelement
Peter Krempa [Mon, 13 Feb 2023 14:53:23 +0000 (15:53 +0100)]
util: xml: Return GPtrArray from virXMLNodeGetSubelement

Rework the helper to use a GPtrArray structure to simplify callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemucapabilitiesdata: Add data for the qemu-9.0 development cycle
Peter Krempa [Wed, 3 Jan 2024 14:37:06 +0000 (15:37 +0100)]
qemucapabilitiesdata: Add data for the qemu-9.0 development cycle

Add data for the qemu-9.0 development cycle based on
'v8.2.0-196-g7425b6277f'

Notable changes:
 - new machine types added
 - 'iommufd' object added
 - 'vfio-pci' device added 'fd' and 'iommufd' properties
 - 'virtio-blk-pci' device added 'iothread-vq-mapping' property

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: automatically bind to a vfio variant driver, if available
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
qemu: automatically bind to a vfio variant driver, if available

Rather than always binding to the vfio-pci driver, use the new
function virPCIDeviceFindBestVFIOVariant() to see if the running
kernel has a VFIO variant driver available that is a better match for
the device, and if one is found, use that instead.

virPCIDeviceFindBestVFIOVariant() function reads the modalias file for
the given device from sysfs, then looks through
/lib/modules/${kernel_release}/modules.alias for the vfio_pci alias
that matches with the least number of wildcard ('*') fields.

The appropriate "VFIO variant" driver for a device will be the PCI
driver implemented by the discovered module - these drivers are
compatible with (and provide the entire API of) the standard vfio-pci
driver, but have additional device-specific APIs that can be useful
for, e.g., saving/restoring state for migration.

If a specific driver is named (using <driver model='blah'/> in the
device XML), that will still be used rather than searching
modules.alias; this makes it possible to force binding of vfio-pci if
there is an issue with the auto-selected variant driver.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: support manually specifying VFIO variant driver in <hostdev> XML
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: support manually specifying VFIO variant driver in <hostdev> XML

This patch makes it possible to manually specify which VFIO variant
driver to use for PCI hostdev device assignment, so that, e.g. you
could force use of a VFIO "variant" driver, with e.g.

  <driver model='mlx5_vfio_pci'/>

or alternately to force use of the generic vfio-pci driver with

  <driver model='vfio-pci'/>

when libvirt would have normally (after applying a subsequent patch)
found a "better match" for a device in the active kernel's
modules.alias file. (The main potential use of this manual override
would probably be to work around a bug in a new VFIO variant driver by
temporarily not using that driver).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: remove explicit <driver name='vfio'/> from hostdev test cases
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
tests: remove explicit <driver name='vfio'/> from hostdev test cases

The long-deprecated use of <driver name='vfio|xen|kvm'/> in domain xml
for <hostdev> devices was only ever necessary during the period when
libvirt (and the Linux kernel) supported both VFIO and "legacy KVM"
styles of hostdev device assignment for QEMU. This became pointless
many years ago when legacy KVM device assignment was removed from the
kernel, and support for that style of device assignment was completely
disabled in the libvirt source in 2019 (commit
v5.6.0-316-g2e7225ea8c).

Nevertheless, there were instances of <driver name='vfio'/> in the
unit test data that were then (unnecessarily) propagated to several
more tests over the years. This patch cleans out those unnecessary
explicit settings of driver name='vfio' in all QEMU unit test data,
proving that the attribute is no longer (externally) needed. (A later
patch which adds a 2nd attribute to the <driver> element will include
a test case that explicitly exercises the driver name attribute).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoxen: explicitly set hostdev driver.name at runtime, not in postparse
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
xen: explicitly set hostdev driver.name at runtime, not in postparse

Xen only supports a single type of PCI hostdev assignment, so it is
superfluous to have <driver name='xen'/> peppered throughout the
config. It *is* necessary to have the driver type explicitly set in
the hostdev object before calling into the hypervisor-agnostic "hostdev
manager" though (otherwise the hostdev manager doesn't know whether it
should do Xen-specific setup, or VFIO-specific setup).

Historically, the Xen driver has checked for "default" driver name
(i.e. not set in the XML), and set it to "xen', during the XML
postparse, thus guaranteeing that it will be set by the time the
object is sent to the hostdev manager at runtime, but also setting it
so early that a simple round-trip of parse-format results in the XML
always containing an explicit <driver name='xen'/>, even if that
wasn't specified in the original XML.

The QEMU driver *doesn't* set driver.name during postparse though;
instead, it waits until domain startup time (or device attach time for
hotplug), and sets the driver.name then. The result is that a
parse-format round trip of the XML in the QEMU driver *doesn't* add in
the <driver name='vfio'/>.

This patch modifies the Xen driver to behave similarly to the QEMU
driver - the PostParse just checks for a driver.name that isn't
supported by the Xen driver, and any explicit setting to "xen" is
deferred until domain runtime rather than during the postparse, thus
Xen domain XML also doesn't get extraneous <driver name='xen'/>.

This delayed setting of driver.name of course results in slightly
different xml2xml parse-format results, so the unit test data is
modified accordingly.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: replace virHostdevIsVFIODevice with virHostdevIsPCIDevice
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: replace virHostdevIsVFIODevice with virHostdevIsPCIDevice

virHostdevIsVFIODevice() and virDomainDefHasVFIOHostdev() are only ever
called from the QEMU driver, and in the case of the QEMU driver, any
PCI hostdev by definition uses VFIO, so really all these callers only
need to know if the device is a PCI hostdev.

(It turned out that the less specific virHostdevIsPCIDevice() already
existed in hypervisor/virhostdev.c, so I had to remove one of them;
since conf is a lower level directory than hypervisor, and the
function is called from conf, keeping the copy in hypervisor would
have required moving its caller (virDomainDefHasPCIHostdev()) into
hypervisor as well, so I just removed the copy in hypervisor.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: use new common parser/formatter for hostdev driver in network XML
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: use new common parser/formatter for hostdev driver in network XML

Now if a new attribute is added to <driver>, we only need to update
the formatting/parsing in one place.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: split out hostdev <driver> parse/format to their own functions
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: split out hostdev <driver> parse/format to their own functions

This is done so that we can re-use the same parser/formatter for
<network> and <networkport>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: use virDeviceHostdevPCIDriverInfo in network and networkport objects
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: use virDeviceHostdevPCIDriverInfo in network and networkport objects

The next step in consolidating parsing/formatting of the <driver>
element of these objects using a common struct and common code. This
eliminates the virNetworkForwardDriverNameType enum which is nearly
identical to virDeviceHostdevPCIDriverName (the only non-identical bit
was just because they'd gotten out of sync over time) and replaces its
uses with a virDeviceHostdevPCIDriverInfo (which is a struct that
contains a virDeviceHostdevPCIDriverName).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: put hostdev PCI backend into a struct
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: put hostdev PCI backend into a struct

The new struct is virDeviceHostdevPCIDriverInfo, and the "backend"
enum in the hostdevDef will be replaced with a
virDeviceHostdevPCIDriverInfo named "driver'. Since the enum value in
this new struct is called "name", it means that all references to
"backend" will become "driver.name".

This will allow easily adding other items for new attributes in the
<driver> element / C struct, which will be useful once we are using
this new struct in multiple places.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: normalize hostdev <driver> parsing to simplify adding new attr
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: normalize hostdev <driver> parsing to simplify adding new attr

The hostdev version of the <driver> subelement appears in four places:

 * The domain XML in the <hostdev> and <interface type='hostdev'>
   elements (that's 2)

 * The network XML inside <forward> when the network is a pool of
   SRIOV VFs

 * the <networkport> XML, which is used to communicate between the
   hypervisor driver and network driver.

In order to make the pending addition of a new attribute to <driver>
in all these cases simpler, this patch refactors the parsing of
<driver> in all four places to use virXMLProp*() and
virXMLFormatElement().

Making all of the different instances of the separate parse/format for
<driver> look nearly identical will make it easier to see that the
upcoming patch that converges all four to use a common
parser/formatter is a functional NOP.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: move/rename hostdev PCI driver type enum to device_conf.h
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
conf: move/rename hostdev PCI driver type enum to device_conf.h

Currently this enum is defined in domain_conf.h and named
virDomainHostdevSubsysPCIDriverType. I want to use it in parts of the
network and networkport config, so am moving its definition to
device_conf.h which is / can be included by all interested parties,
and renaming it to match the name of the corresponding XML attribute
("driver name"). The name change (which includes enum values) does cause a
lot of churn, but it's all mechanical.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoschema: consolidate RNG for all hostdev <driver> elements
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
schema: consolidate RNG for all hostdev <driver> elements

The exact same element can appear in <hostdev> and <interface
type='hostdev'>, and nearly identical in <network> and <networkport>
(these latter two don't include "xen" as a possible driver, but that's
coincidental - there's no reason Xen couldn't also use the VF pools in
virtual networks, it just doesn't).

This patch modifies all 4 to use the same <ref name="hostdevDriver"/>
so that it is simpler to add something new.

A side effect of this patch is that the grammar for the <interface>
element in domain XML has been tightened up a bit - previously it was
accepted by the schema (but nonsensical) to have virtio and network
interface options specified; as a part of making the two different
<driver> choices each a complete element (rather than each being a
collection of attributes and subelements) these extra
attributes/subelements that were irrelevant to the hostdev-type
<driver> were made to be valid only for an emulated interface's
<driver>.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoutil: properly deal with VFIO module name vs. driver name
Laine Stump [Fri, 5 Jan 2024 01:12:51 +0000 (20:12 -0500)]
util: properly deal with VFIO module name vs. driver name

Historically libvirt hasn't differentiated between the name of a
loadable kernel module, and the name of the device driver that module
implements, but these two names can be (and usually are) at least
subtly different.

For example, the loadable module called "vfio_pci" implements a PCI
driver called "vfio-pci". We have always used the name "vfio-pci" both
to load the module (with modprobe) and to check (in
/sys/bus/pci/drivers) if the driver is available. (This has happened
to work because modprobe "normalizes" all the names it is given by
replacing "-" with "_", so "vfio-pci" works for both loading the
module and checking for the driver.)

When we recently gained the ability to manually specify the driver for
"virsh nodedev-detach", the fragility of this system became apparent -
if a user gave the "driver name" as "vfio_pci", then we would modprobe
the module correctly, but then erroneously believe it hadn't been
loaded because /sys/bus/pci/drivers/vfio_pci didn't exist. For manual
specification of the driver name, we could deal with this by telling
the user "always use the correct name for the driver, don't assume
that it has the same name as the module", but it would still end up
confusing people, especially since some drivers do use underscore in
their name (e.g. the mlx5_vfio_pci driver/module).

This will only get worse when an upcoming patch starts automatically
determining the driver to use for VFIO-assigned devices - it will look
in the kernel's modules.alias file to find "best" VFIO variant
*module* for a device, and 3 out of 4 current examples of
vfio-pci/variant drivers have a mismatch between module name and
driver name, so the current code would end up properly loading the
module, but then erroneously think that the driver wasn't available.

This patch makes the code more forgiving by

1) checking for both $drivername and underscore($drivername) in
   /sys/bus/pci/drivers

2) when we determine a module needs to be loaded, look at the link in
   /sys/module/$modulename/driver/pci:$drivername to determine the
   name of the driver we need to bind to the device(rather than just
   assuming the driver has the same name as the module

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
16 months agotests: Ensure test files are newline-terminated
Andrea Bolognani [Fri, 5 Jan 2024 11:02:43 +0000 (12:02 +0100)]
tests: Ensure test files are newline-terminated

Currently we only append a newline to 'actual' if 'expected'
(as loaded from file) already ends in a newline, but that
results in inconsistent behavior.

For example, some of the test files used by virhostcputest are
newline-terminated and some aren't. If we were to remove
existing newlines from those files or add them where they
aren't present, the test would still pass, and even using
VIR_TEST_REGENERATE_OUTPUT=1 wouldn't change them back.

Make things consistent by ensuring that 'actual' is always
newline-terminated. The only exception is when 'actual' is
completely empty: in that case, we want the file to be actually
empty, not contain a single empty line. query-jobs-empty.result
in qemumonitorjsondata/ is an example of this being used.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agotests: Drop some unused qemunbdkit data files
Andrea Bolognani [Fri, 5 Jan 2024 11:32:02 +0000 (12:32 +0100)]
tests: Drop some unused qemunbdkit data files

The test still passes after deleting them, which seems to
indicate that they're unnecessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agolibvirt.spec: Fix nbdkit selection logic on mingw and old rhel
Peter Krempa [Fri, 5 Jan 2024 08:39:45 +0000 (09:39 +0100)]
libvirt.spec: Fix nbdkit selection logic on mingw and old rhel

rhel-8 lacks 'pidfd_open()' support and thus nbdkit can't be enabled
there.

mingw builds explicitly disable nbdkit support, but use
'--auto-features=enabled' thus omitting setting of
'nbdkit_config_default' results in meson thinking we want to enable it:

  ../meson.build:1018:2: ERROR: Problem encountered: nbdkit_config_default requires nbdkit to be enabled

Disable it explicitly. The meson logic might need to be fixed eventually
when switching it on by default.

Fixes: 9eabf14afbd429af1be195723fdeab5ccdd0b2cd
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
16 months agoqemuxml2argvtest: Add checker that all input files are used
Peter Krempa [Fri, 1 Dec 2023 15:47:23 +0000 (16:47 +0100)]
qemuxml2argvtest: Add checker that all input files are used

To prevent regressions when refactoring tests and accidentally forgotten
input files make sure that qemuxml2argvtest is invoked for all input
files in tests/qemuxml2argvdata

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Mark 'nbdkit' tests as skipped if nbdkit is not compiled in
Peter Krempa [Wed, 3 Jan 2024 12:03:24 +0000 (13:03 +0100)]
qemuxml2argvtest: Mark 'nbdkit' tests as skipped if nbdkit is not compiled in

Rather than completely compiling out the tests mark them as skipped.
This will allow us to add a checker that all input files are accounted
for.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Add test cases covered only by qemuxml2xmltest - part 2
Peter Krempa [Mon, 4 Dec 2023 13:52:34 +0000 (14:52 +0100)]
qemuxml2argvtest: Add test cases covered only by qemuxml2xmltest - part 2

Add the rest of test cases which were tested only by qemuxml2xmltest.

All test cases added here have a '<interface type="network"' which needs
to be translated using the new fake network driver.

Note that this captures the status quo of the tests. No care was given
whether the tests make sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agovirnetworkportxml2xmltest: Add simple versions of bridge/network tests
Peter Krempa [Fri, 1 Dec 2023 22:09:48 +0000 (23:09 +0100)]
virnetworkportxml2xmltest: Add simple versions of bridge/network tests

Add versions stripping vlans and bandwidth setup so that they can be
used in qemuxml2argvtest for interfaces which don't support the above.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Enable 'graphics-listen-network' case
Peter Krempa [Mon, 4 Dec 2023 13:51:14 +0000 (14:51 +0100)]
qemuxml2argvtest: Enable 'graphics-listen-network' case

Use the data from 'nat-network' network definition to enable the test
case also for xml2argvtest.

Since the network listen bit doesn't need any plug definition just use
an empty string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2xmltest: Introduce fake network driver
Peter Krempa [Fri, 1 Dec 2023 14:49:21 +0000 (15:49 +0100)]
qemuxml2xmltest: Introduce fake network driver

In order to be able to use '<interface type="network"' we need a fake
network driver in qemuxml2argvtest. Create one by simply allowing users
to reuse configs from tests/networkxml2xmlin and tests/virnetworkportxml2xmldata
which will be returned to corresponding functions.

The driver implements:

    .networkLookupByName = fakeNetworkLookupByName,
      - validate syntax of network name, check if config exists
    .networkGetXMLDesc = fakeNetworkGetXMLDesc,
      - return appropriate XML
    .networkPortCreateXML = fakeNetworkPortCreateXML,
      - validate that port XML exists
    .networkPortGetXMLDesc = fakeNetworkPortGetXMLDesc,
      - return appropriate port XML

With the above and the correspondign test data, all network XMLs can be
enabled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvmock: Mock virNetDevSetMTU
Peter Krempa [Mon, 4 Dec 2023 15:28:23 +0000 (16:28 +0100)]
qemuxml2argvmock: Mock virNetDevSetMTU

Unfortunately the network backend commandline formatter attempts to also
setup the backend itself, which it really should not.

For now make sure qemuxml2argvtest can call virNetDevSetMTU.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu: process: Separate setup of network device objects
Peter Krempa [Fri, 1 Dec 2023 21:48:55 +0000 (22:48 +0100)]
qemu: process: Separate setup of network device objects

Separate the SLIRP bits from 'qemuProcessNetworkPrepareDevices' and do
the setup of the internal data when setting up domain data.

This will allow tests to use the same code path to lookup data for a
network.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2xmltest: Delete 'interface-driver' case
Peter Krempa [Mon, 4 Dec 2023 15:02:05 +0000 (16:02 +0100)]
qemuxml2xmltest: Delete 'interface-driver' case

Everything this XML tests is already explicitly covered in other tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml*test: Improve 'vhost_queues' test case
Peter Krempa [Mon, 4 Dec 2023 14:58:39 +0000 (15:58 +0100)]
qemuxml*test: Improve 'vhost_queues' test case

Modify the test case so that it can be used also for qemuxml2argvtest
by removing invalid configuration (interface type='user' + queues),
clean up unneeded disks and rename it accordingly. Also test the
ioeventfd.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2*test: Add specific test case for interface link state
Peter Krempa [Mon, 4 Dec 2023 14:26:13 +0000 (15:26 +0100)]
qemuxml2*test: Add specific test case for interface link state

Test both linkstates in an explicit test case. Note that link state is
setup via monitor, thus not visible on the commandline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2xmltest: Move 'graphics-listen-network2' case go genericxml2xmltest
Peter Krempa [Mon, 4 Dec 2023 13:16:13 +0000 (14:16 +0100)]
qemuxml2xmltest: Move 'graphics-listen-network2' case go genericxml2xmltest

The tested configuration is not valid for a qemu VM. Move it to the
generic test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Add test cases covered only by qemuxml2xmltest - part 1
Peter Krempa [Fri, 1 Dec 2023 15:53:32 +0000 (16:53 +0100)]
qemuxml2argvtest: Add test cases covered only by qemuxml2xmltest - part 1

There were plenty of test cases invoked only from qemuxml2xmltest but
not from qemuxml2argvtest, either by accident or it was deemed unneeded.

Bulk-add all test cases which fit the above description which don't
require faking the network driver. Use same invocation as present in
qemuxml2xmltest.

Arguably in certain cases we could move the test case to
genericxml2xmltest, but this covers the cases when that would not be
appropriate.

Tests requiring the network driver will be bulk-added when the fake
network driver will be implemented.

This patch also allows the use of FLAG_SKIP_CONFIG_ACTIVE in
qemuxml2argvtest although the flag will be dormant for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvmock: Mock qemuInterfaceBridgeConnect
Peter Krempa [Fri, 1 Dec 2023 22:11:11 +0000 (23:11 +0100)]
qemuxml2argvmock: Mock qemuInterfaceBridgeConnect

Prepare for test cases which would want to call that function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Check for duplicate invocation of tests
Peter Krempa [Fri, 1 Dec 2023 15:27:26 +0000 (16:27 +0100)]
qemuxml2argvtest: Check for duplicate invocation of tests

Prevent duplicated invocation of tests by tracking use of output files.
Some cases need to be exempt from this for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Remove duplicated invocations of tests
Peter Krempa [Fri, 1 Dec 2023 15:37:47 +0000 (16:37 +0100)]
qemuxml2argvtest: Remove duplicated invocations of tests

'parallel-tcp-chardev', 'parallel-parport-chardev' are invoked twice
with exactly the same parameters, remove the duplicity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvdata: Move 'smbios-multiple-type2' case to genericxml2xmltest
Peter Krempa [Fri, 1 Dec 2023 15:12:42 +0000 (16:12 +0100)]
qemuxml2argvdata: Move 'smbios-multiple-type2' case to genericxml2xmltest

The qemu driver explicitly rejects such configuration, thus this is just
a generic XML2XML test case. Move it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Reinstate 'pseries-vio-address-clash' case
Peter Krempa [Fri, 1 Dec 2023 14:24:34 +0000 (15:24 +0100)]
qemuxml2argvtest: Reinstate 'pseries-vio-address-clash' case

The case was removed in commit 8ff73d22c7405049452e2bf7f281f7460a6b9d10
which modernized the cases without an explicit reason. Reinstate it.

Fixes: 8ff73d22c7405049452e2bf7f281f7460a6b9d10
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Fix and use 'disk-network-ssh-key' case
Peter Krempa [Fri, 1 Dec 2023 14:19:15 +0000 (15:19 +0100)]
qemuxml2argvtest: Fix and use 'disk-network-ssh-key' case

The test case was introduced by commit 68599168ea8185689bd227e6d142e3d933558f84
but is only used in the qemunbdkittest. Fix it and make use of it also
in qemuxml2argvtest.

Fixes: 68599168ea8185689bd227e6d142e3d933558f84
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuxml2argvtest: Reinstate 'console-compat-chardev' and 'pci-serial-dev-chardev'
Peter Krempa [Fri, 1 Dec 2023 14:14:00 +0000 (15:14 +0100)]
qemuxml2argvtest: Reinstate 'console-compat-chardev' and 'pci-serial-dev-chardev'

The tests invocations were accidentaly removed in commit
54257ed51b5132032cedb7e1e7b8c34b9ae52115

Fixes: 54257ed51b5132032cedb7e1e7b8c34b9ae52115
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu: add runtime config option for nbdkit
Jonathon Jongsma [Wed, 8 Nov 2023 19:14:50 +0000 (13:14 -0600)]
qemu: add runtime config option for nbdkit

Currently when we build with nbdkit support, libvirt will always try to
use nbdkit to access remote disk sources when it is available. But
without an up-to-date selinux policy allowing this, it will fail.
because the required selinux policies are not yet widely available, we
have disabled nbdkit support on rpm builds for all distributions before
Fedora 40.

Unfortunately, this makes it more difficult to test nbdkit support.
After someone updates to the necessary selinux policies, they would also
need to rebuild libvirt to enable nbdkit support. By introducing a
configure option (nbdkit_config_default), we can build packages with
nbdkit support but have it disabled by default.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Suggested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
16 months agonode_device: udevGetStringSysfsAttr() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:17:03 +0000 (03:17 +0300)]
node_device: udevGetStringSysfsAttr() to void

udevGetStringSysfsAttr() return value is invariant, so change it
type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agonode_device: udevTranslatePCIIds() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:17:02 +0000 (03:17 +0300)]
node_device: udevTranslatePCIIds() to void

udevTranslatePCIIds() return value is invariant, so change it
type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agovirprocess: virProcessGetNamespaces() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:17:01 +0000 (03:17 +0300)]
virprocess: virProcessGetNamespaces() to void

virProcessGetNamespaces() return value is invariant, so change it
type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoconf: virDomainNetUpdate() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:17:00 +0000 (03:17 +0300)]
conf: virDomainNetUpdate() to void

virDomainNetUpdate() return value is invariant, so change it type
and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agolxc: virLXCControllerAddConsole() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:16:59 +0000 (03:16 +0300)]
lxc: virLXCControllerAddConsole() to void

virLXCControllerAddConsole() return value is invariant, so change
it type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agorpc: virnetserver: virNetServerAddService() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:16:58 +0000 (03:16 +0300)]
rpc: virnetserver: virNetServerAddService() to void

virNetServerAddService() return value is invariant, so change it
type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agocpu: : virCPUx86DataAddItem() to void
Artem Chernyshev [Thu, 4 Jan 2024 00:16:57 +0000 (03:16 +0300)]
cpu: : virCPUx86DataAddItem() to void

virCPUx86DataAddItem() return value is invariant, so change it
type and remove all dependent checks.

Functions changed to void:

virCPUx86DataAddItem()
x86DataAdd()
virCPUx86DataAdd()
x86DataAddSignature()
virCPUx86DataSetSignature()
libxlCapsAddCPUID()
cpuidSetLeaf4()
cpuidSetLeaf7()
cpuidSetLeafB()
cpuidSetLeafD()
cpuidSetLeafResID()
cpuidSetLeaf12()
cpuidSetLeaf14()
cpuidSetLeaf17()

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu_driver: Don't handle the EOF event if vm get restarted
Guoyi Tu [Thu, 7 Dec 2023 12:52:39 +0000 (20:52 +0800)]
qemu_driver: Don't handle the EOF event if vm get restarted

Currently, libvirt creates a thread pool with only on thread to handle all
qemu monitor events for virtual machines, In the cases that if the thread
gets stuck while handling a monitor EOF event, such as unable to kill the
virtual machine process or release resources, the events of other virtual
machine will be also blocked, which will lead to the abnormal behavior of
other virtual machines.

For instance, when another virtual machine completes a shutdown operation
and the monitor EOF event has been queued but remains unprocessed, we
immediately destroy and start the virtual machine again, at a later time
when EOF event get processed, the processMonitorEOFEvent() will kill the
virtual machine that just started.

To address this issue, in the processMonitorEOFEvent(), we check whether
the current virtual machine's id is equal to the the one at the time
the event was generated. If they do not match, we immediately return.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Signed-off-by: dengpengcheng <dengpc12@chinatelecom.cn>
16 months agoci: Update Alpine and Fedora and regenerate
Michal Privoznik [Thu, 14 Dec 2023 07:36:01 +0000 (08:36 +0100)]
ci: Update Alpine and Fedora and regenerate

New Alpine and Fedora releases were added to libvirt-ci (3.19 and
39, respectively) and old ones were removed. Update the manifest
file and regenerate the rest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
16 months agoci: integration: Switch upstream integration tests to Fedora 39
Michal Privoznik [Thu, 14 Dec 2023 07:44:10 +0000 (08:44 +0100)]
ci: integration: Switch upstream integration tests to Fedora 39

Currently, Fedora 37 and 38 is used. The former is now EOL since
there's new release. Switch 37 to 39 then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
16 months agoconf: Restore setting default bus for input devices
Jonathan Wright [Wed, 3 Jan 2024 15:26:59 +0000 (09:26 -0600)]
conf: Restore setting default bus for input devices

Prior to v9.3.0-rc1~30 we used to set default bus for <input/>
devices, during XML parsing. In the commit this code was moved to
a post parse callback. But somehow the line that sets the bus in
one specific case disappeared. Bring it back.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/577
Fixes: c4bc4d3b82fbe22e03c986ca896090f481df5c10
Signed-off-by: Jonathan Wright <jonathan@almalinux.org>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agodocs: fix typo in qemu-passthrough-security
Foster Snowhill [Thu, 14 Dec 2023 12:12:13 +0000 (12:12 +0000)]
docs: fix typo in qemu-passthrough-security

Signed-off-by: Foster Snowhill <2486761-ForstPenguin@users.noreply.gitlab.com>
16 months agoImprove error message in remoteGetUNIXSocket
Martin Kletzander [Thu, 7 Dec 2023 10:28:23 +0000 (11:28 +0100)]
Improve error message in remoteGetUNIXSocket

By adding a link to an explanation in the kbase.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
16 months agoqemucapabilitiesdata: Final update of 'caps_8.2.0_x86_64'
Peter Krempa [Thu, 16 Nov 2023 13:58:07 +0000 (14:58 +0100)]
qemucapabilitiesdata: Final update of 'caps_8.2.0_x86_64'

QEMU 8.2 was released, update the x86_64 data for a final time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoci: Switch from FreeBSD 12.0 to FreeBSD 14.0
Michal Privoznik [Wed, 3 Jan 2024 09:07:49 +0000 (10:07 +0100)]
ci: Switch from FreeBSD 12.0 to FreeBSD 14.0

FreeBSD 12.0 is no longer supported since 14.0 is out. Change the
CI manifest and refresh the rest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
16 months agoTranslated using Weblate (Georgian)
Temuri Doghonadze [Mon, 1 Jan 2024 11:37:07 +0000 (12:37 +0100)]
Translated using Weblate (Georgian)

Currently translated at 4.4% (461 of 10414 strings)

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

Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Signed-off-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
16 months agoTranslated using Weblate (Georgian)
Weblate [Mon, 1 Jan 2024 11:37:06 +0000 (12:37 +0100)]
Translated using Weblate (Georgian)

Currently translated at 4.4% (461 of 10414 strings)

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

Co-authored-by: Weblate <noreply-mt-weblate@weblate.org>
Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
16 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 1 Jan 2024 11:37:06 +0000 (12:37 +0100)]
Translated using Weblate (Swedish)

Currently translated at 59.6% (6211 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 59.2% (6170 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 58.8% (6129 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 58.4% (6088 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 58.0% (6047 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 57.6% (6006 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 57.4% (5985 of 10417 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>
16 months agoqemu: Replace the deprecated short-formed option "unix"
Han Han [Thu, 21 Dec 2023 08:33:38 +0000 (16:33 +0800)]
qemu: Replace the deprecated short-formed option "unix"

Change to the boolean option "unix=on"

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoTranslated using Weblate (Korean)
김인수 [Tue, 19 Dec 2023 15:58:18 +0000 (16:58 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10414 of 10414 strings)

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

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
16 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 19 Dec 2023 15:58:17 +0000 (16:58 +0100)]
Translated using Weblate (Swedish)

Currently translated at 58.0% (6047 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 57.6% (6006 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 57.4% (5985 of 10417 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>
16 months agoconf: fix integer overflow in virDomainControllerDefParseXML
Egor Makrushin [Wed, 20 Dec 2023 12:38:08 +0000 (15:38 +0300)]
conf: fix integer overflow in virDomainControllerDefParseXML

Multiplication results in integer overflow.
Thus, replace it with ULLONG_MAX and change
def->opts.pciopts.pcihole64size type to ULL.
Update variable usage according to new type.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Egor Makrushin <emakrushin@astralinux.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoremote: DeserializeDomainDiskErrors: remove dead code
Ján Tomko [Tue, 19 Dec 2023 15:46:53 +0000 (16:46 +0100)]
remote: DeserializeDomainDiskErrors: remove dead code

As of commit b2d079c113a which converted this function to use g_strdup,
the error label is only reached when i = 0, rendering it useless.

Remove it.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/572
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoapparmor: Add capabilities for PCI passthrough to virtxend profile
Jim Fehlig [Mon, 18 Dec 2023 23:48:13 +0000 (16:48 -0700)]
apparmor: Add capabilities for PCI passthrough to virtxend profile

When splitting out the apparmor modular daemon profiles from the
libvirtd profile, the net_admin and sys_admin capabilities were
dropped from the virtxend profile. It was not known at the time
that these capabilities were needed for PCI passthrough. Without
the capabilities, the following messages are emitted from the audit
subsystem

audit: type=1400 audit(1702939277.946:63): apparmor="DENIED" \
operation="capable" class="cap" profile="virtxend" pid=3611 \
comm="rpc-virtxend" capability=21  capname="sys_admin"
audit: type=1400 audit(1702940304.818:63): apparmor="DENIED" \
operation="capable" class="cap" profile="virtxend" pid=3731 \
comm="rpc-virtxend" capability=12  capname="net_admin"

It appears sys_admin is needed to simply read from the PCI dev's
sysfs config file. The net_admin capability is needed when setting
the MAC address of an SR-IOV virtual function.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuDomainBlockPeek: Fix format checking logic
Peter Krempa [Sat, 16 Dec 2023 08:20:41 +0000 (09:20 +0100)]
qemuDomainBlockPeek: Fix format checking logic

Recent refactor which changed the format check to use
qemuBlockStorageSourceIsRaw accidentaly inverted the condition.

Caught by the CI test suite.

Fixes: b600b69f8291226095e0fdb2eb7503baa79063fc
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
16 months agodocs: virtiofs: add section about ID remapping
Ján Tomko [Mon, 11 Sep 2023 13:38:10 +0000 (15:38 +0200)]
docs: virtiofs: add section about ID remapping

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu: virtiofs: auto-fill idmap for unprivileged use
Ján Tomko [Wed, 13 Dec 2023 13:05:32 +0000 (14:05 +0100)]
qemu: virtiofs: auto-fill idmap for unprivileged use

If the user did not specify any uid mapping, map its own
user ID to ID 0 inside the container and the rest of the IDs
to the first found user's authorized range in /etc/sub[ug]id

https://issues.redhat.com/browse/RHEL-7386
https://gitlab.com/libvirt/libvirt/-/issues/535

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoutil: add virGetSubUIDs
Ján Tomko [Wed, 13 Dec 2023 11:51:43 +0000 (12:51 +0100)]
util: add virGetSubUIDs

A function for parsing /etc/sub[ug]id

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu: allow running virtiofsd in session mode
Ján Tomko [Fri, 1 Sep 2023 14:28:08 +0000 (16:28 +0200)]
qemu: allow running virtiofsd in session mode

https://gitlab.com/libvirt/libvirt/-/issues/535

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu: virtiofs: do not force UID 0
Ján Tomko [Thu, 7 Sep 2023 14:22:43 +0000 (16:22 +0200)]
qemu: virtiofs: do not force UID 0

Remove the explicit setting of uid 0 when running virtiofsd.

It is not required for privileged mode, where virtiofsd will be run
as root anyway. And for unprivileged mode, virtiofsd no longer requires
to be run as root.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemu: format uid/gid map for virtiofs
Ján Tomko [Wed, 16 Aug 2023 13:40:03 +0000 (15:40 +0200)]
qemu: format uid/gid map for virtiofs

Pass the ID map to virtiofsd, which will run the suid `newuidmap`
binary for us.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoconf: add idmap element to filesystem
Ján Tomko [Wed, 16 Aug 2023 12:44:01 +0000 (14:44 +0200)]
conf: add idmap element to filesystem

Allow the user to manually tweak the ID mapping that will allow
virtiofsd to run unprivileged.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoconf: move idmap parsing earlier
Ján Tomko [Wed, 16 Aug 2023 12:52:40 +0000 (14:52 +0200)]
conf: move idmap parsing earlier

It will be reused for <filesystem> as well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoconf: move idmap definition earlier
Ján Tomko [Wed, 16 Aug 2023 12:47:12 +0000 (14:47 +0200)]
conf: move idmap definition earlier

It will be reused for <filesystem> as well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
16 months agoqemuDomainBlockResize: Properly resize disks with storage slice
Peter Krempa [Mon, 11 Dec 2023 14:37:51 +0000 (15:37 +0100)]
qemuDomainBlockResize: Properly resize disks with storage slice

Until now resizing a disk with a storage slice would break in one of the
following ways:

1) for a non-raw format, the virtual size would change, but the slice
would still remain in place
2) for raw disks qemu would refuse to change the size

The only reasonable scenario we want to support is a 'raw' image with 0
offset (inside a block device), where we can just drop the slice.

Anything else comes from a non-standard storage setup that we don't want
to touch.

To facilitate the resize, we first remove the 'size' parameter in qemu
thus dropping the slice and then instructing qemu to resize the disk.

Resolves: https://issues.redhat.com/browse/RHEL-18782
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agovirStorageSourceSliceFree: Export function
Peter Krempa [Mon, 11 Dec 2023 16:06:32 +0000 (17:06 +0100)]
virStorageSourceSliceFree: Export function

The function will be used in the code for resizing block devices with a
slice.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: block: Format storage slice properties optionally
Peter Krempa [Mon, 11 Dec 2023 16:13:39 +0000 (17:13 +0100)]
qemu: block: Format storage slice properties optionally

Prepare the blockdev props formatter to skip formatting the slice props
in case they are not applicable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: block: Make 'slice' layer effective for 'raw' storage source
Peter Krempa [Mon, 23 Oct 2023 13:46:26 +0000 (15:46 +0200)]
qemu: block: Make 'slice' layer effective for 'raw' storage source

Rather than pulling the configuration of the storage slice into the
'format' layer make the 'slice' layer effective for raw disks with a
storage slice. This was made possible by the recent refactors which made
the 'format' layer optional if not needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemuDomainBlockResize: Implement VIR_DOMAIN_BLOCK_RESIZE_CAPACITY
Peter Krempa [Wed, 13 Dec 2023 14:44:36 +0000 (15:44 +0100)]
qemuDomainBlockResize: Implement VIR_DOMAIN_BLOCK_RESIZE_CAPACITY

Resizing of block-backed storage requires the user to pass the exact
capacity of the device. Implement code which will query it instead so
the user doesn't need to do that.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/449
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agovirDomainBlockResize: Introduce VIR_DOMAIN_BLOCK_RESIZE_CAPACITY
Peter Krempa [Wed, 13 Dec 2023 09:07:52 +0000 (10:07 +0100)]
virDomainBlockResize: Introduce VIR_DOMAIN_BLOCK_RESIZE_CAPACITY

Allow users to easily resize 'raw' images on block devices to the full
capacity of the block device. Obviously this won't work on file-backed
storage (filling the remaining capacity is most likely wrong) or for
formats with metadata due to the overhead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agovsh: Introduce simple version of VSH_ALTERNATIVE_OPTIONS_EXPR
Peter Krempa [Wed, 13 Dec 2023 13:23:45 +0000 (14:23 +0100)]
vsh: Introduce simple version of VSH_ALTERNATIVE_OPTIONS_EXPR

VSH_ALTERNATIVE_OPTIONS takes just the name of the options instead of
requiring also the getter functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemuDomainBlockResize: Agregate all checks at the beginning
Peter Krempa [Wed, 13 Dec 2023 15:55:59 +0000 (16:55 +0100)]
qemuDomainBlockResize: Agregate all checks at the beginning

Move the check for readonly and empty disks to the top where all other
checks will be done.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: Use qemuBlockStorageSourceIsLUKS/qemuBlockStorageSourceIsRaw
Peter Krempa [Tue, 12 Dec 2023 16:16:25 +0000 (17:16 +0100)]
qemu: Use qemuBlockStorageSourceIsLUKS/qemuBlockStorageSourceIsRaw

Refactor code checking whether image is raw. This fixes multiple places
where a LUKS encrypted disk could be mistreated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: block: Introduce helpers for properly testing for 'raw' and 'luks' images
Peter Krempa [Tue, 12 Dec 2023 16:11:45 +0000 (17:11 +0100)]
qemu: block: Introduce helpers for properly testing for 'raw' and 'luks' images

Unfortunately a LUKS image to be decrypted by qemu has
VIR_STORAGE_FILE_RAW as format, but has encryption properties populated.

Many places in the code don't check it properly and also don't check
properly whether the image is indeed LUKS to be decrypted by qemu.

Introduce helpers which will simplify this task.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Spellchecked-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: migration: Automatically fix non-shared-storage migration to bigger block devices
Peter Krempa [Wed, 6 Dec 2023 14:57:16 +0000 (15:57 +0100)]
qemu: migration: Automatically fix non-shared-storage migration to bigger block devices

QEMU's blockdev-mirror job doesn't allow copy into a destination which
isn't exactly the same size as source. This is a problem for
non-shared-storage migration when migrating into a raw block device, as
there it's very hard to ensure that the destination size will match the
source size.

Rather than failing the migration, we can add a storage slice in such
case automatically and thus make the migration pass.

To do this we need to probe the size of the block device on the
destination and if it differs form the size detected on the source we'll
install the 'slice'.

An additional handling is required when persisting the VM as we want to
propagate the slice even there to ensure that the device sizes won't
change.

Resolves: https://issues.redhat.com/browse/RHEL-4607
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: Move and export qemuDomainStorageUpdatePhysical and dependencies
Peter Krempa [Wed, 6 Dec 2023 14:42:29 +0000 (15:42 +0100)]
qemu: Move and export qemuDomainStorageUpdatePhysical and dependencies

Move qemuDomainStorageUpdatePhysical, qemuDomainStorageOpenStat,
qemuDomainStorageCloseStat to qemu_domain.c and export them. They'll be
reused in the migration code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: migration: Rename qemuMigrationDstPrecreateStorage to qemuMigrationDstPrepareSt...
Peter Krempa [Wed, 6 Dec 2023 13:58:48 +0000 (14:58 +0100)]
qemu: migration: Rename qemuMigrationDstPrecreateStorage to qemuMigrationDstPrepareStorage

The function will be used to setup storage for non-shared-storage
migration, not just precreate images.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemuDomainStorageOpenStat: Remove unused 'driver' argument and untangle callers
Peter Krempa [Wed, 6 Dec 2023 14:29:03 +0000 (15:29 +0100)]
qemuDomainStorageOpenStat: Remove unused 'driver' argument and untangle callers

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemu: migration: Improve handling of VIR_MIGRATE_PARAM_DEST_XML with VIR_MIGRATE_PERS...
Peter Krempa [Thu, 7 Dec 2023 14:22:58 +0000 (15:22 +0100)]
qemu: migration: Improve handling of VIR_MIGRATE_PARAM_DEST_XML with VIR_MIGRATE_PERSIST_DEST

When a user provides a migration XML via the VIR_MIGRATE_PARAM_DEST_XML
it's expected that they want to change ABI-compatible aspects of the XML
such as the disk paths or similar.

If the user requests persisting of the VM but does not provide an
explicit persistent XML libvirt would take the persistent XML from the
source of the migration as the persistent config. This usually involves
the old paths to images.

Doing this would result into failure to start the VM.

It makes more sense to take the XML used for migration and use that as
the base for persisting the config.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemuMigrationDstPrecreateStorage: Fix and clarify logic
Peter Krempa [Wed, 6 Dec 2023 13:47:01 +0000 (14:47 +0100)]
qemuMigrationDstPrecreateStorage: Fix and clarify logic

While it's intended that qemuMigrationDstPrecreateDisk is called with
any kind of the disk, the logic in qemuMigrationDstPrecreateStorage
which checks the existence of the image wouldn't properly handle e.g.
network backed disks, where it would attempt to use virFileExists() on
the disk's 'src->path'.

Fix the logic by first skipping disks not meant for migration, then do
the existence check only when 'disk->src' is local storage.

Since qemuMigrationDstPrecreateDisk has a debug statement there's no
need to have an extra one right before calling into it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemuMigrationDstPrecreateStorage: Refactor cleanup
Peter Krempa [Wed, 6 Dec 2023 13:32:09 +0000 (14:32 +0100)]
qemuMigrationDstPrecreateStorage: Refactor cleanup

Use automatic pointer freeing for 'conn' and remove the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoqemuMigrationDstPrecreateStorage: Improve error messages
Peter Krempa [Wed, 6 Dec 2023 13:30:24 +0000 (14:30 +0100)]
qemuMigrationDstPrecreateStorage: Improve error messages

Change the error messages so that they can be used to identify the
problematic disk or image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 11 Dec 2023 11:44:02 +0000 (12:44 +0100)]
Translated using Weblate (Swedish)

Currently translated at 57.1% (5954 of 10417 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>
16 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 10 Dec 2023 10:44:00 +0000 (11:44 +0100)]
Translated using Weblate (Swedish)

Currently translated at 56.9% (5933 of 10417 strings)

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

Translated using Weblate (Swedish)

Currently translated at 56.7% (5912 of 10417 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>