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> --- src/conf/domain_conf.c | 13 +++++++++++++ src/conf/domain_conf.h | 3 +++ src/hypervisor/virhostdev.c | 2 +- src/libvirt_private.syms | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 01e2bd631a..2d6ae64210 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -33079,6 +33079,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 e63230beec..018daef4c7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4735,6 +4735,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 19907c76ba..0d5e582c08 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -2536,7 +2536,7 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr, 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 cd028c488a..8dbbd7f64d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -817,6 +817,7 @@ virDomainQemuMonitorEventStateRegisterID; virHostdevIsMdevDevice; virHostdevIsPCIDevice; virHostdevIsPCIDeviceWithIOMMUFD; +virHostdevIsPCIDeviceWithoutIOMMUFD; virHostdevIsSCSIDevice; -- 2.53.0