diff --git a/libvirt-hypervisor-Call-virWaitForDevices-after-detaching-host-devices.patch b/libvirt-hypervisor-Call-virWaitForDevices-after-detaching-host-devices.patch new file mode 100644 index 0000000..a310b4f --- /dev/null +++ b/libvirt-hypervisor-Call-virWaitForDevices-after-detaching-host-devices.patch @@ -0,0 +1,47 @@ +From f753d55edab43dae78f9ef5dc13ca53f626e09fe Mon Sep 17 00:00:00 2001 +Message-ID: +From: Pavel Hrdina +Date: Thu, 26 Mar 2026 14:32:36 +0100 +Subject: [PATCH] hypervisor: Call virWaitForDevices() after detaching host + devices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pavel Hrdina + +On systems with selinux enabled starting a VM with managed host device +using IOMMUFD backend can run into race-condition where both libvirt and +udev are setting selinux label on /dev/vfio/devices/vfioX device. If +udev is the last one to set selinux label starting VM fails with: + +error: internal error: QEMU unexpectedly closed the monitor (vm='test'): 2026-03-26T15:47:36.620422Z qemu-kvm: -device {"driver":"vfio-pci","id":"hostdev0","iommufd":"iommufd0","fd":"20","bus":"pci.7","addr":"0x0"}: vfio hostdev0: Failed to add fd 20 to KVM VFIO device: Invalid argument + +We need to wait for udev to finish processing all events. + +Signed-off-by: Pavel Hrdina +Reviewed-by: Ján Tomko +(cherry picked from commit b96ea4db3aabac4790d6e1d53e2f309f5e73efae) + +Resolves: https://redhat.atlassian.net/browse/VOYAGER-309 +Signed-off-by: Pavel Hrdina +--- + src/hypervisor/virhostdev.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c +index 43155ceb6c..981ca4cd20 100644 +--- a/src/hypervisor/virhostdev.c ++++ b/src/hypervisor/virhostdev.c +@@ -782,6 +782,9 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mgr, + } + } + ++ /* Step 2.5: Wait for udev to handle all events for devices. */ ++ virWaitForDevices(); ++ + /* At this point, all devices are attached to the stub driver and have + * been marked as inactive */ + +-- +2.53.0 diff --git a/libvirt.spec b/libvirt.spec index d497a30..4034993 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -294,7 +294,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 11.10.0 -Release: 10.4%{?dist}%{?extra_release} +Release: 10.5%{?dist}%{?extra_release} License: GPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OFL-1.1 URL: https://libvirt.org/ @@ -404,6 +404,7 @@ Patch99: libvirt-qemu-Implement-iommufd.patch Patch100: libvirt-conf-Add-iommufd-fdgroup-support.patch Patch101: libvirt-qemu-Implement-iommufd-fdgroup.patch Patch102: libvirt-tests-Add-iommufd-fdgroup-test.patch +Patch103: libvirt-hypervisor-Call-virWaitForDevices-after-detaching-host-devices.patch Requires: libvirt-daemon = %{version}-%{release} @@ -2795,6 +2796,9 @@ exit 0 %endif %changelog +* Fri Mar 27 2026 Pavel Hrdina - 11.10.0-10.5 +- hypervisor: Call virWaitForDevices() after detaching host devices (VOYAGER-309) + * Fri Mar 20 2026 Pavel Hrdina - 11.10.0-10.4 - security_apparmor: Use g_auto* in AppArmorSetSecurityHostdevLabel (VOYAGER-309) - security: Cleanup hostdev label error logic (VOYAGER-309)