summary refs log tree commit diff stats
path: root/hw/vfio/container.c
diff options
context:
space:
mode:
authorZhenzhong Duan <zhenzhong.duan@intel.com>2025-04-23 15:28:23 +0800
committerCédric Le Goater <clg@redhat.com>2025-04-25 09:01:38 +0200
commit0805f829a1aa07888fa7378f9421d37c521c4193 (patch)
treee39c6d3132eefd6e5f3b0a3cf6124b6cc2d370fe /hw/vfio/container.c
parent0327ffc8530e9733526fab6c790ad5f0661b008d (diff)
downloadfocaccia-qemu-0805f829a1aa07888fa7378f9421d37c521c4193.tar.gz
focaccia-qemu-0805f829a1aa07888fa7378f9421d37c521c4193.zip
vfio: Cleanup host IOMMU device creation
realize() is now moved after attachment, do the same for hiod creation.
Introduce a new function vfio_device_hiod_create_and_realize() to do
them all in one go.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250423072824.3647952-5-zhenzhong.duan@intel.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio/container.c')
-rw-r--r--hw/vfio/container.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index 652a6197ce..78f70e63d6 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -898,7 +898,9 @@ static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,
         goto group_put_exit;
     }
 
-    if (!vfio_device_hiod_realize(vbasedev, errp)) {
+    if (!vfio_device_hiod_create_and_realize(vbasedev,
+                                             TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO,
+                                             errp)) {
         goto device_put_exit;
     }
 
@@ -924,6 +926,7 @@ static void vfio_legacy_detach_device(VFIODevice *vbasedev)
     QLIST_REMOVE(vbasedev, container_next);
     vbasedev->bcontainer = NULL;
     trace_vfio_device_detach(vbasedev->name, group->groupid);
+    object_unref(vbasedev->hiod);
     vfio_device_put(vbasedev);
     vfio_group_put(group);
 }