hypervisor: move HostdevNeedsVFIO to hypervisor

Move HostdevNeedsVFIO method to hypervisor to be reused between qemu
and ch drivers.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Praveen K Paladugu 2024-10-11 13:13:02 -05:00 committed by Michal Privoznik
parent 0dad1ec009
commit b05f6134c9
7 changed files with 15 additions and 13 deletions

View File

@ -2512,3 +2512,10 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr,
}
goto cleanup;
}
bool
virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev)
{
return virHostdevIsPCIDevice(hostdev) ||
virHostdevIsMdevDevice(hostdev);
}

View File

@ -232,3 +232,6 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr,
const char *dom_name,
virDomainDiskDef **disks,
size_t ndisks);
bool
virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev);

View File

@ -1674,6 +1674,7 @@ virCloseCallbacksDomainRunForConn;
# hypervisor/virhostdev.h
virHostdevFindUSBDevice;
virHostdevManagerGetDefault;
virHostdevNeedsVFIO;
virHostdevPCINodeDeviceDetach;
virHostdevPCINodeDeviceReAttach;
virHostdevPCINodeDeviceReset;

View File

@ -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) {

View File

@ -130,14 +130,6 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriver *driver,
}
bool
qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev)
{
return virHostdevIsPCIDevice(hostdev) ||
virHostdevIsMdevDevice(hostdev);
}
bool
qemuHostdevHostSupportsPassthroughVFIO(void)
{

View File

@ -23,8 +23,6 @@
#include "qemu_conf.h"
bool qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev);
bool qemuHostdevHostSupportsPassthroughVFIO(void);
int qemuHostdevUpdateActiveNVMeDisks(virQEMUDriver *driver,

View File

@ -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));