diff mbox series

[RFC,v4,16/24] vfio/as: Simplify vfio_viommu_preset()

Message ID 20230712072528.275577-17-zhenzhong.duan@intel.com (mailing list archive)
State New, archived
Headers show
Series vfio: Adopt iommufd | expand

Commit Message

Duan, Zhenzhong July 12, 2023, 7:25 a.m. UTC
Commit "vfio/container-base: Introduce [attach/detach]_device container callbacks"
add support to link to address space, we can utilize it to simplify
vfio_viommu_preset().

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/vfio/as.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/hw/vfio/as.c b/hw/vfio/as.c
index 0a2363f437..a7179403b7 100644
--- a/hw/vfio/as.c
+++ b/hw/vfio/as.c
@@ -161,22 +161,7 @@  void vfio_unblock_multiple_devices_migration(void)
 
 bool vfio_viommu_preset(VFIODevice *vbasedev)
 {
-    VFIOAddressSpace *space;
-    VFIOContainer *container;
-    VFIODevice *tmp_vbasedev;
-
-    QLIST_FOREACH(space, &vfio_address_spaces, list) {
-        QLIST_FOREACH(container, &space->containers, next) {
-            tmp_vbasedev = NULL;
-            while ((vbasedev = vfio_container_dev_iter_next(container,
-                                                            vbasedev))) {
-                if (vbasedev == tmp_vbasedev) {
-                    return space->as != &address_space_memory;
-                }
-            }
-        }
-    }
-    g_assert_not_reached();
+    return vbasedev->container->space->as != &address_space_memory;
 }
 
 static void vfio_set_migration_error(int err)