The iommu group number need not be fetched from the sysfs everytime as it remains constant. Fetch it once during allocation. Add a helper to set the value to set it from tests. 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 be1b6de..f401e1d 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; @@ -1619,6 +1622,8 @@ virPCIDeviceNew(unsigned int domain, if (virPCIIsAKnownStub(driver)) dev->stubDriver = driver; + dev->iommuGroup = virPCIDeviceAddressGetIOMMUGroupNum(&devAddr); + VIR_DEBUG("%s %s: initialized", dev->id, dev->name); cleanup: @@ -1723,6 +1728,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