mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
util: new function virPCIDeviceGetVFIOGroupDev
Given a virPCIDevice, this function returns the path for the device that controls the vfio group the device belongs to, e.g. "/dev/vfio/15".
This commit is contained in:
parent
d923f6c882
commit
b210208f97
@ -1609,6 +1609,7 @@ virPCIDeviceGetReprobe;
|
|||||||
virPCIDeviceGetStubDriver;
|
virPCIDeviceGetStubDriver;
|
||||||
virPCIDeviceGetUnbindFromStub;
|
virPCIDeviceGetUnbindFromStub;
|
||||||
virPCIDeviceGetUsedBy;
|
virPCIDeviceGetUsedBy;
|
||||||
|
virPCIDeviceGetVFIOGroupDev;
|
||||||
virPCIDeviceIsAssignable;
|
virPCIDeviceIsAssignable;
|
||||||
virPCIDeviceListAdd;
|
virPCIDeviceListAdd;
|
||||||
virPCIDeviceListCount;
|
virPCIDeviceListCount;
|
||||||
|
@ -1727,6 +1727,41 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* virPCIDeviceGetVFIOGroupDev - return the name of the device used to
|
||||||
|
* control this PCI device's group (e.g. "/dev/vfio/15")
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
virPCIDeviceGetVFIOGroupDev(virPCIDevicePtr dev)
|
||||||
|
{
|
||||||
|
char *devPath = NULL;
|
||||||
|
char *groupPath = NULL;
|
||||||
|
char *groupDev = NULL;
|
||||||
|
|
||||||
|
if (virPCIFile(&devPath, dev->name, "iommu_group") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
if (virFileIsLink(devPath) != 1) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Invalid device %s iommu_group file %s is not a symlink"),
|
||||||
|
dev->name, devPath);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (virFileResolveLink(devPath, &groupPath) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Unable to resolve device %s iommu_group symlink %s"),
|
||||||
|
dev->name, devPath);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (virAsprintf(&groupDev, "/dev/vfio/%s",
|
||||||
|
last_component(groupPath)) < 0) {
|
||||||
|
virReportOOMError();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(devPath);
|
||||||
|
VIR_FREE(groupPath);
|
||||||
|
return groupDev;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virPCIDeviceDownstreamLacksACS(virPCIDevicePtr dev)
|
virPCIDeviceDownstreamLacksACS(virPCIDevicePtr dev)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +111,8 @@ typedef int (*virPCIDeviceFileActor)(virPCIDevicePtr dev,
|
|||||||
int virPCIDeviceFileIterate(virPCIDevicePtr dev,
|
int virPCIDeviceFileIterate(virPCIDevicePtr dev,
|
||||||
virPCIDeviceFileActor actor,
|
virPCIDeviceFileActor actor,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
char *
|
||||||
|
virPCIDeviceGetVFIOGroupDev(virPCIDevicePtr dev);
|
||||||
|
|
||||||
int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
|
int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
|
||||||
int strict_acs_check);
|
int strict_acs_check);
|
||||||
|
Loading…
Reference in New Issue
Block a user