diff mbox

[2/3] vfio: invoke looking up address space.

Message ID 1505156192-18994-3-git-send-email-wexu@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Xu Sept. 11, 2017, 6:56 p.m. UTC
From: Wei Xu <wexu@redhat.com>

Invoke looking up correct address space before getting an
IOMMU group.

Signed-off-by: Wei Xu <wexu@redhat.com>
---
 hw/vfio/pci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 31e1edf..856cefd 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2640,6 +2640,7 @@  static void vfio_realize(PCIDevice *pdev, Error **errp)
     struct stat st;
     int groupid;
     int i, ret;
+    AddressSpace *as;
 
     if (!vdev->vbasedev.sysfsdev) {
         if (!(~vdev->host.domain || ~vdev->host.bus ||
@@ -2686,7 +2687,12 @@  static void vfio_realize(PCIDevice *pdev, Error **errp)
 
     trace_vfio_realize(vdev->vbasedev.name, groupid);
 
-    group = vfio_get_group(groupid, pci_device_iommu_address_space(pdev), errp);
+    as = vfio_lookup_as(groupid, pdev, errp);
+    if (!as) {
+        goto error;
+    }
+
+    group = vfio_get_group(groupid, as, errp);
     if (!group) {
         goto error;
     }