On 11/14/2015 03:35 AM, Shivaprasad G Bhat wrote:
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 <sb...@linux.vnet.ibm.com>
---
  src/util/virpci.c |    5 +++++
  1 file changed, 5 insertions(+)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index bff37d7..89e69e2 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;
@@ -1564,6 +1565,8 @@ virPCIDeviceNew(unsigned int domain,
      virPCIDevicePtr dev;
      char *vendor = NULL;
      char *product = NULL;
+    virPCIDeviceAddress devAddr = { domain, bus,
+                                    slot, function };

Ugh. Pre-existing, but virPCIDevice should have a single virPCIDeviceAddress instead of individual members for domain, bus, slot, and function. Then you wouldn't need to create a separate object just to send to virPCIDeviceAddressGetIOMMUGroupNum. That change would create a lot of diff lines though, so isn't appropriate for this patch.

Nothing dangerous about this (as long as we later do the right thing when iommuGroup is < 0). ACK

if (VIR_ALLOC(dev) < 0)
          return NULL;
@@ -1611,6 +1614,8 @@ virPCIDeviceNew(unsigned int domain,
          goto error;
      }
+ dev->iommuGroup = virPCIDeviceAddressGetIOMMUGroupNum(&devAddr);
+
      VIR_DEBUG("%s %s: initialized", dev->id, dev->name);
cleanup:

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to