- security_apparmor: Use g_auto* in AppArmorSetSecurityHostdevLabel (VOYAGER-309) - security: Cleanup hostdev label error logic (VOYAGER-309) - qemu: Fix IOMMUFD and VFIO security labels (VOYAGER-309) - viriommufd: Set IOMMU_OPTION_RLIMIT_MODE only when running privileged (VOYAGER-309) - conf: Move and rename virStorageSourceFDTuple object (VOYAGER-309) - conf: Refactor virHostdevIsPCIDevice (VOYAGER-309) - hypervisor: Fix virHostdevNeedsVFIO detection (VOYAGER-309) - qemu: Expand call to qemuDomainNeedsVFIO (VOYAGER-309) - qemu: Update qemuDomainNeedsVFIO to ignore PCI hostdev with IOMMUFD (VOYAGER-309) - src: Use virHostdevIsPCIDeviceWith* to check for IOMMUFD (VOYAGER-309) - conf: Introduce domain iommufd element (VOYAGER-309) - qemu: Implement iommufd (VOYAGER-309) - conf: Add iommufd fdgroup support (VOYAGER-309) - qemu: Implement iommufd fdgroup (VOYAGER-309) - tests: Add iommufd fdgroup test (VOYAGER-309) Resolves: VOYAGER-309
101 lines
3.2 KiB
Diff
101 lines
3.2 KiB
Diff
From c57b38c1bf7771489142198c7cf6fdc6ac1b15e1 Mon Sep 17 00:00:00 2001
|
|
Message-ID: <c57b38c1bf7771489142198c7cf6fdc6ac1b15e1.1774023916.git.phrdina@redhat.com>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Wed, 18 Mar 2026 11:57:43 +0100
|
|
Subject: [PATCH] hypervisor: Fix virHostdevNeedsVFIO detection
|
|
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
Function virHostdevNeedsVFIO is used only in QEMU to figure out if the
|
|
host device needs access to /dev/vfio/vfio, for PCI host devices that is
|
|
true only if libvirt is not using IOMMUFD.
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
(cherry picked from commit ffa8020d3665f7ff27c6b82e88d3a93674155c8d)
|
|
|
|
Resolves: https://redhat.atlassian.net/browse/VOYAGER-309
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
---
|
|
src/conf/domain_conf.c | 13 +++++++++++++
|
|
src/conf/domain_conf.h | 3 +++
|
|
src/hypervisor/virhostdev.c | 9 ++++++++-
|
|
src/libvirt_private.syms | 1 +
|
|
4 files changed, 25 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
index da90fd1446..e8c4116fa0 100644
|
|
--- a/src/conf/domain_conf.c
|
|
+++ b/src/conf/domain_conf.c
|
|
@@ -32936,6 +32936,19 @@ virHostdevIsPCIDeviceWithIOMMUFD(const virDomainHostdevDef *hostdev)
|
|
}
|
|
|
|
|
|
+/**
|
|
+ * virHostdevIsPCIDeviceWithIOMMUFD:
|
|
+ * @hostdev: host device to check
|
|
+ *
|
|
+ * Returns true if @hostdev is a PCI device with IOMMUFD disabled, false otherwise.
|
|
+ */
|
|
+bool
|
|
+virHostdevIsPCIDeviceWithoutIOMMUFD(const virDomainHostdevDef *hostdev)
|
|
+{
|
|
+ return virHostdevIsPCIDeviceImpl(hostdev, VIR_TRISTATE_BOOL_NO);
|
|
+}
|
|
+
|
|
+
|
|
static void
|
|
virDomainObjGetMessagesIOErrorsSrc(virStorageSource *src,
|
|
const char *diskdst,
|
|
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
|
index 91b8976ea5..36e69ad6fd 100644
|
|
--- a/src/conf/domain_conf.h
|
|
+++ b/src/conf/domain_conf.h
|
|
@@ -4726,6 +4726,9 @@ virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev)
|
|
bool
|
|
virHostdevIsPCIDeviceWithIOMMUFD(const virDomainHostdevDef *hostdev)
|
|
ATTRIBUTE_NONNULL(1);
|
|
+bool
|
|
+virHostdevIsPCIDeviceWithoutIOMMUFD(const virDomainHostdevDef *hostdev)
|
|
+ ATTRIBUTE_NONNULL(1);
|
|
|
|
void
|
|
virDomainObjGetMessagesIOErrorsChain(virStorageSource *src,
|
|
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
|
|
index 7d7df4418d..43155ceb6c 100644
|
|
--- a/src/hypervisor/virhostdev.c
|
|
+++ b/src/hypervisor/virhostdev.c
|
|
@@ -2510,10 +2510,17 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr,
|
|
goto cleanup;
|
|
}
|
|
|
|
+/**
|
|
+ * virHostdevNeedsVFIO:
|
|
+ * @hostdev: host device to check
|
|
+ *
|
|
+ * Returns true if using the @hostdev requires access to /dev/vfio/vfio,
|
|
+ * otherwise false.
|
|
+ */
|
|
bool
|
|
virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev)
|
|
{
|
|
- return virHostdevIsPCIDevice(hostdev) ||
|
|
+ return virHostdevIsPCIDeviceWithoutIOMMUFD(hostdev) ||
|
|
virHostdevIsMdevDevice(hostdev);
|
|
}
|
|
|
|
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
index 386e757d81..ea1e2d8586 100644
|
|
--- a/src/libvirt_private.syms
|
|
+++ b/src/libvirt_private.syms
|
|
@@ -814,6 +814,7 @@ virDomainQemuMonitorEventStateRegisterID;
|
|
virHostdevIsMdevDevice;
|
|
virHostdevIsPCIDevice;
|
|
virHostdevIsPCIDeviceWithIOMMUFD;
|
|
+virHostdevIsPCIDeviceWithoutIOMMUFD;
|
|
virHostdevIsSCSIDevice;
|
|
|
|
|
|
--
|
|
2.53.0
|