conf: replace virHostdevIsVFIODevice with virHostdevIsPCIDevice

virHostdevIsVFIODevice() and virDomainDefHasVFIOHostdev() are only ever
called from the QEMU driver, and in the case of the QEMU driver, any
PCI hostdev by definition uses VFIO, so really all these callers only
need to know if the device is a PCI hostdev.

(It turned out that the less specific virHostdevIsPCIDevice() already
existed in hypervisor/virhostdev.c, so I had to remove one of them;
since conf is a lower level directory than hypervisor, and the
function is called from conf, keeping the copy in hypervisor would
have required moving its caller (virDomainDefHasPCIHostdev()) into
hypervisor as well, so I just removed the copy in hypervisor.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Laine Stump 2024-01-04 20:12:51 -05:00
parent bb1acb9ca2
commit b9a1e7c436
8 changed files with 15 additions and 27 deletions

View File

@ -30704,12 +30704,12 @@ virDomainDefHasNVMeDisk(const virDomainDef *def)
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def)
virDomainDefHasPCIHostdev(const virDomainDef *def)
{
size_t i;
for (i = 0; i < def->nhostdevs; i++) {
if (virHostdevIsVFIODevice(def->hostdevs[i]))
if (virHostdevIsPCIDevice(def->hostdevs[i]))
return true;
}
@ -30980,17 +30980,16 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *hostdev)
/**
* virHostdevIsVFIODevice:
* virHostdevIsPCIDevice:
* @hostdev: host device to check
*
* Returns true if @hostdev is a PCI device with VFIO backend, false otherwise.
* Returns true if @hostdev is a PCI device, false otherwise.
*/
bool
virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev)
virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev)
{
return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
hostdev->source.subsys.u.pci.driver.name == VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO;
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
}

View File

@ -4419,7 +4419,7 @@ bool
virDomainDefHasNVMeDisk(const virDomainDef *def);
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def);
virDomainDefHasPCIHostdev(const virDomainDef *def);
bool
virDomainDefHasMdevHostdev(const virDomainDef *def);
@ -4477,7 +4477,7 @@ bool
virHostdevIsMdevDevice(const virDomainHostdevDef *hostdev)
ATTRIBUTE_NONNULL(1);
bool
virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev)
virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev)
ATTRIBUTE_NONNULL(1);
int

View File

@ -344,14 +344,6 @@ virHostdevNetDevice(virDomainHostdevDef *hostdev,
}
bool
virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev)
{
return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
}
static bool
virHostdevIsPCINetDevice(const virDomainHostdevDef *hostdev)
{

View File

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

View File

@ -340,11 +340,11 @@ virDomainDefHasMemoryHotplug;
virDomainDefHasNVMeDisk;
virDomainDefHasOldStyleROUEFI;
virDomainDefHasOldStyleUEFI;
virDomainDefHasPCIHostdev;
virDomainDefHasSpiceGraphics;
virDomainDefHasUSB;
virDomainDefHasVcpusOffline;
virDomainDefHasVDPANet;
virDomainDefHasVFIOHostdev;
virDomainDefLifecycleActionAllowed;
virDomainDefMaybeAddController;
virDomainDefMaybeAddInput;
@ -777,8 +777,8 @@ virDomainEventWatchdogNewFromObj;
virDomainQemuMonitorEventNew;
virDomainQemuMonitorEventStateRegisterID;
virHostdevIsMdevDevice;
virHostdevIsPCIDevice;
virHostdevIsSCSIDevice;
virHostdevIsVFIODevice;
# conf/domain_nwfilter.h
@ -1642,7 +1642,6 @@ virCloseCallbacksDomainRunForConn;
# hypervisor/virhostdev.h
virHostdevFindUSBDevice;
virHostdevIsPCIDevice;
virHostdevManagerGetDefault;
virHostdevPCINodeDeviceDetach;
virHostdevPCINodeDeviceReAttach;

View File

@ -9343,7 +9343,7 @@ getPPC64MemLockLimitBytes(virDomainDef *def)
for (i = 0; i < def->nhostdevs; i++) {
virDomainHostdevDef *dev = def->hostdevs[i];
if (virHostdevIsVFIODevice(dev)) {
if (virHostdevIsPCIDevice(dev)) {
pciAddr = &dev->source.subsys.u.pci.addr;
if (virPCIDeviceAddressIsValid(pciAddr, false)) {
@ -9448,7 +9448,7 @@ qemuDomainGetNumVFIOHostdevs(const virDomainDef *def)
int n = 0;
for (i = 0; i < def->nhostdevs; i++) {
if (virHostdevIsVFIODevice(def->hostdevs[i]) ||
if (virHostdevIsPCIDevice(def->hostdevs[i]) ||
virHostdevIsMdevDevice(def->hostdevs[i]))
n++;
}
@ -10492,7 +10492,7 @@ qemuDomainSupportsVideoVga(const virDomainVideoDef *video,
bool
qemuDomainNeedsVFIO(const virDomainDef *def)
{
return virDomainDefHasVFIOHostdev(def) ||
return virDomainDefHasPCIHostdev(def) ||
virDomainDefHasMdevHostdev(def) ||
virDomainDefHasNVMeDisk(def);
}

View File

@ -133,7 +133,7 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriver *driver,
bool
qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev)
{
return virHostdevIsVFIODevice(hostdev) ||
return virHostdevIsPCIDevice(hostdev) ||
virHostdevIsMdevDevice(hostdev);
}

View File

@ -4738,7 +4738,7 @@ qemuDomainRemoveHostDevice(virQEMUDriver *driver,
virDomainAuditHostdev(vm, hostdev, "detach", true);
if (!virHostdevIsVFIODevice(hostdev) &&
if (!virHostdevIsPCIDevice(hostdev) &&
qemuSecurityRestoreHostdevLabel(driver, vm, hostdev) < 0)
VIR_WARN("Failed to restore host device labelling");