diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 185ec2ca50..4b06e74894 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -2512,3 +2512,10 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr, } goto cleanup; } + +bool +virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev) +{ + return virHostdevIsPCIDevice(hostdev) || + virHostdevIsMdevDevice(hostdev); +} diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index 22ec3068db..b9e6108816 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -232,3 +232,6 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr, const char *dom_name, virDomainDiskDef **disks, size_t ndisks); + +bool +virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 62c729d7ff..6616f96712 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1674,6 +1674,7 @@ virCloseCallbacksDomainRunForConn; # hypervisor/virhostdev.h virHostdevFindUSBDevice; virHostdevManagerGetDefault; +virHostdevNeedsVFIO; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; virHostdevPCINodeDeviceReset; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 23b7e6b4e8..be4b9a38ff 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -32,6 +32,7 @@ #include "virfile.h" #include "virdevmapper.h" #include "virglibutil.h" +#include "virhostdev.h" #define VIR_FROM_THIS VIR_FROM_QEMU @@ -481,7 +482,7 @@ qemuSetupHostdevCgroup(virDomainObj *vm, return -1; } - if (qemuHostdevNeedsVFIO(dev) && + if (virHostdevNeedsVFIO(dev) && qemuCgroupAllowDevicePath(vm, QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RW, false) < 0) { return -1; @@ -530,7 +531,7 @@ qemuTeardownHostdevCgroup(virDomainObj *vm, return -1; } - if (qemuHostdevNeedsVFIO(dev) && + if (virHostdevNeedsVFIO(dev) && !qemuDomainNeedsVFIO(vm->def) && qemuCgroupDenyDevicePath(vm, QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RWM, false) < 0) { diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 15b543dbff..f25ccaf1a4 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -130,14 +130,6 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriver *driver, } -bool -qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev) -{ - return virHostdevIsPCIDevice(hostdev) || - virHostdevIsMdevDevice(hostdev); -} - - bool qemuHostdevHostSupportsPassthroughVFIO(void) { diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index 3e9adc57a9..bbf7bb11e7 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -23,8 +23,6 @@ #include "qemu_conf.h" -bool qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev); - bool qemuHostdevHostSupportsPassthroughVFIO(void); int qemuHostdevUpdateActiveNVMeDisks(virQEMUDriver *driver, diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 5d9385afd6..0ebc115524 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -339,7 +339,7 @@ qemuDomainSetupHostdev(virDomainObj *vm, if (path) *paths = g_slist_prepend(*paths, g_steal_pointer(&path)); - if (qemuHostdevNeedsVFIO(hostdev) && + if (virHostdevNeedsVFIO(hostdev) && (!hotplug || !qemuDomainNeedsVFIO(vm->def))) *paths = g_slist_prepend(*paths, g_strdup(QEMU_DEV_VFIO));