mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
virhostdev.c: add virHostdevIsPCIDevice() helper
Add a helper to quickly determine if a hostdev is a PCI device, instead of doing a tedious 'if' check with hostdev mode and subsys type. Reviewed-by: Laine Stump <laine@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
953be56eea
commit
a8017c6882
@ -347,12 +347,18 @@ virHostdevNetDevice(virDomainHostdevDefPtr 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
|
static bool
|
||||||
virHostdevIsPCINetDevice(const virDomainHostdevDef *hostdev)
|
virHostdevIsPCINetDevice(const virDomainHostdevDef *hostdev)
|
||||||
{
|
{
|
||||||
return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
return virHostdevIsPCIDevice(hostdev) && hostdev->parentnet != NULL;
|
||||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
|
||||||
hostdev->parentnet != NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,3 +233,5 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManagerPtr hostdev_mgr,
|
|||||||
const char *dom_name,
|
const char *dom_name,
|
||||||
virDomainDiskDefPtr *disks,
|
virDomainDiskDefPtr *disks,
|
||||||
size_t ndisks);
|
size_t ndisks);
|
||||||
|
|
||||||
|
bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev);
|
||||||
|
@ -1526,6 +1526,7 @@ virCloseCallbacksUnset;
|
|||||||
|
|
||||||
# hypervisor/virhostdev.h
|
# hypervisor/virhostdev.h
|
||||||
virHostdevFindUSBDevice;
|
virHostdevFindUSBDevice;
|
||||||
|
virHostdevIsPCIDevice;
|
||||||
virHostdevManagerGetDefault;
|
virHostdevManagerGetDefault;
|
||||||
virHostdevPCINodeDeviceDetach;
|
virHostdevPCINodeDeviceDetach;
|
||||||
virHostdevPCINodeDeviceReAttach;
|
virHostdevPCINodeDeviceReAttach;
|
||||||
|
Loading…
Reference in New Issue
Block a user