]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
3 months agoqemu_firmware: Split sanity check
Andrea Bolognani [Mon, 24 Nov 2025 13:36:55 +0000 (14:36 +0100)] 
qemu_firmware: Split sanity check

The two checks are semantically different, so it makes sense to
perform them separately. We will soon extend the first one.

While at it, start printing out the value of isConfidential. We
could print the value of each firmware feature it's derived from,
but that would make things unnecessarily verbose; at the same
time, knowing that libvirt believes that the firmware build is
targeting the confidential use case can be useful for debugging
so it's worth including it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoqemu_firmware: Parse host-uefi-vars firmware feature
Andrea Bolognani [Mon, 24 Nov 2025 13:14:36 +0000 (14:14 +0100)] 
qemu_firmware: Parse host-uefi-vars firmware feature

When present in a firmware descriptor, this feature indicates that
the corresponding executable expects to access variable storage
through the uefi-vars QEMU device.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agotests: Add firmware-auto-efi-enrolled-keys-aarch64
Andrea Bolognani [Tue, 9 Dec 2025 23:02:52 +0000 (00:02 +0100)] 
tests: Add firmware-auto-efi-enrolled-keys-aarch64

This test case demonstrates how to automatically configure an
aarch64 guest so that Secure Boot support is available and only
signed operating systems are allowed to boot.

It currently fails because there is no firmware descriptor that
describes a suitable firmware build yet. That will change in a
future commit.

In addition to the latest version, the test case is also executed
against QEMU 8.2.0 specifically. This version of the test case is
intended to fail, because the uefi-vars device that we need to
support Secure Boot on aarch64 was not yet available in that
version of QEMU. The exact error message will change down the
line.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agotests: Add firmware-auto-efi-varstore-aarch64
Andrea Bolognani [Thu, 22 Jan 2026 13:45:28 +0000 (14:45 +0100)] 
tests: Add firmware-auto-efi-varstore-aarch64

This test case demonstrates how to explicitly opt into using
the uefi-vars device for an aarch64 guest.

Normally the firmware autoselection process will pick a UEFI
build that is loaded via pflash, but by including the <varstore>
element in the input XML we can tell the QEMU driver that we
want want the uefi-vars device to be used instead.

Currently this results in an error, because the firmware
autoselection algorithm doesn't yet know how to properly handle
the scenario. A future commit will address this and make things
work as expected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agotests: Add firmware-auto-efi-varstore-q35
Andrea Bolognani [Thu, 22 Jan 2026 13:42:34 +0000 (14:42 +0100)] 
tests: Add firmware-auto-efi-varstore-q35

This test case demonstrates how to explicitly opt into using
the uefi-vars device for an x86_64 guest.

Normally the firmware autoselection process will pick a UEFI
build that is loaded via pflash, but by including the <varstore>
element in the input XML we can tell the QEMU driver that we
want want the uefi-vars device to be used instead.

Currently this results in an error, because the firmware
autoselection algorithm doesn't yet know how to properly handle
the scenario. A future commit will address this and make things
work as expected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agotests: Add firmware-manual-efi-varstore-aarch64
Andrea Bolognani [Tue, 18 Nov 2025 13:46:12 +0000 (14:46 +0100)] 
tests: Add firmware-manual-efi-varstore-aarch64

This test case demonstrates how to manually configure an aarch64
guest to use the uefi-vars device.

It currently fails because the QEMU driver does not yet recognize
the firmware type as EFI, and so rejects the attempt to use ACPI
together with it. That will change in a future commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agotests: Add firmware-manual-efi-varstore-q35
Andrea Bolognani [Fri, 7 Nov 2025 15:41:37 +0000 (16:41 +0100)] 
tests: Add firmware-manual-efi-varstore-q35

This test case demonstrates how to manually configure an x86_64
guest to use the uefi-vars device.

It fails when using an older version of QEMU which didn't have
the device, and succeeds when using the latest version. The
relevant bits of the QEMU command line are not generated yet,
but that will come in a later commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoqemu: Validate presence of uefi-vars device
Andrea Bolognani [Fri, 21 Nov 2025 18:32:31 +0000 (19:32 +0100)] 
qemu: Validate presence of uefi-vars device

The use of varstore requires the uefi-vars device to be present
in the QEMU binary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoqemu_capabilities: Introduce QEMU_CAPS_DEVICE_UEFI_VARS
Andrea Bolognani [Fri, 21 Nov 2025 14:34:32 +0000 (15:34 +0100)] 
qemu_capabilities: Introduce QEMU_CAPS_DEVICE_UEFI_VARS

This capability indicates the availability of the uefi-vars
device.

The actual name of the QEMU device varies slightly depending on
the architecture: it's uefi-vars-x64 on x86_64, uefi-vars-sysbus
on other UEFI architectures (aarch64, riscv64, loongarch64).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoconf: Update validation to consider varstore element
Andrea Bolognani [Thu, 22 Jan 2026 18:27:03 +0000 (19:27 +0100)] 
conf: Update validation to consider varstore element

The code is reworked quite significantly, but most of the
existing checks are preserved. Those that aren't, notably the
one that allowed pflash as the only acceptable non-stateless
firmware type, are intentionally removed because they will no
longer reflect reality once support for the uefi-vars QEMU
device is introduced.

As a side effect, reworking the function in this fashion
resolves a subtle bug: due to the early exits that were being
performed when the loader element was missing, the checks at
the bottom of the function (related to the shim and kernel
elements) were effectively never performed. This is no longer
the case.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoconf: Parse and format varstore element
Andrea Bolognani [Mon, 19 Jan 2026 13:20:06 +0000 (14:20 +0100)] 
conf: Parse and format varstore element

This will be used to configure the backing storage used by the
uefi-vars QEMU device.

Dealing with the element itself is trivial, however we have to
refactor the existing code which deals with the loader and nvram
elements slightly: in particular, we can no longer perform an
early exit if those elements are absent.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoschema: Introduce osnvram define
Andrea Bolognani [Mon, 23 Feb 2026 12:57:32 +0000 (13:57 +0100)] 
schema: Introduce osnvram define

This moves the definition of the <nvram> element out of the
fairly complex oshvm define and will make it easier to later
add the <varstore> element without making things unmanageable.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agotests: Rename custom JSON firmware descriptors
Andrea Bolognani [Fri, 23 Jan 2026 13:34:05 +0000 (14:34 +0100)] 
tests: Rename custom JSON firmware descriptors

Most of the JSON firmware descriptors in our test suite come from
the Fedora package for edk2, but there are a few additional ones
that we have created ourselves to ensure coverage of uncommon or
problematic scenarios.

In order to make sure that such descriptors are clearly marked as
custom, rename them to include the string "libvirt" in the path.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoconf: Move type=rom default for loader to drivers
Andrea Bolognani [Tue, 3 Feb 2026 14:18:39 +0000 (15:18 +0100)] 
conf: Move type=rom default for loader to drivers

Right now we set this default in the common parsing code, which
is not a big problem per se but would get in the way of some
upcoming changes.

Leave this choice to individual drivers instead. Only the QEMU
and Xen drivers use the value for anything, so we can limit the
amount of code duplication this change causes.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agoqemu_firmware: Only set format for custom loader if path is present
Andrea Bolognani [Tue, 3 Feb 2026 15:05:05 +0000 (16:05 +0100)] 
qemu_firmware: Only set format for custom loader if path is present

We only set the template format if the template path is present,
and we should be consistent with that. The format on its own is
not very interesting anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agodocs: Improvement related to firmware selection
Andrea Bolognani [Mon, 23 Feb 2026 13:58:15 +0000 (14:58 +0100)] 
docs: Improvement related to firmware selection

Recommend that users take advantage of firmware autoselection
and discourage providing paths manually.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agodocs: Rename "BIOS bootloader" section to "guest firmware"
Andrea Bolognani [Mon, 23 Feb 2026 13:55:20 +0000 (14:55 +0100)] 
docs: Rename "BIOS bootloader" section to "guest firmware"

The new name is much more accurate since the documentation is
applicable to firmware other than BIOS, notably UEFI.

An empty container is used to keep old links working.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 months agohyperv: Add basic domainGetBlockInfo() API implementation
Jonathon Jongsma [Thu, 5 Feb 2026 21:35:08 +0000 (15:35 -0600)] 
hyperv: Add basic domainGetBlockInfo() API implementation

This adds initial support for virDomainGetBlockInfo() for the hyperv
driver. It currently supports:
 - physical disk drives that are assigned to a vm
 - virtual disk drives backed by a .VHD file that are local to the host
 - other drives backed by local files (e.g. cdrom with a .iso)

It will fail to get allocation and physical values for any drives backed
by files that are not local to the host (e.g. on network shares)

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agohyperv: Add resource subtype definitions
Jonathon Jongsma [Fri, 13 Feb 2026 22:04:22 +0000 (16:04 -0600)] 
hyperv: Add resource subtype definitions

Rather than using raw strings, create definitions for each subtype
string so that they can be re-used without needing to know the exact
string format.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoconf: support windows paths in virDomainDiskByName()
Jonathon Jongsma [Fri, 6 Feb 2026 22:08:37 +0000 (16:08 -0600)] 
conf: support windows paths in virDomainDiskByName()

With the hyperv driver, disks might have windows paths like
"c:\path\to\disk.vhdx". Currently, this function supports paths, but
only if they're in unix format.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agohyperv: add support for secure boot configuration
Jonathon Jongsma [Thu, 12 Feb 2026 17:25:39 +0000 (11:25 -0600)] 
hyperv: add support for secure boot configuration

When getting the xml description of a guest, check if secure boot is
enabled and set firmware features accordingly.

Also support firmware autoselection and honor the secure boot setting
when defining new vms from xml.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agohyperv: Clean up unnecessary header includes
Jonathon Jongsma [Tue, 17 Feb 2026 15:16:03 +0000 (09:16 -0600)] 
hyperv: Clean up unnecessary header includes

Remove some unused or over-broad includes from headers, push some
includes down to .c files when the only user is the implementation.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemu: saveimage: Use 'virFileWrapperFd' when loading non-sparse saveimage
Peter Krempa [Tue, 17 Feb 2026 13:38:37 +0000 (14:38 +0100)] 
qemu: saveimage: Use 'virFileWrapperFd' when loading non-sparse saveimage

Always instantiate a 'virFileWrapperFd' (iohelper) to wrap the saveimage
file descriptor of a non-'sparse' format saveimage.

For 'sparse' images we also need to ensure that the FD returned when
opening the save image is an actual file FD (thus not the FD from the
helper process used to bypass root-squashed NFS) as qemu requires an
actual file in those cases.

This patch reworks 'qemuSaveImageOpen' to create the wrapper process
based on whether the 'wrapperFd' variable is non-NULL rather than
based on a combination of 'sparse' and 'bypass_cache' flags. The caller
will then based on the image format and the need for the wrapper use the
appropriate settings.

As with this patch all non-sparse images will always pass a pipe instead
of a file to qemu it also fixes problems with qemu-11.0 where the 'fd'
migration protocol rejects FDs which point to a file.

Resolves: https://issues.redhat.com/browse/RHEL-76301
Closes: https://gitlab.com/libvirt/libvirt/-/issues/850
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemu: driver: Merge 'qemuDomainRestoreInternal' and 'qemuDomainObjRestore'
Peter Krempa [Tue, 17 Feb 2026 12:22:44 +0000 (13:22 +0100)] 
qemu: driver: Merge 'qemuDomainRestoreInternal' and 'qemuDomainObjRestore'

The two functions are for reverting a save image. They differ only on
what domain object is used (new one vs existing one). Merge the code
paths for existing VMs (for managed save restore) into
'qemuDomainRestoreInternal' and reuse it instead of
'qemuDomainObjRestore'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemuSaveImageCreateFd: Handle case when 'virQEMUFileOpenAs' doesn't return a file...
Peter Krempa [Wed, 11 Feb 2026 16:31:56 +0000 (17:31 +0100)] 
qemuSaveImageCreateFd: Handle case when 'virQEMUFileOpenAs' doesn't return a file fd for 'sparse' format

The 'sparse' uses a mode in qemu which requires direct access to the
file descriptior of the file itself. If we reside on root-squashed NFS
the FD from 'virQEMUFileOpenAs' may not actually be a file which would
not work with qemu.

Reject such a config with a better error message and add documentation
outlining the quirk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agovirfile: Introduce 'virFileFDIsRegular'
Peter Krempa [Wed, 11 Feb 2026 15:48:40 +0000 (16:48 +0100)] 
virfile: Introduce 'virFileFDIsRegular'

Similarly to 'virFileIsRegular' return if the FD is a regular file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemuMonitorMigrateToFdSet: Drop 'flags' argument
Peter Krempa [Wed, 11 Feb 2026 16:20:29 +0000 (17:20 +0100)] 
qemuMonitorMigrateToFdSet: Drop 'flags' argument

The only caller doesn't use it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemuSaveImageOpen: Remove wrong ATTRIBUTE_NONNULL
Peter Krempa [Tue, 17 Feb 2026 13:45:41 +0000 (14:45 +0100)] 
qemuSaveImageOpen: Remove wrong ATTRIBUTE_NONNULL

After commit 517248e2394 removed the previously-4th argument the
ATTRIBUTE_NONNULL(4) annotation no longer makes sense.

Fixes: 517248e2394476a3105ff5866b0b718fc6583073
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agovirpci: Report an error if virPCIGetVirtualFunctionIndex() fails
Michal Privoznik [Wed, 2 Jul 2025 11:51:58 +0000 (13:51 +0200)] 
virpci: Report an error if virPCIGetVirtualFunctionIndex() fails

Either an error should be returned in all error paths in a
function or in none (leaving it up to caller). Well,
virPCIGetVirtualFunctionIndex() breaks this pattern. Fix it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 months agobhyve: implement domainGetVcpuPinInfo
Roman Bogorodskiy [Thu, 5 Feb 2026 17:46:32 +0000 (18:46 +0100)] 
bhyve: implement domainGetVcpuPinInfo

Implement domainGetVcpuPinInfo for querying vcpu pinning information.
Also, implement a couple of other APIs this one depends on:
domainGetVcpusFlags and domainGetMaxVcpus.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agobhyve: support vcpu pinning
Roman Bogorodskiy [Wed, 4 Feb 2026 18:39:43 +0000 (19:39 +0100)] 
bhyve: support vcpu pinning

Bhyve supports vcpu pinning using the `-p vcpu:hostcpu`
argument. This argument can be specified multiple times for the same
vcpu to pin it to multiple hostcpu's.

Bhyve currently does not allow to change vcpu pinning configuration for
the VM that is already running.

Use this to support domain's vcpupin configuration such as:

  <cputune>
    <vcpupin vcpu="0" cpuset="1,2,3"/>
  </cputune>

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemu: Report error aborting stopped postcopy migration
Jiri Denemark [Thu, 19 Feb 2026 10:27:40 +0000 (11:27 +0100)] 
qemu: Report error aborting stopped postcopy migration

When virDomainAbortJob is called with VIR_DOMAIN_ABORT_JOB_POSTCOPY flag
and the post-copy migration of the domain is already stopped (either
because of a failure or previous call to virDomainAbortJob), the
migrate-pause QMP command fails with "migrate-pause is currently only
supported during postcopy-active or postcopy-recover state". Such error
might be confusing to end users especially when we mark it as an
internal error. Let's not call the QMP command at all and report a
clear error message instead.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agovirstorageobj: Make virStoragePoolObjAddVol() report an error on failure
Michal Privoznik [Mon, 16 Feb 2026 09:42:07 +0000 (10:42 +0100)] 
virstorageobj: Make virStoragePoolObjAddVol() report an error on failure

Adding a storage volume into a pool is done by calling
virStoragePoolObjAddVol(). This function may fail if another
volume already exists with the same key/name/target. In some
cases the storage driver does check for duplicates before calling
the function. But in some cases (e.g. when refreshing an RBD pool
in virStorageBackendRBDRefreshPool()) it doesn't.

The problem here is that the function reports no error upon
failure and leaves it as an exercise for caller. Well, no caller
does that.

Therefore, make the function report an error. The advantage of
this approach is - the function can report more accurate error
message than any caller ever could.

NB¸ this stems from a discussion on the users list [1], and while
this does NOT solve the original issue, it fixes one of the
symptoms.

1: https://lists.libvirt.org/archives/list/users@lists.libvirt.org/message/BALVNCRQM4KBKGV4RQ7BMKSX7UIJKLQH/
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 months agovirsh: report "unknown" for autostart when API query fails
Lucas Amaral [Mon, 16 Feb 2026 15:50:06 +0000 (12:50 -0300)] 
virsh: report "unknown" for autostart when API query fails

When virStoragePoolGetAutostart(), virNetworkGetAutostart(), or
virNodeDeviceGetAutostart() fails, the respective info commands
report "no autostart". This is incorrect: the API failure means
we cannot determine the autostart state, not that autostart is
disabled.

The persistent field in the same functions already correctly
reports "unknown" on API failure. Apply the same pattern to the
autostart field for consistency and correctness.

Signed-off-by: Lucas Amaral <lucaaamaral@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agovirsh: return failure exit code when UUID fetch fails
Lucas Amaral [Mon, 16 Feb 2026 14:48:17 +0000 (11:48 -0300)] 
virsh: return failure exit code when UUID fetch fails

The domuuid, net-uuid, and pool-uuid commands call vshError() when
GetUUIDString() fails, but unconditionally return true, which
vshCommandRun() maps to EXIT_SUCCESS. This means scripts checking
$? see success despite the error.

Return false on failure so the exit code correctly reflects the
error, consistent with other virsh commands.

Signed-off-by: Lucas Amaral <lucaaamaral@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agonews: Mention firmwareFeatures element for domaincaps
Andrea Bolognani [Tue, 10 Feb 2026 23:51:35 +0000 (00:51 +0100)] 
news: Mention firmwareFeatures element for domaincaps

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agodocs: Document firmwareFeature element for domaincaps
Andrea Bolognani [Tue, 10 Feb 2026 23:48:18 +0000 (00:48 +0100)] 
docs: Document firmwareFeature element for domaincaps

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoqemu: Fill in firmwareFeature element for domaincaps
Andrea Bolognani [Mon, 9 Feb 2026 20:37:23 +0000 (21:37 +0100)] 
qemu: Fill in firmwareFeature element for domaincaps

On architectures that support neither UEFI nor BIOS as firmware,
such as ppc64 and s390x, the enums end up empty. This correctly
indicates that filtering by firmware feature is not possible, and
is consistent with the fact that the existing "firmware" enum is
also empty in those cases, meaning that firmware autoselection
itself is just not applicable.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoconf: Add firmwareFeatures element for domaincaps
Andrea Bolognani [Mon, 9 Feb 2026 20:28:50 +0000 (21:28 +0100)] 
conf: Add firmwareFeatures element for domaincaps

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoschema: Add firmwareFeatures element for domaincaps
Andrea Bolognani [Mon, 9 Feb 2026 18:18:32 +0000 (19:18 +0100)] 
schema: Add firmwareFeatures element for domaincaps

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agotests: fix mocking on macOS
Pavel Hrdina [Tue, 17 Feb 2026 09:15:13 +0000 (10:15 +0100)] 
tests: fix mocking on macOS

On macOS we use flat namespace so we cannot have multiple mocks for the
same function.

Fixes: 63434db800b921e96fec424a667b7161af1f02de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 months agoiommufd: fix FD leak in case of error
Pavel Hrdina [Tue, 17 Feb 2026 07:38:07 +0000 (08:38 +0100)] 
iommufd: fix FD leak in case of error

Reported-by: coverity
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 months agotests: properly mock VFIO and IOMMU checks
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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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>