]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
3 weeks agoqemuhotplugtest: Use fake drivers
Michal Privoznik [Wed, 11 Mar 2026 13:33:46 +0000 (14:33 +0100)] 
qemuhotplugtest: Use fake drivers

Hotplugging a device may require talking to other drivers (e.g.
network), similar to when starting a domain anew
(qemuxmlconftest). Register fake drivers for future benefit of
the test.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 weeks agovirnetworkportxml2xmldata: Use different PCI address in plug-hostdev-pci.xml
Michal Privoznik [Wed, 11 Mar 2026 13:33:57 +0000 (14:33 +0100)] 
virnetworkportxml2xmldata: Use different PCI address in plug-hostdev-pci.xml

Inside of plug-hostdev-pci.xml there's a PCI address of an
allocated PCI device for an <interface type='network'/>.
Currently, there's some made up address. But this specific file
is going to be used from qemuhotplugtest soon and as such it
needs an PCI address that virpcimock creates. Switch it to
0000:06:12.2.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 weeks agoqemuxmlconftest: Separate fake drivers into a separate file
Michal Privoznik [Tue, 10 Mar 2026 18:42:12 +0000 (19:42 +0100)] 
qemuxmlconftest: Separate fake drivers into a separate file

One of the tests that qemuxmlconftest does is generate cmd line
for given domain XML. This process might involve talking to other
drivers (secret/storage/nwfilter/network). To produce predictable
output the test comes with fake implementation of APIs of those
drivers. Well, move that implementation into a separate file so
that it can be reused by other tests (notably, qemuhotplugtest is
going to use it).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 weeks agotests: Drop WITH_QEMU from qemu specific tests binaries/libraries
Michal Privoznik [Tue, 10 Mar 2026 16:05:12 +0000 (17:05 +0100)] 
tests: Drop WITH_QEMU from qemu specific tests binaries/libraries

Inside of tests/meson.build there is a section that builds QEMU
related tests conditionally (for instance
qemudomaincheckpointxml2xmltest). It makes no sense to have the
same check inside source file. Or even provide alternative
implementation for cases when building without QEMU
(EXIT_AM_SKIP). When building without QEMU driver the test is not
even compiled, so EXIT_AM_SKIP is dead code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 weeks agonetworkxmlconftest: s/fail/cleanup/
Michal Privoznik [Thu, 29 Jan 2026 14:10:06 +0000 (15:10 +0100)] 
networkxmlconftest: s/fail/cleanup/

Inside of testCompareXMLtoXMLFiles() the 'fail' label is used in
both successful and error runs. If that's the case, our coding
standard mandates the label to be named 'cleanup'. Change it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 weeks agonetwork: Format <ip/> element using virXMLFormatElement()
Michal Privoznik [Thu, 29 Jan 2026 14:09:37 +0000 (15:09 +0100)] 
network: Format <ip/> element using virXMLFormatElement()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 weeks agosrc: Drop NULL check before calling virBufferEscapeString()
Michal Privoznik [Fri, 30 Jan 2026 14:47:19 +0000 (15:47 +0100)] 
src: Drop NULL check before calling virBufferEscapeString()

There's no need to check if any of the three arguments passed to
virBufferEscapeString() is NULL as the function does so itself.
Well, in a few places we're comparing the last argument against
NULL. Drop the comparison then.

Generated using the following spatch:

  @@
  expression X, Y, E;
  @@
  - if (E) virBufferEscapeString(X, Y, E);
  + virBufferEscapeString(X, Y, E);

  @@
  expression X, Y, E;
  @@
  - if (E) {
    virBufferEscapeString(X, Y, E);
  - }

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 weeks agohyperv: Implement virDomainSnapshotGetParent()
Jonathon Jongsma [Thu, 5 Mar 2026 21:41:50 +0000 (15:41 -0600)] 
hyperv: Implement virDomainSnapshotGetParent()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agohyperv: Implement virDomainSnapshotCurrent()/virDomainHasCurrentSnapshot()
Jonathon Jongsma [Thu, 5 Mar 2026 15:43:48 +0000 (09:43 -0600)] 
hyperv: Implement virDomainSnapshotCurrent()/virDomainHasCurrentSnapshot()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agohyperv: implement virDomainSnapshotGetXMLDesc()
Jonathon Jongsma [Wed, 11 Feb 2026 16:10:02 +0000 (10:10 -0600)] 
hyperv: implement virDomainSnapshotGetXMLDesc()

This function is required for `virsh snapshot-list` to work.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agohyperv: implement virDomainListAllSnapshots()/virDomainSnapshotNum()
Jonathon Jongsma [Wed, 11 Feb 2026 15:22:56 +0000 (09:22 -0600)] 
hyperv: implement virDomainListAllSnapshots()/virDomainSnapshotNum()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agohyperv: Implement domainSnapshotLookupByName()
Jonathon Jongsma [Wed, 11 Feb 2026 22:25:51 +0000 (16:25 -0600)] 
hyperv: Implement domainSnapshotLookupByName()

Unfortunately Hyper-V does not enforce any uniqueness constraints on
snapshot names (called ElementName in Hyper-V). So it's possible for
multiple snapshots of the same domain to have identical ElementNames.
Since libvirt uses the domain and snapshot name as a unique key to
reference a snapshot, we can't use the hyperv ElementName as the
snapshot name in libvirt.

So instead I've decided to use the InstanceId of the snapshot as the
snapshot name and use the ElementName as the snapshot description. This
results in a worse user experience (since the snapshot names end up
being something like "Microsoft:$(UUID)"), but guarantees that we will
be able to uniquely reference every snapshot.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agoviriommufd: Set IOMMU_OPTION_RLIMIT_MODE only when running privileged
Pavel Hrdina [Fri, 13 Mar 2026 09:50:36 +0000 (10:50 +0100)] 
viriommufd: Set IOMMU_OPTION_RLIMIT_MODE only when running privileged

If libvirt daemon is running unprivileged it will fail so we should not
even try to set it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 weeks agoqemu: Enable AMD IOMMU XTSUP by default
Xiaotian Feng [Wed, 25 Feb 2026 07:48:21 +0000 (07:48 +0000)] 
qemu: Enable AMD IOMMU XTSUP by default

Add QEMU_CAPS_AMD_IOMMU_XTSUP capability and enable xtsup
by default for AMD IOMMU when a Q35 domain has >255 vCPUs,
similar to Intel EIM auto-enable logic. Also ensure intremap is
turned on when required.

Signed-off-by: Xiaotian Feng <xiaotian.feng@amd.com>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Tested-by: Ankit Soni <Ankit.Soni@amd.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agoconf: support >255 vcpu w/ amd-iommu xtsup
Xiaotian Feng [Wed, 25 Feb 2026 07:48:20 +0000 (07:48 +0000)] 
conf: support >255 vcpu w/ amd-iommu xtsup

Rename QEMU_MAX_VCPUS_WITHOUT_EIM to QEMU_MAX_VCPUS_WITHOUT_X2APIC to
clarify the limit is tied to APIC ID width.

Validation now accepts either:
  - intel-iommu with eim='on', or
  - amd-iommu with xtsup='on'
for guests with more than 255 vCPUs on x86/q35.

Update error messages to mention x2APIC mode instead of extended
interrupt mode. This reflects that AMD platforms can satisfy the same
requirement via xtsup property on amd-iommu.

Signed-off-by: Xiaotian Feng <xiaotian.feng@amd.com>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Tested-by: Ankit Soni <Ankit.Soni@amd.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agoconf: fix error log for passthrough and xtsup attributes
Xiaotian Feng [Wed, 25 Feb 2026 07:48:19 +0000 (07:48 +0000)] 
conf: fix error log for passthrough and xtsup attributes

Correct error messages for passthrough (pt) and xtsup attributes to
reflect their actual names instead of "dma translation".

Signed-off-by: Xiaotian Feng <xiaotian.feng@amd.com>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Tested-by: Ankit Soni <Ankit.Soni@amd.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 weeks agoconf: fix virDomainIOMMUDefEquals for amd_iommu
Xiaotian Feng [Wed, 25 Feb 2026 07:48:18 +0000 (07:48 +0000)] 
conf: fix virDomainIOMMUDefEquals for amd_iommu

iommu->pt and iommu->xtsup are missing in virDomainIOMMUDefEquals.

Signed-off-by: Xiaotian Feng <Xiaotian.Feng@amd.com>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Tested-by: Ankit Soni <Ankit.Soni@amd.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoutil: implement virHostCPUGetOnlineBitmap() for FreeBSD
Roman Bogorodskiy [Tue, 10 Mar 2026 19:05:39 +0000 (20:05 +0100)] 
util: implement virHostCPUGetOnlineBitmap() for FreeBSD

Implement virHostCPUGetOnlineBitmap() for FreeBSD. As FreeBSD
supports neither plugging nor taking CPUs offline,
all CPUs are always online.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agorpc: free saved close error in virNetClientDispose
Leander Kohler [Fri, 27 Feb 2026 12:39:19 +0000 (13:39 +0100)] 
rpc: free saved close error in virNetClientDispose

virNetClientMarkClose() may cache the current error in client->error via
virSaveLastError() when a client is marked for close.

That error is normally released in virNetClientCloseLocked(), but some
teardown paths can dispose the client object without reaching that
cleanup. In that case, client->error remains allocated and ASan reports
a leak.

Free client->error in virNetClientDispose() as a final cleanup fallback.

This was observed during virtchd shutdown in test_disk_is_locked, with
the leak originating from:
virDomainInterfaceDeleteDevice() -> remoteConnectClose() ->
virNetClientMarkClose() -> virSaveLastError()

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agotests: Create fake root dirs later
Michal Privoznik [Wed, 11 Mar 2026 11:21:17 +0000 (12:21 +0100)] 
tests: Create fake root dirs later

In one of previous commits the virTestMain() function was changed
to actually create fake HOME, XDG_RUNTIME_DIR, ... directories
instead of setting spoofed values in the environment. But
alongside with this, the call to virTestFakeRootDirInit() was
moved (to location where environment was poisoned). And this
would not matter if it wasn't for mocking. Because what we ended
up with is virTestFakeRootDirInit() is called and then
(optionally) the process re-execs itself (with mocks loaded).
This means that previously created root dirs are never cleaned
up and just pollute builddir.

Therefore, restore original location from which the function was
called.

Fixes: 79d97d2b4f0b55ea80f8330144953e2b93927e25
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 weeks agodocs: Clarify host-model description in domain capabilities
Jiri Denemark [Wed, 11 Mar 2026 11:13:45 +0000 (12:13 +0100)] 
docs: Clarify host-model description in domain capabilities

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 weeks agovirsh: Add --expand-cpu-features option for domcapabilities
Jiri Denemark [Wed, 11 Mar 2026 11:13:22 +0000 (12:13 +0100)] 
virsh: Add --expand-cpu-features option for domcapabilities

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 weeks agoqemu: Implement VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES
Jiri Denemark [Wed, 11 Mar 2026 11:12:40 +0000 (12:12 +0100)] 
qemu: Implement VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 weeks agoIntroduce EXPAND_CPU_FEATURES flag for domain capabilities
Jiri Denemark [Wed, 11 Mar 2026 10:31:06 +0000 (11:31 +0100)] 
Introduce EXPAND_CPU_FEATURES flag for domain capabilities

The new VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES flag for
virConnectGetDomainCapabilities can be used to request the host-model
CPU definition to include all supported features (normally only extra
features relative to the selected CPU model are listed).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 weeks agodocs: storage: Note that refreshing the storage pool is needed on outside modification
Peter Krempa [Mon, 9 Mar 2026 16:30:24 +0000 (17:30 +0100)] 
docs: storage: Note that refreshing the storage pool is needed on outside modification

Add a note stating that pool contents and metadata are not auto-updated
when the pool is modified outside of libvirt.

Closes: https://gitlab.com/libvirt/libvirt/-/work_items/749
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 weeks agoutil: Move 'virProcessLimitResourceToLabel' into same preprocessor if-block as only...
Peter Krempa [Mon, 9 Mar 2026 16:38:28 +0000 (17:38 +0100)] 
util: Move 'virProcessLimitResourceToLabel' into same preprocessor if-block as only caller

'virProcessLimitResourceToLabel' is called only from
'virProcessGetLimitFromProc' but the latter has different conditions
when it's compiled. In certain cases this could lead to build failures.

Fixes: 90fe839f8a0
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/848
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
4 weeks agoqemu: monitor: Use 'flat' mode of 'query-block'
Peter Krempa [Thu, 11 Dec 2025 10:13:08 +0000 (11:13 +0100)] 
qemu: monitor: Use 'flat' mode of 'query-block'

We don't actually look at any of the information in 'backing-image'
field so we can ask qemu not to send it to us.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu: capabilities: Introduce QEMU_CAPS_QUERY_BLOCK_FLAT
Peter Krempa [Thu, 11 Dec 2025 10:11:54 +0000 (11:11 +0100)] 
qemu: capabilities: Introduce QEMU_CAPS_QUERY_BLOCK_FLAT

The 'flat' mode of 'query-block' allows ommiting information we don't
actually read. Add a capability which will allow us to request the new
mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemucapabilitiestest: Update 'caps_11.0.0_aarch64' to 'v10.2.0-2062-g084a6c6e73"aarch
Peter Krempa [Mon, 9 Mar 2026 15:08:44 +0000 (16:08 +0100)] 
qemucapabilitiestest: Update 'caps_11.0.0_aarch64' to 'v10.2.0-2062-g084a6c6e73"aarch

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemucapabilitiestest: Update 'caps_11.0.0_x86_64' to 'v10.2.0-2062-g084a6c6e73"
Peter Krempa [Thu, 26 Feb 2026 13:59:22 +0000 (14:59 +0100)] 
qemucapabilitiestest: Update 'caps_11.0.0_x86_64' to 'v10.2.0-2062-g084a6c6e73"

Notable changes:
 - 'nitro' machine type added
 - 'query-block' supports 'flat' mode
 - all chardev backends gained 'logtimestamp' option
 - new cpu models:
    - ClearwaterForest-v3-x86_64-cpu
    - GraniteRapids-v5-x86_64-cpu
    - SapphireRapids-v6-x86_64-cpu
 - 'vmx-mbec' cpu feature added
 - 'virtio-gpu-virgl-hostmem-region' qom object added
 - devices 'VGA' and 'qxl' lost the 'global-vmstate' option
 - device 'amd-iommu' gained 'pt' option
 - QOM type 'audio-backend' replaced by specific backend-based types:
     'audio-alsa', 'audio-dbus', 'audio-mixeng-backend', 'audio-none',
     'audio-oss', 'audio-pa', 'audio-sdl', 'audio-spice', 'audio-wav'
 - 'tdx-guest' qom object gained 'confidential-guest-reset' feature flag
 - target 'hexagon' added; 'microblazeel' removed
 - events GUEST_CRASHLOADED/GUEST_PANICKED gained info about 'sev'
 - event VFIO_MIGRATION gained 'pre-copy-p2p-prepare' value in
   'device-state' enum
 - 'cxl-inject-*' commands gained many new parameters

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu: processShutdownCompletedEvent: Remove inactive VM object after shutdown
Peter Krempa [Mon, 9 Mar 2026 14:07:39 +0000 (15:07 +0100)] 
qemu: processShutdownCompletedEvent: Remove inactive VM object after shutdown

When the qemu process can't be successfully killed (e.g. when it's stuck
in a long system call) libvirt creates a watch and waits for the monitor
socket to go away before cleaning up the domain.

The cleanup code in 'processShutdownCompletedEvent' called
'qemuProcessStop' but didn't call also 'qemuDomainRemoveInactive' which
would break if a transient VM would undergo the delayed cleanup as we'd
still have it's VM object around.

Fixes: e62c26a20dced58ea342d9cb8f5e9164dc3bb023
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/853
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu: hotplug: Don't access disk definititon after it was freed after media change
Peter Krempa [Thu, 5 Mar 2026 14:39:02 +0000 (15:39 +0100)] 
qemu: hotplug: Don't access disk definititon after it was freed after media change

A special case in qemuDomainAttachDeviceDiskLive causes disk media to be
changed. This code has different semantics than the real hotplug code
where the hotplugged device definition is absorbed into the domain
definition and thus the pointer is still valid. On media change we just
use the disk source and discard everything else from the disk
definition.

Later in qemuDomainAttachDeviceLive we then attempt to extract the alias
of the attached device for emiting an event. Since in case of media
change the main definition was freed this causes an use-after-free on
the disk data pointer.

To address this the media change code will clear the disk definition
pointer from the device wrapper and the caller will extract the device
alias only when the disk definition pointer is non-NULL.

The semantics of the event will not change because the device alias
wouldn't be assigned for the media change code at all.

The use-after-free is observable via valgrind when attempting a media
change via 'virsh attach-device', as otherwise in most cases it doesn't
cause any ill efect as only the pointer to a NULL string is accessed:

==2763495== Invalid read of size 8
==2763495==    at 0xEA4102A: qemuDomainAttachDeviceLive (qemu_hotplug.c:3455)
==2763495==    by 0xEA28ECD: qemuDomainAttachDeviceLiveAndConfig (qemu_driver.c:7408)
==2763495==    by 0xEA28ECD: qemuDomainAttachDeviceFlags (qemu_driver.c:7456)
==2763495==    by 0x4BC5BE6: virDomainAttachDevice (libvirt-domain.c:8951)
==2763495==    by 0x402579D: remoteDispatchDomainAttachDevice (remote_daemon_dispatch_stubs.h:3763)
 [snip]
==2763495==  Address 0x6df57c8 is 360 bytes inside a block of size 608 free'd
==2763495==    at 0x48F7E43: free (vg_replace_malloc.c:990)
==2763495==    by 0x4EC7EC4: g_free (in /usr/lib64/libglib-2.0.so.0.8600.3)
==2763495==    by 0xEA4101E: qemuDomainAttachDeviceDiskLive (qemu_hotplug.c:1150)
==2763495==    by 0xEA4101E: qemuDomainAttachDeviceLive (qemu_hotplug.c:3453)
==2763495==    by 0xEA28ECD: qemuDomainAttachDeviceLiveAndConfig (qemu_driver.c:7408)
==2763495==    by 0xEA28ECD: qemuDomainAttachDeviceFlags (qemu_driver.c:7456)
==2763495==    by 0x4BC5BE6: virDomainAttachDevice (libvirt-domain.c:8951)
 [snip]

Closes: https://gitlab.com/libvirt/libvirt/-/issues/859
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemuDomainAttachDeviceDiskLive: Remove 'disk' variable
Peter Krempa [Thu, 5 Mar 2026 14:10:54 +0000 (15:10 +0100)] 
qemuDomainAttachDeviceDiskLive: Remove 'disk' variable

Remove the extra temporary variable to make the changes in the next
patch more obvious.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu_hotplug: Fix crash when attaching network inteface with hostdev network
Pavel Hrdina [Tue, 10 Mar 2026 08:34:48 +0000 (09:34 +0100)] 
qemu_hotplug: Fix crash when attaching network inteface with hostdev network

The following interface XML will crash libvirt when attached to
running VM:

  <interface type='network'>
    <source network='hostdev_net'/>
  </interface>

Instead of trying to figure out every single place where hostdev is used
as struct directly and allocating empty private data check if iommufd
is configured as that will happen only for <hostdev> device where the
private data are correctly allocated.

This patch is best viewed with `git show -w`.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 weeks agoutil: extend virHostCPUGetInfo() for FreeBSD
Roman Bogorodskiy [Sat, 7 Mar 2026 07:35:37 +0000 (07:35 +0000)] 
util: extend virHostCPUGetInfo() for FreeBSD

Extend virHostCPUGetInfo() to report more data on FreeBSD, such as:

 - NUMA domain count
 - CPU core count
 - CPU threads per core count

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agodocs: bhyve: add arm64 guest example
Roman Bogorodskiy [Sun, 8 Mar 2026 05:38:08 +0000 (06:38 +0100)] 
docs: bhyve: add arm64 guest example

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agodocs: bhyve: fix typo in version number
Roman Bogorodskiy [Sun, 8 Mar 2026 05:04:00 +0000 (06:04 +0100)] 
docs: bhyve: fix typo in version number

In the "virtio-scsi" section: "12:0.0" -> "12.0.0".

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agodocs: bhyve: document NUMA domains configuration
Roman Bogorodskiy [Sun, 8 Mar 2026 05:03:29 +0000 (06:03 +0100)] 
docs: bhyve: document NUMA domains configuration

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agohyperv: report whether guests have TPM enabled
Jonathon Jongsma [Thu, 12 Feb 2026 19:31:23 +0000 (13:31 -0600)] 
hyperv: report whether guests have TPM enabled

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemuhotplugtest: Run "interface-hostdev" test cases only on Linux
Michal Privoznik [Mon, 9 Mar 2026 15:03:06 +0000 (16:03 +0100)] 
qemuhotplugtest: Run "interface-hostdev" test cases only on Linux

In one of my previous commits, I've introduced
"interface-hostdev" attach and detach test cases to
qemuhotplugtest. And they work flawlessly, on Linux. But on
anything else they fail because our virpci.c module is basically
just a bunch of stub functions that do nothing but report an
error, rendering my changes to virpcimock futile.

BTW: this is similar to what I had done in v12.1.0-rc1~199.

Fixes: f9bb819fc4841dbdff801629bf58f9fd6d7d93eb
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 weeks agoqemuhotplugtest: Introduce interface-hostdev test case
Michal Privoznik [Thu, 26 Feb 2026 10:01:54 +0000 (11:01 +0100)] 
qemuhotplugtest: Introduce interface-hostdev test case

While our qemuhotplugtest already does a PCI hotplug and unlpug
("hostdev-pci") there is another way to hotplug a PCI device,
esp. if it's a NIC: <interface type='hostdev'/>. This has been
missing and as shown in v12.1.0-rc1-4-gfe782ed334 can be
potentially dangerous as some different paths are taken.
Introduce a test case for interface-hostdev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 weeks agovirnetdevmock: Mock virNetDevSaveNetConfig() and virNetDevSetNetConfig()
Michal Privoznik [Thu, 26 Feb 2026 15:01:21 +0000 (16:01 +0100)] 
virnetdevmock: Mock virNetDevSaveNetConfig() and virNetDevSetNetConfig()

We really don't want our test suite talking to kernel and setting
various attributes on NICs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 weeks agovirpcimock: Create net/ subdir for devices
Michal Privoznik [Thu, 26 Feb 2026 14:51:59 +0000 (15:51 +0100)] 
virpcimock: Create net/ subdir for devices

A PCI device that is a network interface card also has 'net/'
subdir with interface name it corresponds to. For instance:

  # ls -l /sys/bus/pci/devices/0000\:00\:1f.6/net/
  total 0
  drwxr-xr-x 5 root root 0 Feb 26 16:51 eth0

Allow setting interface name for PCI devices.
Now, in real life the net/$IFNAME/ is a directory, but since our
code opens net/ dir and then just reads dentries creating file
instead of full blown dir is okay.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 weeks agovirpcimock: Create sriov_totalvfs file and virtfnN symlinks
Michal Privoznik [Thu, 26 Feb 2026 15:38:32 +0000 (16:38 +0100)] 
virpcimock: Create sriov_totalvfs file and virtfnN symlinks

In case of an SRIOV device the sysfs struct looks like this:

-r--r--r--. 1 root root 4096 Feb 26 14:40 /sys/bus/pci/devices/0000:82:00.0/sriov_totalvfs
lrwxrwxrwx. 1 root root    0 Feb 25 22:51 /sys/bus/pci/devices/0000:82:00.0/virtfn0 -> ../0000:82:10.0
lrwxrwxrwx. 1 root root    0 Feb 25 22:51 /sys/bus/pci/devices/0000:82:00.0/virtfn1 -> ../0000:82:10.4
lrwxrwxrwx. 1 root root    0 Feb 25 22:51 /sys/bus/pci/devices/0000:82:00.0/virtfn2 -> ../0000:82:11.0
lrwxrwxrwx. 1 root root    0 Feb 25 22:51 /sys/bus/pci/devices/0000:82:00.0/virtfn3 -> ../0000:82:11.4

Of course, there is much more, I've just picked up files that our
code touches during hotplug of an <interface type='hostdev'/>.

The first file 'sriov_totalvfs' contains the maximum number of
VFs supported. Then, for each VF created there's 'virtfnN'
symlink to individual VFs.

Teach our virpcimock to create the file and symlinks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 weeks agotests: stop mocking virGetUserRuntimeDirectory()
Laine Stump [Thu, 11 Dec 2025 05:22:30 +0000 (00:22 -0500)] 
tests: stop mocking virGetUserRuntimeDirectory()

The same functionality has been achieved by setting the
XDG_RUNTIME_DIR environment variable during the setup of the "fake
root" directory in testutils.c

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agotests: point $HOME and $XDG_* into usable fake root directory
Laine Stump [Wed, 10 Dec 2025 17:20:09 +0000 (12:20 -0500)] 
tests: point $HOME and $XDG_* into usable fake root directory

A long time ago we added some lines to "poison" the environment of
test programs (specifically $HOME and $XDG_*) with nonexisting
unusable paths so that any test program attempting to use the normal
settings of those variables (which point into the filesystem of the
system running the test) would fail (rather than silently messing up
the test system).

At some later time, someone wrote tests for hostdev devices that
required that virGetUserRuntimeDirectory() (which normally uses either
$XDG_RUNTIME_DIR or $HOME) return a directory that could actually be
used as a part of the test; this was solved by mocking
virGetUserRuntimeDirectory() to return a path underneath
$LIBVIRT_FAKE_ROOT_DIR (which is created each time a test starts).

Much much later, I wanted to add validation of the directory returned
by virGetUserRuntimeDirectory(), but when this validation was added,
the poisoned values that had been set (back in paragraph one "a long
time ago") caused this validation to fail.

My first attempt to fix this was to make the mocked
virGetUserRuntimeDirectory() more generally available, and turn it on
for all the tests that failed. But then I realized that a better
solution would be to instead "nourish" (rather than "poison" - get
it?) $HOME and $XDG_* with directories created under
$LIBVIRT_FAKE_ROOT_DIR. This way we are actually testing the real
virGetUserRuntimeDirectory() and any future validation, and also make
some other tests cover more actual code in the future.

In this patch the poisoning of the environment is removed, the call to
the function creating the fake root dir is moved up to that location,
and as a part of creating the fake root dir, we also set the
aforementioned environment variables and create the directories
associated with them (since the tests assume that they already exist).

The now-redundant original mock of virGetUserRuntimeDirectory() will
be removed in another patch.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoconsistently use glib g_getenv() instead of libc getenv()
Laine Stump [Mon, 15 Dec 2025 20:56:47 +0000 (15:56 -0500)] 
consistently use glib g_getenv() instead of libc getenv()

We've been using glib g_setenv() since commit
2c3353242337bb50fe5abc9454fd5fc98236d4ef in December 2019 (switching
away from the gnulib version of setenv()). Most (but not all) of the
calls to get environment variables have remained using libc's getenv()
though, even though there is a g_getenv() wrapper in glib to match the
g_setenv() wrapper.

While getenv() doesn't have the thread safety problems of setenv(),
it's still recommended that users of g_setenv() also use g_getenv()
(for consistency, and because the glib functions handle UTF-8 properly
while libc getenv() may or may not depending on the setting of LANG in
the environment).

This patch changes all calls to getenv() to use g_getenv() instead,
with the exceptions of:

1) the call to getenv() in virt-login-shell.c (because
virt-login-shell runs setuid root, and we don't want glib or any other
gigantic library anywhere near a setuid program). In a few cases a
char * needs to be made const, and the return from getenv() needs to
be g_strdup()ed if it must stick around for any amount of time (since
the buffer returned from g_getenv() might be recycled/re-used if there
is another call to g_getenv()/g_setenv()).

2) the call to getenv() in libvirt_nss_log.c because it is compiled
into a loadable module that will be loaded into a process after the
process's normal startup, and so any initialization that might be
required for a glib function to operate properly may not be called.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoutil: make completely separate functions for WIN32 versions of virGetUser*Directory()
Laine Stump [Wed, 10 Dec 2025 05:43:04 +0000 (00:43 -0500)] 
util: make completely separate functions for WIN32 versions of virGetUser*Directory()

This will make it easier to, e.g., add sanity checks to the Linux
versions of these functions without potentially causing regressions on
a platform that isn't widely tested

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoutil: rename virGetUserDirectory(ByUID) to virGetUserHomeDirectory(ByUID)
Laine Stump [Wed, 10 Dec 2025 04:25:36 +0000 (23:25 -0500)] 
util: rename virGetUserDirectory(ByUID) to virGetUserHomeDirectory(ByUID)

All the other wrapper functions for glib g_get_user_*_dir() have the
type of directory (the "*" in that wildcarded name) in the libvirt
function name. These functions, on the other hand, call
g_get_home_dir(), but the libvirt API is called
virGetUserDirectory*(). Let's make it *a bit* closer to consistent (at
least the libvirt API names will be consistent with each other, even
if glib isn't).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoremote: reduce scope of userdir in remoteGetUNIXSocketHelper()
Laine Stump [Fri, 14 Nov 2025 05:20:49 +0000 (00:20 -0500)] 
remote: reduce scope of userdir in remoteGetUNIXSocketHelper()

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoutil: reduce scope of rundir in virPidFileConstructPath()
Laine Stump [Fri, 14 Nov 2025 05:01:32 +0000 (00:01 -0500)] 
util: reduce scope of rundir in virPidFileConstructPath()

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoutil: reduce scope/autofree-ify rundir in virDaemonUnixSocketPaths()
Laine Stump [Fri, 14 Nov 2025 04:54:41 +0000 (23:54 -0500)] 
util: reduce scope/autofree-ify rundir in virDaemonUnixSocketPaths()

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu: support setting default route for passt interfaces inside the guest
Laine Stump [Thu, 12 Feb 2026 16:23:10 +0000 (11:23 -0500)] 
qemu: support setting default route for passt interfaces inside the guest

libvirt's <interface> element has for a long time supported adding
<route> sub-elements to specify arbitrary routes to be added to the
guest OS networking, but historically this has only worked for LXC
guests. If you tried to add <route> to the interface of a QEMU guest,
it would be rejected.

passt networking doesn't support setting *any arbitrary* route but it
does support setting a default route (using the passt commandline
"--gateway" parameter). A default route is really just a "route with
unspecified destination/prefix", so a default route can be specified
in libvirt XML with:

   <route gateway='192.168.0.1'/>

Attempts to give a specified destination, prefix, or metric will
result in a validation error.

Resolves: https://issues.redhat.com/browse/RHEL-46602
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 weeks agoconf/util: fix non-specification of IP route destination address
Laine Stump [Tue, 24 Feb 2026 07:14:38 +0000 (02:14 -0500)] 
conf/util: fix non-specification of IP route destination address

The Linux/libnl version of virNetDevIPRouteAdd() has always had code
that would use "0.0.0.0" (or "::" for IPv6) for the route's
destination address if none was specified, but 1) our validation code
has always required it to be specified anyway, 2) the FreeBSD version
of virnertDevIPRouteAdd() expected that it would be specified, and 3)
virNetDevIPRouteFormat() also expected route->address to be
valid. This patch fixes those 3 deficiencies, so that this XML now
works:

   <route gateway='1.2.3.4'/>

i.e. it is the same as:

   <route address='0.0.0.0' prefix='0' gateway='1.2.3.4'/>

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 weeks agoutil: make the route arg to virNetDevIPRouteGetPrefix const
Laine Stump [Thu, 12 Feb 2026 16:18:27 +0000 (11:18 -0500)] 
util: make the route arg to virNetDevIPRouteGetPrefix const

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu: only limit IPv4 prefix for slirp
Laine Stump [Wed, 11 Feb 2026 23:31:42 +0000 (18:31 -0500)] 
qemu: only limit IPv4 prefix for slirp

The slirp backend is limited in what the netmask/prefix of a
user-specified IP address can be, but passt doesn't have these
artificial limitations - any valid prefix is okay with passt, so we
shouldn't reject them

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 weeks agoqemu: reorganize qemuValidateDomainDeviceDefNetwork()
Laine Stump [Wed, 11 Feb 2026 23:28:50 +0000 (18:28 -0500)] 
qemu: reorganize qemuValidateDomainDeviceDefNetwork()

This will make existing code more consistent with upcoming validation
for routes.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agoqemu: delete passt "repair" socket when appropriate
Laine Stump [Tue, 3 Feb 2026 21:24:09 +0000 (16:24 -0500)] 
qemu: delete passt "repair" socket when appropriate

When using a vhost-user connection between passt and QEMU, passt will
autocreate a socket called ${socketname}.repair, but doesn't delete
this socket when it exits, so to be a good citizen, libvirt should
delete it when we are tearing down the passt device plumbing.

Resolves: https://issues.redhat.com/browse/RHEL-80285
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agotest: Default to ROM type for loader
Jim Fehlig [Fri, 6 Mar 2026 16:56:16 +0000 (09:56 -0700)] 
test: Default to ROM type for loader

Commit 1504b7f687 moved the corresponding logic from the generic
postparse code to drivers but failed to update the test driver,
which causes failures in virt-manager's test suite.

Fixes: 1504b7f687bdfc679377e605d076776b18533468
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 weeks agobhyve: support NUMA configuration for domains
Roman Bogorodskiy [Fri, 27 Feb 2026 09:38:51 +0000 (10:38 +0100)] 
bhyve: support NUMA configuration for domains

Bhyve supports NUMA domains configuration using the '-n'
command line argument:

  -n id,size,cpus[,domain_policy]

Here, "id" is a numeric NUMA domain id, "size" is the total VM
memory size with units format similar to the "-m" switch,
"cpus" is a cpuset, and "domain_policy" is an optional
domainset(9) memory allocation policy. The "domain_policy"
is currently not used by the libvirt driver.

This argument is repeated for every NUMA domain to be configured, e.g.:

  bhyve \
  ...
  -n id=0,size=107,cpus=0-3
  -n id=1,size=107,cpus=4-7

To support that:

 * Add a corresponding capability; it is considered supported
   if the bhyve binary has the '-n' command line switch.

 * Generate command line arguments for NUMA from
   <cpu><numa>..</numa></cpu> domain configuration.

Additionally, validate that:

 * NUMA domains can be only configured with the UEFI loaders.
 * No more than 8 domains configured per VM as limited by bhyve.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agohyperv: implement virDomainDefineXMLFlags()
Jonathon Jongsma [Fri, 27 Feb 2026 20:43:00 +0000 (14:43 -0600)] 
hyperv: implement virDomainDefineXMLFlags()

We already implement virDomainDefineXML(), so we can just implement one
in terms of the other.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agohyperv: fix flags passed to virDomainDefParseString()
Jonathon Jongsma [Fri, 27 Feb 2026 20:34:58 +0000 (14:34 -0600)] 
hyperv: fix flags passed to virDomainDefParseString()

This function expects flags that are bitwise-or values of the
VIR_DOMAIN_DEF_PARSE_* constants, but we were passing two flags that
were not part of this flag set:
 - 1 < VIR_DOMAIN_VIRT_HYPERV
 - VIR_DOMAIN_XML_INACTIVE

Replace VIR_DOMAIN_XML_INACTIVE with VIR_DOMAIN_DEF_PARSE_INACTIVE
(which fortunately happens to be the exact same value). Remove flag
"1 < VIR_DOMAIN_VIRT_HYPERV", which turns out to the the same value
as the flag VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION, which seems
unnecessary and undesirable here.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 weeks agohyperv: ensure we don't define multiple domains with the same name
Jonathon Jongsma [Fri, 27 Feb 2026 17:56:00 +0000 (11:56 -0600)] 
hyperv: ensure we don't define multiple domains with the same name

Right now if we run `virsh define domain.xml` multiple times, it will
result in multiple domains being defined with the same name. This
violates libvirt assumptions about name uniqueness, so prevent this from
happening by returning an error.

There's not much we can do about vms that may have been created outside
of libvirt that might have the same name (unless we switch to using
something like the UUID as the name for hyperv domains, which would
not be very user-friendly), but at least we can not contribute to the
problem.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 weeks agohyperv: improve error message when redefining domain
Jonathon Jongsma [Fri, 27 Feb 2026 17:47:00 +0000 (11:47 -0600)] 
hyperv: improve error message when redefining domain

The current error message results in something like the following when
running `virsh define` for an existing domain:

    `domain Domain already exists with UUID '$UUID' exists already`

Improve the error message and make it behave like the esx driver and
indicate that we do not yet support redefining existing domains in hyperv.

Also avoid using the public LookupByUUID() API to check for existance,
which requires unnecessarily allocating and de-allocating a virDomainPtr
object.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 weeks agoutil: json: fix memory leak in virJSONValueFromJsonC()
Elizaveta Tereshkina [Fri, 6 Mar 2026 10:46:20 +0000 (13:46 +0300)] 
util: json: fix memory leak in virJSONValueFromJsonC()

In the 'json_type_object' and/ro 'json_type_array' cases, the
error path uses 'g_free()', which doesn't release other nested
memory allocations.  Replace it with 'virJSONValueFree()' to
properly free the entire 'virJSONValue' structure.

Fixes: 9e6555fd90988948a05e83466b1903bb95b36f39
Fixes: da66bf53b09ee8f5facacae700638a9a6f3a2477
Signed-off-by: Elizaveta Tereshkina <teryoshkina.ea@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 weeks agosecret: install service file only if init_script is 'systemd'
Roman Bogorodskiy [Mon, 2 Mar 2026 18:38:39 +0000 (19:38 +0100)] 
secret: install service file only if init_script is 'systemd'

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 weeks agoqemu: Fix IOMMUFD and VFIO security labels
Pavel Hrdina [Fri, 27 Feb 2026 16:55:34 +0000 (17:55 +0100)] 
qemu: Fix IOMMUFD and VFIO security labels

When IOMMUFD support was introduced it incorrectly tried to label
`/dev/iommu` and `/dev/vfio/devices/vfioX` but they are not added to
QEMU namespace because libvirt opens FDs and passes these FDs to QEMU.

We need to label these FDs instead.

Fixes: 7d2f91f9cb572ab95d0916bdd1a46dd198874529
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 weeks agosecurity: Cleanup hostdev label error logic
Pavel Hrdina [Mon, 2 Mar 2026 11:46:00 +0000 (12:46 +0100)] 
security: Cleanup hostdev label error logic

Current code used mix of return, goto, break and setting ret variable.
Simplify the logic to just return -1 on error.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 weeks agosecurity_apparmor: Use g_auto* in AppArmorSetSecurityHostdevLabel
Pavel Hrdina [Mon, 2 Mar 2026 11:47:43 +0000 (12:47 +0100)] 
security_apparmor: Use g_auto* in AppArmorSetSecurityHostdevLabel

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 weeks agoPost-release version bump to 12.2.0
Jiri Denemark [Mon, 2 Mar 2026 09:27:06 +0000 (10:27 +0100)] 
Post-release version bump to 12.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
5 weeks agoRelease of libvirt-12.1.0 v12.1.0
Jiri Denemark [Mon, 2 Mar 2026 09:22:43 +0000 (10:22 +0100)] 
Release of libvirt-12.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
5 weeks agonews: Mention latency histogram support and (managed) save fixes
Peter Krempa [Mon, 2 Mar 2026 08:46:28 +0000 (09:46 +0100)] 
news: Mention latency histogram support and (managed) save fixes

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 weeks agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Thu, 26 Feb 2026 18:58:27 +0000 (18:58 +0000)] 
Translated using Weblate (English (United Kingdom))

Currently translated at 47.8% (5256 of 10975 strings)

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

Signed-off-by: Andi Chandler <andi@gowling.com>
5 weeks agofdstream: fix EOF handling when reading data
Daniel P. Berrangé [Tue, 24 Feb 2026 17:44:19 +0000 (17:44 +0000)] 
fdstream: fix EOF handling when reading data

A recent commit caused the virFDStreamRead method to loop reading data
until the provided buffer is full. Unfortunately the EOF handling was
not quite correct.

 * When seeing a virFDStreamMsg with length zero, it would still
   loop trying to read more and then get an error that the thread
   has quit.

 * When seeing a virFDStreamMsg with length zero on subsequent
   iterations, it would discard this message, which would in turn
   prevent the caller from ever seeing the 'ret == 0' return value
   indicating EOF. The caller would then try to read again and get
   an error about the stream being closed.

Fixes: e23fd0b7fd36c41e6db49df4f4962762d3ef6ab0
Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Tested-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 weeks agofdstream: don't set return value if looping to read more data
Daniel P. Berrangé [Tue, 24 Feb 2026 17:11:59 +0000 (17:11 +0000)] 
fdstream: don't set return value if looping to read more data

The 'ret' variable should only have a value assigned once we have
completely finished reading data, otherwise an error on a subsequent
iteration will report an error but not return a negative value.

Fixes: e23fd0b7fd36c41e6db49df4f4962762d3ef6ab0
Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Tested-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 weeks agonews: document bhyve changes for 12.1.0
Roman Bogorodskiy [Fri, 27 Feb 2026 09:52:28 +0000 (10:52 +0100)] 
news: document bhyve changes for 12.1.0

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 weeks agoNEWS: Document features/improvements/bug fixes I've participated in
Michal Privoznik [Fri, 27 Feb 2026 12:34:23 +0000 (13:34 +0100)] 
NEWS: Document features/improvements/bug fixes I've participated in

There are some features/improvements/bug fixes I've either
contributed or reviewed/merged. Document them for upcoming
release.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 weeks agonews: document new hyperv features
Jonathon Jongsma [Thu, 26 Feb 2026 15:20:43 +0000 (09:20 -0600)] 
news: document new hyperv features

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
6 weeks agoqemu_hotplug: enter monitor in order to rollback passed FD v12.1.0-rc2
Pavel Hrdina [Thu, 26 Feb 2026 09:54:18 +0000 (10:54 +0100)] 
qemu_hotplug: enter monitor in order to rollback passed FD

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 weeks agodomain_conf: initialize network hostdev private data
Pavel Hrdina [Thu, 26 Feb 2026 09:18:23 +0000 (10:18 +0100)] 
domain_conf: initialize network hostdev private data

Currently virDomainNetDef and virDomainActualNetDef use
virDomainHostdevDef directly as structure and the code doesn't call
virDomainHostdevDefNew() that would initialize private data.

This is hackish quick fix to solve a crash that happens in two
scenarios:

1. attaching any interface with hostdev backend

0x0000fffbfc0e2a90 in qemuDomainAttachHostPCIDevice (driver=0xfffbb4006750, vm=0xfffbf001f790, hostdev=0xfffbf400b150) at ../src/qemu/qemu_hotplug.c:1652
1652 if ((ret = qemuFDPassDirectTransferMonitor(hostdevPriv->vfioDeviceFd, priv->mon)) < 0)

2. starting VM with interface with hostdev backend using iommufd

0x00007f6638d5b9ca in qemuProcessOpenVfioDeviceFd (hostdev=hostdev@entry=0x7f6634425ee0) at ../src/qemu/qemu_process.c:7719
7719     hostdevPriv->vfioDeviceFd = qemuFDPassDirectNew(name, &vfioDeviceFd);

Proper fix for this issue is to refactor network code to use pointer and to
use virDomainHostdevDefNew().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
6 weeks agoutil: fix use-after-free in virIdentityGetSystem
Stefan Kober [Wed, 25 Feb 2026 12:50:16 +0000 (13:50 +0100)] 
util: fix use-after-free in virIdentityGetSystem

We have a g_autoptr ret in the virIdentityGetSystem function. In the
happy path it is properly returned by doing: return g_steal_pointer(&ret);

There are 2 early return paths, were we do the following: "return ret;"

This leads to the g_autoptr being cleaned up after we leave the
function, as we do not properly "steal" it.

When later using the return value we have a use-after-free, which has
led to segfaults in some cases.

As this is a regression introduced in v5.9.0-rc1~269, we change
the behavior to properly return NULL in those cases.

Fixes: c6825d88137cb8e4debdf4310e45ee23cb5698c0
On-behalf-of: SAP stefan.kober@sap.com
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
6 weeks agovmx: log full .vmx content
Cole Robinson [Tue, 24 Feb 2026 16:09:45 +0000 (11:09 -0500)] 
vmx: log full .vmx content

We can kinda triangulate it from virConf debugging lines,
but this is nicer IMO

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 weeks agoqemu: Fix job handling when domain dies in post-copy migration
Jiri Denemark [Mon, 23 Feb 2026 15:23:10 +0000 (16:23 +0100)] 
qemu: Fix job handling when domain dies in post-copy migration

When a domain is in post-copy migration phase, we need to keep the job
active if something fails to protect the domain from changes.
Unfortunately, there is a race between migration code and
qemuProcessStop that can cause the job to stay active even when the
domain is gone and thus preventing the domain from being started again
(until virtqemud is restarted). The race is caused by unlocking the vm
object when calling virConnectUnregisterCloseCallback. While the domain
is unlocked qemuProcessStop can finish its work and the domain may no
longer be active when we get the lock back. The post-copy path does not
properly check if a domain is still active.

Instead of adding the virDomainObjIsActive check in all places where
this could happen, we can add it in virDomainObjIsPostcopy and
virDomainObjIsFailedPostcopy and let the code take the pre-copy cleanup
path. Clearly an inactive domain can never be in (failed) post-copy
migration.

https://issues.redhat.com/browse/RHEL-145179

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
6 weeks agopo: Refresh potfile for v12.1.0 v12.1.0-rc1
Jiri Denemark [Tue, 24 Feb 2026 12:59:36 +0000 (13:59 +0100)] 
po: Refresh potfile for v12.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 weeks agoTranslated using Weblate (Chinese (Simplified) (zh_CN))
Haorong Xu [Mon, 23 Feb 2026 20:21:16 +0000 (20:21 +0000)] 
Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 97.9% (10790 of 11015 strings)

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

Signed-off-by: Haorong Xu <haorongxu09@gmail.com>
6 weeks agoTranslated using Weblate (Spanish)
Fco. Javier F. Serrador [Mon, 23 Feb 2026 20:21:15 +0000 (20:21 +0000)] 
Translated using Weblate (Spanish)

Currently translated at 90.3% (9956 of 11015 strings)

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

Signed-off-by: "Fco. Javier F. Serrador" <fserrador@gmail.com>
6 weeks agoTranslated using Weblate (Spanish)
Weblate [Mon, 23 Feb 2026 20:21:14 +0000 (20:21 +0000)] 
Translated using Weblate (Spanish)

Currently translated at 90.3% (9956 of 11015 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
6 weeks agoTranslated using Weblate (Spanish)
Fco. Javier F. Serrador [Mon, 23 Feb 2026 20:21:14 +0000 (20:21 +0000)] 
Translated using Weblate (Spanish)

Currently translated at 87.8% (9682 of 11015 strings)

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

Signed-off-by: "Fco. Javier F. Serrador" <fserrador@gmail.com>
6 weeks agoTranslated using Weblate (Czech)
Pavel Borecki [Mon, 23 Feb 2026 20:21:13 +0000 (20:21 +0000)] 
Translated using Weblate (Czech)

Currently translated at 98.2% (10818 of 11015 strings)

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

Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
Translated using Weblate (Czech)

Currently translated at 98.2% (10818 of 11015 strings)

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

Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
Translated using Weblate (Czech)

Currently translated at 98.2% (10818 of 11015 strings)

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

Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
Translated using Weblate (Czech)

Currently translated at 98.1% (10816 of 11015 strings)

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

Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
Translated using Weblate (Czech)

Currently translated at 98.1% (10815 of 11015 strings)

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

Signed-off-by: Pavel Borecki <pavel.borecki@gmail.com>
6 weeks agoTranslated using Weblate (Greek)
Jim Spentzos [Mon, 23 Feb 2026 20:21:12 +0000 (20:21 +0000)] 
Translated using Weblate (Greek)

Currently translated at 1.3% (152 of 11015 strings)

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

Signed-off-by: Jim Spentzos <jimspentzos2000@gmail.com>
6 weeks agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Mon, 23 Feb 2026 20:21:11 +0000 (20:21 +0000)] 
Translated using Weblate (Romanian)

Currently translated at 45.5% (5015 of 11015 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
6 weeks agoTranslated using Weblate (Greek)
Weblate [Mon, 23 Feb 2026 20:21:11 +0000 (20:21 +0000)] 
Translated using Weblate (Greek)

Currently translated at 1.3% (146 of 11015 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
6 weeks agoTranslated using Weblate (Greek)
Jim Spentzos [Mon, 23 Feb 2026 20:21:09 +0000 (20:21 +0000)] 
Translated using Weblate (Greek)

Currently translated at 1.3% (146 of 11015 strings)

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

Signed-off-by: Jim Spentzos <jimspentzos2000@gmail.com>
6 weeks agoTranslated using Weblate (Swedish)
Luna Jernberg [Mon, 23 Feb 2026 20:21:08 +0000 (20:21 +0000)] 
Translated using Weblate (Swedish)

Currently translated at 100.0% (11015 of 11015 strings)

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

Signed-off-by: Luna Jernberg <droidbittin@gmail.com>
6 weeks agoTranslated using Weblate (Swedish)
Daniel Nylander [Mon, 23 Feb 2026 20:21:08 +0000 (20:21 +0000)] 
Translated using Weblate (Swedish)

Currently translated at 99.9% (11008 of 11015 strings)

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

Signed-off-by: Daniel Nylander <po@danielnylander.se>
6 weeks agoUpdate translation files
Hosted Weblate [Mon, 23 Feb 2026 20:21:07 +0000 (20:21 +0000)] 
Update translation files

Updated by "Update LINGUAS file" hook in Weblate.

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

Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
6 weeks agoAdded translation using Weblate (Chinese (Traditional Han script))
Languages add-on [Mon, 23 Feb 2026 20:21:07 +0000 (20:21 +0000)] 
Added translation using Weblate (Chinese (Traditional Han script))

Signed-off-by: Languages add-on <noreply-addon-languages@weblate.org>
6 weeks agoTranslated using Weblate (Georgian)
Weblate [Mon, 23 Feb 2026 20:21:06 +0000 (20:21 +0000)] 
Translated using Weblate (Georgian)

Currently translated at 4.6% (515 of 11015 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
6 weeks agobhyve: Default to ROM type for loader
Andrea Bolognani [Tue, 24 Feb 2026 11:31:43 +0000 (12:31 +0100)] 
bhyve: Default to ROM type for loader

A previous commit had moved this logic from the generic
postparse code to drivers but failed to update the bhyve driver
accordingly in the process.

Fixes: 1504b7f687bdfc679377e605d076776b18533468
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 weeks agonews: Document support for uefi-vars device and firmwares
Andrea Bolognani [Sun, 8 Feb 2026 23:20:35 +0000 (00:20 +0100)] 
news: Document support for uefi-vars device and firmwares

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>