]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
19 hours agotests: properly mock VFIO and IOMMU checks master
Pavel Hrdina [Mon, 16 Feb 2026 15:53:57 +0000 (16:53 +0100)] 
tests: properly mock VFIO and IOMMU checks

Fixes: 63434db800b921e96fec424a667b7161af1f02de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
20 hours agoqemu: Fill iommufd domain capability
Pavel Hrdina [Mon, 16 Feb 2026 09:44:57 +0000 (10:44 +0100)] 
qemu: Fill iommufd domain capability

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoconf: Introduce iommufd enum for domaincaps
Pavel Hrdina [Sat, 14 Feb 2026 05:14:20 +0000 (06:14 +0100)] 
conf: Introduce iommufd enum for domaincaps

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_hotplug: Add support to hotplug host device with IOMMUFD
Pavel Hrdina [Sun, 15 Feb 2026 20:21:53 +0000 (21:21 +0100)] 
qemu_hotplug: Add support to hotplug host device with IOMMUFD

For first host device we need to add iommufd object as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_command: Extract building IOMMUFD props to function
Pavel Hrdina [Sun, 15 Feb 2026 19:10:50 +0000 (20:10 +0100)] 
qemu_command: Extract building IOMMUFD props to function

This will be reused by hotplug code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_hotplug: Remove iommufd object if no longer needed
Pavel Hrdina [Sun, 15 Feb 2026 18:57:12 +0000 (19:57 +0100)] 
qemu_hotplug: Remove iommufd object if no longer needed

When removing last host device using IOMMUFD remove the iommufd object
as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu: Save IOMMUFD state into status XML
Pavel Hrdina [Sat, 14 Feb 2026 16:54:57 +0000 (17:54 +0100)] 
qemu: Save IOMMUFD state into status XML

We need to track if iommufd object was added to the VM when we add
hotplug support.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_command: Don't use host property if IOMMUFD is used
Pavel Hrdina [Sun, 15 Feb 2026 18:49:16 +0000 (19:49 +0100)] 
qemu_command: Don't use host property if IOMMUFD is used

They should not be used at the same time.

Fixes: f6230804727df834da27370e835204672218ab23
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu: Convert vfioDeviceFd to qemuFDPassDirect
Pavel Hrdina [Sun, 15 Feb 2026 18:28:16 +0000 (19:28 +0100)] 
qemu: Convert vfioDeviceFd to qemuFDPassDirect

This cleans up creating QEMU command line and makes it easier when
adding hotplug support.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu: Convert IOMMUFD to qemuFDPassDirect
Pavel Hrdina [Sun, 15 Feb 2026 18:42:39 +0000 (19:42 +0100)] 
qemu: Convert IOMMUFD to qemuFDPassDirect

This cleans up creating QEMU command line and makes it easier when
adding hotplug support.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemuxmlconftest: Set fake FD for IOMMUFD
Pavel Hrdina [Sat, 14 Feb 2026 16:11:44 +0000 (17:11 +0100)] 
qemuxmlconftest: Set fake FD for IOMMUFD

Same as for VFIO FD for host device.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemuxmlconftest: Rename and refactor testSetupHostdevPrivateData
Pavel Hrdina [Sat, 14 Feb 2026 10:48:53 +0000 (11:48 +0100)] 
qemuxmlconftest: Rename and refactor testSetupHostdevPrivateData

There is no need to call qemuDomainHostdevPrivateNew() because
privateData is allocated on creation by virDomainHostdevDefNew().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemuxmlconftest: Refactor host device preparation
Pavel Hrdina [Sat, 14 Feb 2026 10:39:19 +0000 (11:39 +0100)] 
qemuxmlconftest: Refactor host device preparation

Create a single place for host device preparation code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_process: Refactor qemuProcessOpenVfioFds
Pavel Hrdina [Sun, 15 Feb 2026 18:15:52 +0000 (19:15 +0100)] 
qemu_process: Refactor qemuProcessOpenVfioFds

Follow our switch pattern to simplify the code logic
and rename the function to follow our naming pattern.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_process: Fix FD leak with multiple host devices using IOMMUFD
Pavel Hrdina [Sun, 15 Feb 2026 18:13:19 +0000 (19:13 +0100)] 
qemu_process: Fix FD leak with multiple host devices using IOMMUFD

We would open IOMMU device for each host device with IOMMUFD backend
leaking FD except for the last one. Since we are adding only single
iommufd object we need to open it only once.

Fixes: 2f0999a161910e3992458902ce90d37f8b8f2642
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_domain: Add missing IOMMUFD cleanup
Pavel Hrdina [Sat, 14 Feb 2026 15:12:11 +0000 (16:12 +0100)] 
qemu_domain: Add missing IOMMUFD cleanup

If starting VM fails we would leak the FD for IOMMU device.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoconf: Introduce virDomainDefHasPCIHostdevWithIOMMUFD
Pavel Hrdina [Sun, 15 Feb 2026 17:19:56 +0000 (18:19 +0100)] 
conf: Introduce virDomainDefHasPCIHostdevWithIOMMUFD

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoconf: Introduce virHostdevIsPCIDeviceWithIOMMUFD
Pavel Hrdina [Sun, 15 Feb 2026 17:19:23 +0000 (18:19 +0100)] 
conf: Introduce virHostdevIsPCIDeviceWithIOMMUFD

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoutil: Use virPCIDevice as argument in virPCIDeviceGetVfioPath
Pavel Hrdina [Sun, 15 Feb 2026 16:51:46 +0000 (17:51 +0100)] 
util: Use virPCIDevice as argument in virPCIDeviceGetVfioPath

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_process: Refactor qemuProcessOpenVfioDeviceFd
Pavel Hrdina [Sun, 15 Feb 2026 18:09:23 +0000 (19:09 +0100)] 
qemu_process: Refactor qemuProcessOpenVfioDeviceFd

This will allow us reusing same code for hotplug support.
As part of refactor remove redundant checks.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoutil: Move openning VFIO device to virpci
Pavel Hrdina [Sun, 15 Feb 2026 16:39:05 +0000 (17:39 +0100)] 
util: Move openning VFIO device to virpci

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu_process: Refactor qemuProcessOpenIommuFd
Pavel Hrdina [Sun, 15 Feb 2026 18:01:35 +0000 (19:01 +0100)] 
qemu_process: Refactor qemuProcessOpenIommuFd

This will allow us reusing same code for hotplug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoutil: Move openning IOMMU device to viriommufd
Pavel Hrdina [Sun, 15 Feb 2026 14:32:24 +0000 (15:32 +0100)] 
util: Move openning IOMMU device to viriommufd

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu: Move IOMMUFD validation to qemu_validate
Pavel Hrdina [Mon, 16 Feb 2026 08:12:02 +0000 (09:12 +0100)] 
qemu: Move IOMMUFD validation to qemu_validate

Fail early if kernel doesn't support IOMMUFD.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoqemu: Introduce QEMU_CAPS_OBJECT_IOMMUFD
Pavel Hrdina [Mon, 16 Feb 2026 07:59:39 +0000 (08:59 +0100)] 
qemu: Introduce QEMU_CAPS_OBJECT_IOMMUFD

Detect if QEMU was compiled with IOMMUFD.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 hours agoscripts: avoid matching 'char **' as string for systemtap
Daniel P. Berrangé [Mon, 16 Feb 2026 10:00:48 +0000 (10:00 +0000)] 
scripts: avoid matching 'char **' as string for systemtap

When a probe argument is declared "char *" we reference the userspace
string value using 'user_string(...)' for systemtap.

Unfortunately our code generator also matches on args declared "char **"
and generates bogus code

   *cert = user_string($arg4);

which is a syntax error for systemtap.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
25 hours agoqemu: Setup disk latency histograms on startup/hotplug/update
Peter Krempa [Fri, 23 Jan 2026 16:18:14 +0000 (17:18 +0100)] 
qemu: Setup disk latency histograms on startup/hotplug/update

Setup the histograms on startup and hotplug of devices via
'qemuProcessSetupDiskPropsRuntime' and facilitate update/reset/disable
of histogram collection via 'qemuDomainChangeDiskLive'.

The latter allows to use the update device API to either clear the bins
or select new bin configuration or disable the histogram altogether
without the need for a specific API.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agoIntroduce support for disk operation latency histogram collection
Peter Krempa [Fri, 23 Jan 2026 16:09:27 +0000 (17:09 +0100)] 
Introduce support for disk operation latency histogram collection

Add config and docs allowing enabling latency histogram collection for
block device operations.

This patch sets up the docs, schema and XML infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agodocs: formatdomain: Reword section about the '<statistics>' element under disk driver
Peter Krempa [Fri, 30 Jan 2026 16:37:48 +0000 (17:37 +0100)] 
docs: formatdomain: Reword section about the '<statistics>' element under disk driver

Separate the timed statistics group and link to the fields which are
returned by it.

Prepare the wording for more statistics configs in the future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agodocs: formatdomain: Fix indentation of docs for <disk><driver><statistics> element
Peter Krempa [Fri, 30 Jan 2026 16:47:46 +0000 (17:47 +0100)] 
docs: formatdomain: Fix indentation of docs for <disk><driver><statistics> element

All other paragraphs in this section use 2 spaces after hyphen, fix the
recently added section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agoqemu: monitor: Add handlers for 'block-latency-histogram-set'
Peter Krempa [Thu, 11 Dec 2025 17:38:12 +0000 (18:38 +0100)] 
qemu: monitor: Add handlers for 'block-latency-histogram-set'

Add QMP monitor code for setting up latency histogram configuration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agoExpose latency histograms via 'virConnectGetAllDomainStats'
Peter Krempa [Thu, 29 Jan 2026 17:10:26 +0000 (18:10 +0100)] 
Expose latency histograms via 'virConnectGetAllDomainStats'

Add documentation and constants for constructing the stats field names
for latency histograms and expose them in the qemu driver:

Example:

  block.1.latency_histogram.read.bin.count=9
  block.1.latency_histogram.read.bin.0.start=0
  block.1.latency_histogram.read.bin.0.value=0
  block.1.latency_histogram.read.bin.1.start=10
  block.1.latency_histogram.read.bin.1.value=0
  block.1.latency_histogram.read.bin.2.start=100
  block.1.latency_histogram.read.bin.2.value=0
  block.1.latency_histogram.read.bin.3.start=1000
  block.1.latency_histogram.read.bin.3.value=1047
  block.1.latency_histogram.read.bin.4.start=10000
  block.1.latency_histogram.read.bin.4.value=2131
  block.1.latency_histogram.read.bin.5.start=100000
  block.1.latency_histogram.read.bin.5.value=0
  block.1.latency_histogram.read.bin.6.start=1000000
  block.1.latency_histogram.read.bin.6.value=0
  block.1.latency_histogram.read.bin.7.start=10000000
  block.1.latency_histogram.read.bin.7.value=0
  block.1.latency_histogram.read.bin.8.start=100000000
  block.1.latency_histogram.read.bin.8.value=0

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agoqemu: monitor: Extract block latency histogram stats into 'qemuBlockStats'
Peter Krempa [Thu, 29 Jan 2026 13:08:18 +0000 (14:08 +0100)] 
qemu: monitor: Extract block latency histogram stats into 'qemuBlockStats'

Extract the 'rd_latency_histogram', 'wr_latency_histogram',
'zone_append_latency_histogram', and 'flush_latency_histogram' stats
objects into our internal data.

Rather than storing 'boundaries' between bins we store them as start
points.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agoqemu: process: Rename 'qemuProcessSetupDiskThrottling' to 'qemuProcessSetupDisks'
Peter Krempa [Thu, 29 Jan 2026 10:21:38 +0000 (11:21 +0100)] 
qemu: process: Rename 'qemuProcessSetupDiskThrottling' to 'qemuProcessSetupDisks'

Rename the runtime disk option setup function to be universal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
25 hours agoqemu: Extract disk setup done via QMP into a separate helper
Peter Krempa [Thu, 29 Jan 2026 10:15:04 +0000 (11:15 +0100)] 
qemu: Extract disk setup done via QMP into a separate helper

Introduce 'qemuProcessSetupDiskPropsRuntime' helper function which will
collect all code used for runtime setup of a disk.

This is currently old-style throttling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 days agoqemu: Wire up new hyperv host-model mode behavior
Michal Privoznik [Wed, 11 Feb 2026 09:16:34 +0000 (10:16 +0100)] 
qemu: Wire up new hyperv host-model mode behavior

Since some hyperv features might be already enabled/disabled when
entering qemuProcessEnableDomainFeatures() only those which are
not set in domain XML (i.e. are VIR_TRISTATE_SWITCH_ABSENT)
should be modified. Furthermore, some features are not a simple
on/off switch, but a number or a string even. Well, that doesn't
matter really as the logic for setting them is the same: only set
their value iff they are not already set.

Resolves: https://issues.redhat.com/browse/RHEL-148219
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agoconf: Parse hyperv features even for host-model
Michal Privoznik [Wed, 11 Feb 2026 09:16:28 +0000 (10:16 +0100)] 
conf: Parse hyperv features even for host-model

As it turns out, some users of the hyperv "host-model" mode might
want to override the hypervisor defaults. For instance disable a
feature that's on by default, or vice versa. Currently, this is
not possible because as soon as our XML parser sees the
"host-model" mode it exits early and skips parsing of individual
features (for "custom" mode). Well, do not return early and parse
the rest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agobhyve: improve loader handling on arm64
Roman Bogorodskiy [Fri, 23 Jan 2026 17:59:56 +0000 (18:59 +0100)] 
bhyve: improve loader handling on arm64

Bhyve on arm64 does not have the bhyveload(8) tool.
That means that it cannot be used as a default if the loader is not
configured for the domain.

To prevent users from getting unusable configurations, handle loader
configuration on arm64 like that:

 - if loader is specified in the domain XML, just use it
 - if not specified, try to check whether the default uboot loader
   is available on the system. In case it is, set is as the loader,
   otherwise fail with the error.

Additionally, the loader could be configured in bhyve.conf.
By default, it uses the loader installed by the
sysutils/u-boot-bhyve-arm64 port or a corresponding package.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agoIn virFDStreamRead(), fill buffer from this and next messages
Erik Huelsmann [Wed, 11 Feb 2026 17:36:06 +0000 (18:36 +0100)] 
In virFDStreamRead(), fill buffer from this and next messages

Before this change, buffers returned from virFDStreamRead() would
alternate in size (262120 and 24), because it only consumed the
bytes remaining from the current background thread message.

As the background thread reads 262144 bytes (256kB) of data in
each chunk, where the maximum size returned from virFDStreamRead()
to be transferred over the remote protocol is only 262120, 24 bytes
would be left in the buffer on each iteration. The next iteration
leaves 24 bytes, which used to be returned without considering
messages waiting in the queue.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Erik Huelsmann <ehuels@gmail.com>
4 days agobhyve: add capability probing for ACPI
Roman Bogorodskiy [Wed, 21 Jan 2026 19:15:37 +0000 (20:15 +0100)] 
bhyve: add capability probing for ACPI

Bhyve used the '-A' flag to enable ACPI until it was deprecated
by commit:

https://cgit.freebsd.org/src/commit/?id=6a0e7f908802b86ca5d1c0b3c404b8391d0f626e

With that, ACPI tables are always generated. As this change is
relatively new and there are likely systems that have bhyve(8) that
requires using the '-A' flag, add a capability probing for that, and
use this flag if it's supported.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agobhyve: do not use deprecated IOAPIC option
Roman Bogorodskiy [Wed, 21 Jan 2026 18:55:54 +0000 (19:55 +0100)] 
bhyve: do not use deprecated IOAPIC option

The '-I' flag for enabling IOAPIC was deprecated long ago in bhyve:

https://cgit.freebsd.org/src/commit/?id=a1a4cbea587a6e201e07dc121268f3e559e2969f

And IOAPIC is provided unconditionally since then. As no supported
FreeBSD versions require that now, simply drop this flag.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agoutil: remove duplicate logging of firewall command
Daniel P. Berrangé [Fri, 16 Jan 2026 17:31:25 +0000 (12:31 -0500)] 
util: remove duplicate logging of firewall command

The vircommand.c code will always log the argv about to
be run, so logging it again in virfirewall.c is redundant.
Removing the dupe avoids the repeated memory allocation
from the array -> string conversion.

The minor difference is the downgrade from INFO to DEBUG
level, but the use of INFO level was out of character for
libvirt to begin with.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 days agodocs: secret: Add documentation of secret encryption feature
Arun Menon [Tue, 10 Feb 2026 17:56:43 +0000 (23:26 +0530)] 
docs: secret: Add documentation of secret encryption feature

Document the new encryption of secrets feature in secretencryption.rst.

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agosecret: Add functionality to load and save secrets in encrypted format
Arun Menon [Tue, 10 Feb 2026 17:56:42 +0000 (23:26 +0530)] 
secret: Add functionality to load and save secrets in encrypted format

Now that we have the functionality to provide the secrets driver
with an encryption key through a configuration file or using system
credentials, and the newly introduced array to iterate over the
encryption schemes, we can use the key to save and load secrets.

Encrypt all secrets that are going to be saved on the disk if the
'secrets_encryption_key' path is set in the secret.conf file OR
if a valid systemd generated credential exists.

While loading secrets, identify the decryption method by matching the file
extension of the stored secret against the known array values.
If no matching scheme is found, the secret is skipped. If the encryption
key is changed across restarts, then also the secret driver will fail to load
the secrets from the disk that were encrypted with the former key.

Signed-off-by: Arun Menon <armenon@redhat.com>
Co-authored-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agosecret: Rename virSecretObj structure attribute from base64File to secretValueFile
Arun Menon [Tue, 10 Feb 2026 17:56:41 +0000 (23:26 +0530)] 
secret: Rename virSecretObj structure attribute from base64File to secretValueFile

Change the attribute name of _virSecretObj because we want it to have a generic
name to indicate that secret values can be stored in it in both base64 and
encrypted formats.

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agosecret: Add secret.conf configuration file and parse it
Arun Menon [Tue, 10 Feb 2026 17:56:40 +0000 (23:26 +0530)] 
secret: Add secret.conf configuration file and parse it

A new configuration file called secret.conf is introduced to
let the user configure the path to the secrets encryption key.
This key will be used to encrypt/decrypt the secrets in libvirt.

By default the path is set to the runtime directory
/run/libvirt/secrets, and it is commented in the config file.
After parsing the file, the virtsecretd driver checks if an
encryption key is present in the path and is valid.

If no encryption key is present in the path, then
the service will by default use the encryption key stored in the
CREDENTIALS_DIRECTORY.

Add logic to parse the encryption key file and store the key.
It also checks for the encrypt_data attribute in the config file.
The encryption and decryption logic will be added in the subsequent patches.

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agosecret: Set up default encryption secret key for the virtsecretd service
Arun Menon [Tue, 10 Feb 2026 17:56:39 +0000 (23:26 +0530)] 
secret: Set up default encryption secret key for the virtsecretd service

This commit sets the foundation for encrypting the libvirt secrets by providing a
secure way to pass a secret encryption key to the virtsecretd service.

A random secret key is generated using the new virt-secret-init-encryption
service. This key can be consumed by the virtsecretd service.

By using the "Before=" directive in the new virt-secret-init-encryption
service and using "Requires=" directive in the virtsecretd service,
we make sure that the daemon is run only after we have an encrypted
secret key file generated and placed in /var/lib/libvirt/secrets.
The virtsecretd service can then read the key from CREDENTIALS_DIRECTORY. [1]

This setup therefore provides a default key out-of-the-box for initial use.
A subsequent commit will introduce the logic for virtsecretd
to access and use this key via the $CREDENTIALS_DIRECTORY environment variable. [2]

[1] https://www.freedesktop.org/software/systemd/man/latest/systemd-creds.html
[2] https://systemd.io/CREDENTIALS/

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agoutil: Add support for GnuTLS decryption
Arun Menon [Tue, 10 Feb 2026 17:56:38 +0000 (23:26 +0530)] 
util: Add support for GnuTLS decryption

Adds `virCryptoDecryptDataAESgnutls` and `virCryptoDecryptData`
as wrapper functions for GnuTLS decryption.

These functions are the inverse of the existing GnuTLS encryption wrappers.
This commit also includes a corresponding test case to validate data decryption.

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agoqemuProcessRefreshDisks: Don't bother to refresh disks on cold boot
Peter Krempa [Thu, 5 Feb 2026 14:10:36 +0000 (15:10 +0100)] 
qemuProcessRefreshDisks: Don't bother to refresh disks on cold boot

The only thing that 'qemuProcessRefreshDisks' currently does is to
update tray state for disks. This makes no sense on cold boot since only
cdroms have tray and the tray is closed.

Avoid the extra call to 'query-block' on cold boot and just assume CDROM
has a closed tray.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuProcessUpdateVideoRamSize: Remove 'driver' argument and adjust callers
Peter Krempa [Thu, 5 Feb 2026 13:54:02 +0000 (14:54 +0100)] 
qemuProcessUpdateVideoRamSize: Remove 'driver' argument and adjust callers

'driver' is part of domain's private data. Use it directly and adjust
all callers recursively.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: Refactor tray_status handling
Peter Krempa [Thu, 5 Feb 2026 13:31:41 +0000 (14:31 +0100)] 
qemu: Refactor tray_status handling

Modify the monitor code to directly return values from 'virDomainDiskTray'
enum instead of two bools.

This allows simplification of the other code:
 - qemuProcessRefreshDiskProps just assigns the value, thus can be deleted
 - old_tray_status is no longer needed as we can directly access the
   disk status instead and assign later

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuDomainAttachDiskGeneric: Avoid unneeded disk property refresh after hotplug
Peter Krempa [Thu, 5 Feb 2026 13:18:46 +0000 (14:18 +0100)] 
qemuDomainAttachDiskGeneric: Avoid unneeded disk property refresh after hotplug

The only thing the call to 'qemuProcessRefreshDiskProps' would update
from data gathered from a 'query-block' QMP call would be the state of
the tray of the device. We know that only CDROM devices have a tray and
after hotplug it's closed.

Remove the unneeded code and adjust tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuDomainDiskPrivate: Remove unused 'tray' field
Peter Krempa [Thu, 5 Feb 2026 13:01:41 +0000 (14:01 +0100)] 
qemuDomainDiskPrivate: Remove unused 'tray' field

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoconf: domain: Add VIR_DOMAIN_DISK_TRAY_NONE state for devices without tray
Peter Krempa [Tue, 3 Feb 2026 14:14:14 +0000 (15:14 +0100)] 
conf: domain: Add VIR_DOMAIN_DISK_TRAY_NONE state for devices without tray

Currently the default state was VIR_DOMAIN_DISK_TRAY_CLOSED. Not all
disks have a tray so add another state as the default and adjust code
which was based on the assumption that the tray is always present.

This change also removes the need for the 'tray' field in the disk
private data which was used inconsistently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuDomainDiskInfo: Use proper type for 'io_status'
Peter Krempa [Thu, 5 Feb 2026 11:02:58 +0000 (12:02 +0100)] 
qemuDomainDiskInfo: Use proper type for 'io_status'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuMonitorJSONGetBlockInfo: Don't fail if 'io-status' field gets new values
Peter Krempa [Thu, 5 Feb 2026 10:47:46 +0000 (11:47 +0100)] 
qemuMonitorJSONGetBlockInfo: Don't fail if 'io-status' field gets new values

Strictly validating qemu replies and rejecting unknown values can have
bad consequences in case qemu adds a new value.

Refactor the code parsing 'io-status' field from 'query-block' to be
tolerant to new values to avoid failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuMonitorJSONHandleMemoryFailure: Simplify error case and value extraction
Peter Krempa [Wed, 4 Feb 2026 10:41:50 +0000 (11:41 +0100)] 
qemuMonitorJSONHandleMemoryFailure: Simplify error case and value extraction

Report missing 'recipient' and 'action' together with the warning about
unknown value. Use the actual name of the event.

Additional booleans can be extracted without extra variables.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: monitor: Add test validating that 'eventHandlers' are properly sorted
Peter Krempa [Wed, 4 Feb 2026 10:35:57 +0000 (11:35 +0100)] 
qemu: monitor: Add test validating that 'eventHandlers' are properly sorted

The monitor code uses 'bsearch' to look up the event handler so the
event names must be properly listed. Until now only a comment reminded
us to do it. Add a test to verify that it is actually sorted properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuMonitorJSONHandleMigrationStatus: Simplify error case
Peter Krempa [Wed, 4 Feb 2026 09:47:53 +0000 (10:47 +0100)] 
qemuMonitorJSONHandleMigrationStatus: Simplify error case

Report both missing 'status' and invalid value in a single error
message. Also use the proper spelling of the event name (all caps).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: Drop 'removable' field from 'qemuDomainDiskInfo'
Peter Krempa [Tue, 3 Feb 2026 17:01:15 +0000 (18:01 +0100)] 
qemu: Drop 'removable' field from 'qemuDomainDiskInfo'

The only real use was in 'qemuProcessRefreshDiskProps' where it guarded
assignment of 'tray' status. Since qemu doesn't actually report any tray
status for devices which don't have a tray there's no need for the extra
guard.

Remove the field completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: process: Unexport 'qemuProcessRefreshDisks'
Peter Krempa [Tue, 3 Feb 2026 16:50:27 +0000 (17:50 +0100)] 
qemu: process: Unexport 'qemuProcessRefreshDisks'

Since it's currently called above the place where it is defined we also
need to move it within qemu_process.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuMigrationSrcBegin: Drop disk refresh step
Peter Krempa [Tue, 3 Feb 2026 16:46:10 +0000 (17:46 +0100)] 
qemuMigrationSrcBegin: Drop disk refresh step

Since 'qemuProcessRefreshDiskProps' doesn't remove the source since we
switched to blockdev mode, we don't need to update disk state at the
beginning of migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: Drop 'empty' filed from 'qemuDomainDiskInfo'
Peter Krempa [Tue, 3 Feb 2026 16:53:09 +0000 (17:53 +0100)] 
qemu: Drop 'empty' filed from 'qemuDomainDiskInfo'

The value is no longer used so drop the field and also the code which
fetches it from the QMP command reply.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuProcessRefreshDiskProps: Drop code to remove disk source
Peter Krempa [Tue, 3 Feb 2026 16:41:21 +0000 (17:41 +0100)] 
qemuProcessRefreshDiskProps: Drop code to remove disk source

In blockdev mode, the guest OS can't force the drive to become empty
(opening cdrom tray doesn't remove media; floppies can't be ejected from
guest OS), so the check if a drive is empty is dead code at this point.

Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: Remove 'removable' field from 'qemuDomainDiskPrivate'
Peter Krempa [Thu, 29 Jan 2026 09:28:16 +0000 (10:28 +0100)] 
qemu: Remove 'removable' field from 'qemuDomainDiskPrivate'

The field is only set, but never read. Drop it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemuDomainDiskInfo: Drop 'nodename' field
Peter Krempa [Thu, 11 Dec 2025 09:52:55 +0000 (10:52 +0100)] 
qemuDomainDiskInfo: Drop 'nodename' field

The field is only read in tests. Other code using it no longer exists.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 days agoqemu: Implement support for persistent reservation migration control
Peter Krempa [Thu, 11 Dec 2025 18:47:16 +0000 (19:47 +0100)] 
qemu: Implement support for persistent reservation migration control

The 'migration' attribute for the '<reservations>' element allows to
control the persistent reservation migration feature independently of
the machine type default.

Add the XML plumbing and qemu support.

We consider it ABI for now since it influences qemu migration protocol.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agoqemu: capabilities: Introduce QEMU_CAPS_DEVICE_SCSI_BLOCK_MIGRATE_PR
Peter Krempa [Thu, 11 Dec 2025 18:26:40 +0000 (19:26 +0100)] 
qemu: capabilities: Introduce QEMU_CAPS_DEVICE_SCSI_BLOCK_MIGRATE_PR

Introduce capability for persisten migration control support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agoqemucapabilitiestest: Update 'caps_11.0.0_aarch64' to 'v10.2.0-1114-gb3abdfa486'
Peter Krempa [Tue, 10 Feb 2026 09:54:28 +0000 (10:54 +0100)] 
qemucapabilitiestest: Update 'caps_11.0.0_aarch64' to 'v10.2.0-1114-gb3abdfa486'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agoqemucapabilitiestest: Update 'caps_11.0.0_x86_64' to 'v10.2.0-1114-gb3abdfa486'
Peter Krempa [Mon, 2 Feb 2026 18:46:33 +0000 (19:46 +0100)] 
qemucapabilitiestest: Update 'caps_11.0.0_x86_64' to 'v10.2.0-1114-gb3abdfa486'

Notable changes:
 - migration:
    - 'detach' option removed
    - 'zero-blocks' capability removed
    - 'query-migrationthreads' removed
 - 'fsl-esdhc-be', 'fsl-esdhc-le' QOM objects added
 - 'iommu-testdev' qom object added
 - 'vhost-user-spi-device', 'vhost-user-spi-pci' qom types added
 - CPU feature 'cet-ss' became migratable
 - property 'svm' of 'intel-iommu' device added
 - property 'migrate-pr' of 'scsi-block' device added
 - property 'x-vpasid-cap-offset' of 'vfio-pci' device added

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 days agonetwork: add comment to table that it belongs to libvirt
Daniel P. Berrangé [Fri, 16 Jan 2026 17:32:30 +0000 (12:32 -0500)] 
network: add comment to table that it belongs to libvirt

The result looks like

$ nft list ruleset
...snip...
table ip6 libvirt_network {
comment "Managed by libvirt for virtual networks:   https://libvirt.org/firewall.html#the-virtual-network-driver"
chain forward {
...snip...

This should reduce the number of people wondering why
these rules exists.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 days agohyperv: Implement virDomainInterfaceAddresses()
Michal Privoznik [Wed, 4 Feb 2026 15:37:32 +0000 (16:37 +0100)] 
hyperv: Implement virDomainInterfaceAddresses()

The virDomainInterfaceAddresses() API accepts @source argument,
but since this is hyperv, we can't really use _SRC_LEASE (we
didn't spawn any dnsmasq there), not _SRC_ARP. The only source
that's more or less usable is _SRC_AGENT. Okay, there's no QEMU
guest agent running, but hyperv has its own guest agent. In my
testing (with Linux guest) I had to install 'hyperv' package and
then enable 'hv_kvp_daemon.service'. After that,
Msvm_GuestNetworkAdapterConfiguration struct [1] contained guest
IP addresses.

There's one caveat though: the interface name
(virDomainInterface::name). We don't fetch that one even for
hypervDomainGetXMLDesc() case. And there's no <target dev=''/>
either nor device alias (v12.0.0-43-g4009126f17). So just put
InstanceID there for now, which is this long path, with some
UUIDs, e.g.:

   Microsoft:5C58E5F2-946E-490F-B81D-6E2A7328640D\C85554E0-2B3B-487C-A557-D230BFF5F9E6\

But hey, at least it's unique.

1: https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/msvm-guestnetworkadapterconfiguration
Resolves: https://issues.redhat.com/browse/RHEL-145306
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agohyperv: Move MAC parsing into a separate function
Michal Privoznik [Fri, 6 Feb 2026 08:20:09 +0000 (09:20 +0100)] 
hyperv: Move MAC parsing into a separate function

When constructing a domain definition, NICs are fetched from WMI
and their MAC addresses are then parsed. Move this code into a
separate function so that it can be reused later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agovirsocketaddr: Introduce virSocketAddrSubnetToPrefix()
Michal Privoznik [Fri, 6 Feb 2026 11:52:40 +0000 (12:52 +0100)] 
virsocketaddr: Introduce virSocketAddrSubnetToPrefix()

The aim of this helper is to convert subnet mask to prefix. For
instance for input "255.0.0.0" to return 8. Additionally, if the
input string is already a prefix (with optional leading slash
character) just return that number parsed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agodatatypes: Declare autofree func for virDomainInterface type
Michal Privoznik [Fri, 6 Feb 2026 08:19:51 +0000 (09:19 +0100)] 
datatypes: Declare autofree func for virDomainInterface type

The virDomainInterface type (struct _virDomainInterface) is
defined in our public header and even has a public free function
(virDomainInterfaceFree()). But in our code we will want to use
automatic memory freeing for it. Hence, make appropriate
declaration in datatypes.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 days agonwfilter: move shared nwfilter driver functions into nwfilter_tech_driver.c
Dion Bosschieter [Tue, 10 Feb 2026 10:16:26 +0000 (11:16 +0100)] 
nwfilter: move shared nwfilter driver functions into nwfilter_tech_driver.c

Introduce nwfilter_tech_driver.c which holds shared non driver specific
methods.
The following logic can be reused by new nwfilter drivers, which are not
ebiptables specific:
- data type print logic, used for constructing ascii cli arguments out
  of nwfilter data;
- chain jump proto type l3_proto_idx logic;
- virNWFilterRule sorting.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
[DB: moved virstring.h include to source file & added to POTFILES]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 days agonwfilter: remove redundant sys/utsname.h include
Dion Bosschieter [Thu, 12 Feb 2026 12:17:49 +0000 (12:17 +0000)] 
nwfilter: remove redundant sys/utsname.h include

There are no calls to uname() in the ebiptables driver code.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
[DB: split from larger patch]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 days agonwfilter: rename generic names to virNWFilter* and CamelCase
Dion Bosschieter [Tue, 10 Feb 2026 10:16:25 +0000 (11:16 +0100)] 
nwfilter: rename generic names to virNWFilter* and CamelCase

Rename generic nwfilter data types and functions to virNWFilter prefix
and convert them to CamelCase. These data types and functions are quite
common to any nwfilter driver implementation. Prior to moving them out
of the nwfilter_ebiptables_driver.c file, we'll first rename them.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dion Bosschieter <dionbosschieter@gmail.com>
5 days agodocs: add description for USB port matching
Maximilian Martin [Mon, 18 Aug 2025 14:34:17 +0000 (16:34 +0200)] 
docs: add description for USB port matching

Adds documentation for the new USB bus/port addressing.
The new "port" attribute is explained.
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/513

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
5 days agonodedev: add USB port to nodedev XML
Maximilian Martin [Mon, 18 Aug 2025 14:34:16 +0000 (16:34 +0200)] 
nodedev: add USB port to nodedev XML

This adds the physical USB port to the capabilities of a
USB device in nodedev XML.
example: <port>1.4</port>

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
5 days agotests: validate an XML config with USB bus/port set
Maximilian Martin [Mon, 18 Aug 2025 14:34:15 +0000 (16:34 +0200)] 
tests: validate an XML config with USB bus/port set

USB bus/port addressing is translated into a bus/device addressing
at startup using the hostdev logic. This test covers XML parsing
and CLI formatting for bus/port addressing.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
5 days agoschema: add USB port attribute
Maximilian Martin [Mon, 18 Aug 2025 14:34:14 +0000 (16:34 +0200)] 
schema: add USB port attribute

Adds USB bus/port addressing the domain XML file
schema. Optionally, the physical USB port can be
declared instead of the USB device address.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
5 days agoconf: add support for host USB port matching
Maximilian Martin [Wed, 11 Feb 2026 18:20:45 +0000 (18:20 +0000)] 
conf: add support for host USB port matching

This patch implements USB bus/port matching in the XML schema.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
[DB: split host USB search parts out into previous patches]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 days agoutil: implement support for finding host USB devices by port
Maximilian Martin [Mon, 18 Aug 2025 14:34:13 +0000 (16:34 +0200)] 
util: implement support for finding host USB devices by port

Extend the API for finding host USB devices, to allow requesting
a search based on the port.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
[DB: split out of bigger patch]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 days agoutil: generalize the host USB device search APIs
Maximilian Martin [Mon, 18 Aug 2025 14:34:13 +0000 (16:34 +0200)] 
util: generalize the host USB device search APIs

Prepare for adding the ability to find host USB devices based
on their port, by generalizing the APIs for device searching
into one all-purpose API

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
[DB: split out of bigger patch]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 days agovirusb test data: add devpath files for port addressing
Maximilian Martin [Mon, 18 Aug 2025 14:34:12 +0000 (16:34 +0200)] 
virusb test data: add devpath files for port addressing

This patch adds devpath files to the virusb test data.
These files are mockups for the USB sysfs files that
contain the port of a USB device in dotted notation.
They are used for testing of USB bus/port matching.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
6 days agoqemu: Ignore cmp_legacy CPU flag
Jean-Louis Dupond [Thu, 5 Feb 2026 13:18:42 +0000 (14:18 +0100)] 
qemu: Ignore cmp_legacy CPU flag

Since commit 99a637a8 in qemu 10.0, the way the cmp_legacy flag is
reported changed. The same way as happend with the 'ht' flag in commit
c6bd2dd634208, which was fixed in libvirt since commit ba16113c.

This causes migrations from a hypervisor running a qemu version before
that commit to a hypervisor running qemu after that commit fails
with the following error:
guest CPU doesn't match specification: extra features: cmp_legacy

We can just ignore this flag, just like we did with the 'ht' flag.

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
8 days agovirsh: Switch cmdDomIfAddr() to vshTable
Michal Privoznik [Fri, 6 Feb 2026 14:29:38 +0000 (15:29 +0100)] 
virsh: Switch cmdDomIfAddr() to vshTable

The aim of cmdDomIfAddr() is to obtain IP addresses for given
domain and then print (ifName, MAC, type, IP Address) tuple.
Preferably in an aligned table. This is hard to do with printf
style of spacing ("%-NNs") since the interface name (ifName) can
vary a lot in length. Fortunately, we have vshTable which is
designed to handle this case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 days agoqemu_command: Generate granule prop for virtio-iommu
Michal Privoznik [Wed, 21 Jan 2026 12:00:39 +0000 (13:00 +0100)] 
qemu_command: Generate granule prop for virtio-iommu

Resolves: https://issues.redhat.com/browse/RHEL-76269
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agoqemu_validate: Check whether granule of virtio-iommu is supported
Michal Privoznik [Wed, 21 Jan 2026 11:54:17 +0000 (12:54 +0100)] 
qemu_validate: Check whether granule of virtio-iommu is supported

Just like with other features, check whether QEMU supports them
based on capabilities. Now, instead of inventing a new QEMU
capability, an existing one can be used:
QEMU_CAPS_VIRTIO_IOMMU_AW_BITS.

This is because the aw-bits and granule attributes were
introduced into QEMU in close succession (v9.0.0-rc0~9^2~7
v9.0.0-rc0~9^2~11), neither can be disabled at compile time and
backporting just one without the other makes almost no sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agoconf: Introduce granule attribute for virtio-iommu
Michal Privoznik [Wed, 21 Jan 2026 11:51:20 +0000 (12:51 +0100)] 
conf: Introduce granule attribute for virtio-iommu

In PCI assignment scenario the virtio-iommu needs to know the
guest page size also known as granule. Expose it as an attribute
to the <driver/> element of a virtio-iommu.

This is possibly interesting only for aarch64 since it supports
virtio-iommu and also supports running guests with different page
size than the host.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agoqemu_command: Generate aw_bits prop for virtio-iommu
Michal Privoznik [Wed, 21 Jan 2026 11:56:06 +0000 (12:56 +0100)] 
qemu_command: Generate aw_bits prop for virtio-iommu

Resolves: https://issues.redhat.com/browse/RHEL-76269
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agoconf: Allow aw_bits for virtio-iommu
Michal Privoznik [Wed, 21 Jan 2026 09:46:43 +0000 (10:46 +0100)] 
conf: Allow aw_bits for virtio-iommu

Introduced in QEMU commit of v9.0.0-rc0~9^2~7 the virtio-iommu
device is also capable of using different addres width. The
corresponding attribute is also called 'aw-bits', just like in
case of intel-iommu. Wire up the missing pieces.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agoqemu_capabilities: Introduce QEMU_CAPS_VIRTIO_IOMMU_AW_BITS
Michal Privoznik [Wed, 21 Jan 2026 09:36:57 +0000 (10:36 +0100)] 
qemu_capabilities: Introduce QEMU_CAPS_VIRTIO_IOMMU_AW_BITS

This capability tracks whether the virtio-iommu device has
aw-bits attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agoconf: Teach virDomainParseMemory() new retval
Michal Privoznik [Fri, 23 Jan 2026 09:09:15 +0000 (10:09 +0100)] 
conf: Teach virDomainParseMemory() new retval

So far, virDomainParseMemory() returns either 0 or -1. While this
allows callers to distinguish a success case from an error it
doesn't allow them to differentiate the case when no value was
provided in the XML, thus nothing was parsed and nothing was
required. Therefore, make virDomainParseMemory() return 1 on
success, 0 in case nothing was parsed and nothing was required,
and -1 on failure.

Arguably, no caller needs this distinction currently, but that is
about to change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 days agohyperv: Avoid memleak in hypervDomainDefParsePhysicalDisk
Michal Privoznik [Fri, 6 Feb 2026 13:26:27 +0000 (14:26 +0100)] 
hyperv: Avoid memleak in hypervDomainDefParsePhysicalDisk

When parsing a physical disk, the @hostResouce is escaped once
with the retval being stored into @hostEscaped. Then, it's
escaped again, but the retval is stored into the very same
variable, leading to a leak where intermediate value is lost.

256 bytes in 1 blocks are definitely lost in loss record 469 of 483
   at 0x49543A0: realloc (vg_replace_malloc.c:1804)
   by 0x516C251: g_realloc (in /usr/lib64/libglib-2.0.so.0.8400.4)
   by 0x518BB7E: g_string_expand (in /usr/lib64/libglib-2.0.so.0.8400.4)
   by 0x518BFF9: g_string_insert_len (in /usr/lib64/libglib-2.0.so.0.8400.4)
   by 0x4A58B5F: g_string_append_len_inline (gstring.h:247)
   by 0x4A58B5F: virBufferAdd (virbuffer.c:164)
   by 0x4AFDA71: virStringReplace (virstring.c:708)
   by 0x4DA4381: hypervDomainDefParsePhysicalDisk (hyperv_driver.c:1375)
   by 0x4DA4A18: hypervDomainDefParseStorage (hyperv_driver.c:1487)
   by 0x4DA9E31: hypervDomainGetXMLDesc (hyperv_driver.c:2761)
   by 0x4DFB3E5: virDomainGetXMLDesc (libvirt-domain.c:2898)
   by 0x406D39B: cmdDumpXML (virsh-domain.c:10787)
   by 0x40B13B1: vshCommandRun (vsh.c:1383)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 days agosrc/esx/esx_vi.c: Debug path element comparisons
Richard W.M. Jones [Thu, 5 Feb 2026 10:55:12 +0000 (10:55 +0000)] 
src/esx/esx_vi.c: Debug path element comparisons

Libvirt vpx:// and esx:// URIs are quite obscure.  In particular it is
very difficult to construct a correct path to a VMware resource.
Basically you are iterating over VMware structures blindly with no way
to know what your choices are at each level in the path.

This commit doesn't directly address this.  It's still difficult.  But
at least let's add the true path choices to the debug output so
someone could in theory use 'LIBVIRT_DEBUG=1' to find out what
possible choices exist at a path level.

For example this command fails because the label (which looks like an
IPv6 address, but is really a label) should use "::" instead of ":0:":

  LIBVIRT_DEBUG=1 virsh -c 'vpx://root@.../data/aaaa:52:0:49e0:2eea:7fff:fee6:eca0/?no_verify=1'

In the debugging output we now print:

  2026-02-05 10:58:25.421+0000: 1528876: debug : esxVI_LookupManagedObjectHelper:4956 : comparing path element 'aaaa:52:0:49e0:2eea:7fff:fee6:eca0' with candidate name 'aaaa:52::49e0:2eea:7fff:fee6:eca0'
  2026-02-05 10:58:25.421+0000: 1528876: error : esxVI_Context_LookupManagedObjectsByPath:1098 : internal error: Could not find compute resource specified in '/data/aaaa:52:0:49e0:2eea:7fff:fee6:eca0/'

In an ideal world we should improve the error message to show the
possible choices, but the way the code is structured makes that
prohibitive.

Related: https://issues.redhat.com/browse/RHEL-145080
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
13 days agobhyvexml2xmltest: Avoid leaking driver caps
Michal Privoznik [Tue, 3 Feb 2026 13:00:59 +0000 (14:00 +0100)] 
bhyvexml2xmltest: Avoid leaking driver caps

Driver capabilities are allocated at the beginning of mymain(),
but roughly in the middle the architecture is switched to aarch64
and capabilities are constructed again. Without freeing the old
ones.

704 (288 direct, 416 indirect) bytes in 1 blocks are definitely lost in loss record 328 of 332
   at 0x4885098: calloc (vg_replace_malloc.c:1682)
   by 0x4EE35CA: g_malloc0 (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x53314B8: g_type_create_instance (in /usr/local/lib/libgobject-2.0.so.0.8400.4)
   by 0x531A263: ??? (in /usr/local/lib/libgobject-2.0.so.0.8400.4)
   by 0x531975E: g_object_new (in /usr/local/lib/libgobject-2.0.so.0.8400.4)
   by 0x4AA9AB6: virObjectNew (virobject.c:252)
   by 0x4AF0BBA: virCapabilitiesNew (capabilities.c:87)
   by 0x401797B: virBhyveCapsBuild (bhyve_capabilities.c:51)
   by 0x4012F57: mymain (bhyvexml2xmltest.c:60)
   by 0x4016872: virTestMain (testutils.c:913)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
13 days agobhyvexml2argvtest: Avoid leaking firmwareDir
Michal Privoznik [Tue, 3 Feb 2026 11:10:00 +0000 (12:10 +0100)] 
bhyvexml2argvtest: Avoid leaking firmwareDir

The firmwareDir member of driver config is set at the beginning
of mymain(). But then, roughly in the middle of test cases it is
overwritten to fakefirmwareemptydir. But this means the old value
must be freed. Or reassigned back to its original variable which
is freed automatically.

16 bytes in 1 blocks are definitely lost in loss record 190 of 505
   at 0x4883224: malloc (vg_replace_malloc.c:451)
   by 0x4EE6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4F0100F: g_strdup (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4013E26: g_strdup_inline (gstrfuncs.h:321)
   by 0x4013E26: mymain (bhyvexml2argvtest.c:151)
   by 0x40189A2: virTestMain (testutils.c:913)
   by 0x4013DE6: main (bhyvexml2argvtest.c:354)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
13 days agobhyvexml2argvtest: Don't leak parts of driver config
Michal Privoznik [Tue, 3 Feb 2026 11:01:59 +0000 (12:01 +0100)] 
bhyvexml2argvtest: Don't leak parts of driver config

At the beginning of mymain() the virBhyveDriverConfigNew() is
called which inits driver config with some paths. These are
then overwritten to produce stable test output. Well, the old
ones should be freed first.

128 bytes in 1 blocks are definitely lost in loss record 453 of 508
   at 0x4883224: malloc (vg_replace_malloc.c:451)
   by 0x506BD16: vasprintf_l (in /lib/libc.so.7)
   by 0x4F39073: g_vasprintf (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4F01288: g_strdup_printf (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x401F75B: virBhyveDriverConfigNew (bhyve_conf.c:62)
   by 0x4013FAA: mymain (bhyvexml2argvtest.c:164)
   by 0x4018892: virTestMain (testutils.c:913)
   by 0x4013DC6: main (bhyvexml2argvtest.c:352)

25 bytes in 1 blocks are definitely lost in loss record 206 of 508
   at 0x4883224: malloc (vg_replace_malloc.c:451)
   by 0x4EE6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4F0100F: g_strdup (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x401F715: g_strdup_inline (gstrfuncs.h:321)
   by 0x401F715: virBhyveDriverConfigNew (bhyve_conf.c:60)
   by 0x4013FAA: mymain (bhyvexml2argvtest.c:164)
   by 0x4018892: virTestMain (testutils.c:913)
   by 0x4013DC6: main (bhyvexml2argvtest.c:352)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>