From: Zhenzhong Duan <zhenzhong.d...@intel.com>

The nested IOMMU support needs device and hwpt id which are generated
only after attachment. Hiod encapsulates these information in realize()
and passes to vIOMMU.

Suggested-by: Cédric Le Goater <c...@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
Reviewed-by: Cédric Le Goater <c...@redhat.com>
Link: 
https://lore.kernel.org/qemu-devel/20250521110301.3313877-1-zhenzhong.d...@intel.com
Signed-off-by: Cédric Le Goater <c...@redhat.com>
---
 hw/vfio/iommufd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 
af1c7ab10a090a2a4a2913231fc50903be9fb0f1..6b2696793f82fd68c306b85407b5f98201b9f5c6
 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -592,6 +592,10 @@ found_container:
         goto err_listener_register;
     }
 
+    /*
+     * Do not move this code before attachment! The nested IOMMU support
+     * needs device and hwpt id which are generated only after attachment.
+     */
     if (!vfio_device_hiod_create_and_realize(vbasedev,
                      TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, errp)) {
         goto err_listener_register;
-- 
2.49.0


Reply via email to