The iommu group number need not be fetched from the sysfs everytime as it remains constant. Fetch it once during allocation Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx> --- src/libvirt_private.syms | 1 + src/util/virpci.c | 11 +++++++++++ src/util/virpci.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a835f18..1e624fe 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1971,6 +1971,7 @@ virPCIDeviceNew; virPCIDeviceReattach; virPCIDeviceReattachInit; virPCIDeviceReset; +virPCIDeviceSetIommuGroup; virPCIDeviceSetManaged; virPCIDeviceSetRemoveSlot; virPCIDeviceSetReprobe; diff --git a/src/util/virpci.c b/src/util/virpci.c index 876da70..b03521c 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -75,6 +75,7 @@ struct _virPCIDevice { bool has_pm_reset; bool managed; char *stubDriver; + int iommuGroup; /* used by reattach function */ bool unbind_from_stub; @@ -1566,6 +1567,8 @@ virPCIDeviceNew(unsigned int domain, char *product = NULL; char *drvpath = NULL; char *driver = NULL; + virPCIDeviceAddress devAddr = { domain, bus, + slot, function }; if (VIR_ALLOC(dev) < 0) return NULL; @@ -1613,6 +1616,8 @@ virPCIDeviceNew(unsigned int domain, goto error; } + dev->iommuGroup = virPCIDeviceAddressGetIOMMUGroupNum(&devAddr); + if (virPCIDeviceGetDriverPathAndName(dev, &drvpath, &driver) < 0) goto cleanup; @@ -1726,6 +1731,12 @@ virPCIDeviceSetStubDriver(virPCIDevicePtr dev, const char *driver) return VIR_STRDUP(dev->stubDriver, driver); } +void +virPCIDeviceSetIommuGroup(virPCIDevicePtr dev, int iommu) +{ + dev->iommuGroup = iommu; +} + const char * virPCIDeviceGetStubDriver(virPCIDevicePtr dev) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 64b9e96..a6c3628 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -87,6 +87,8 @@ int virPCIDeviceReset(virPCIDevicePtr dev, virPCIDeviceListPtr activeDevs, virPCIDeviceListPtr inactiveDevs); +void virPCIDeviceSetIommuGroup(virPCIDevice *dev, + int iommu); void virPCIDeviceSetManaged(virPCIDevice *dev, bool managed); unsigned int virPCIDeviceGetManaged(virPCIDevice *dev); -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list