It calls iommufd_backend_get_device_info() to get host IOMMU related information.
Define a common structure HIOD_IOMMUFD_INFO to describe the info returned from kernel. Currently only vtd, but easy to add arm smmu when kernel supports. Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> --- include/sysemu/iommufd.h | 7 +++++++ backends/iommufd.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/sysemu/iommufd.h b/include/sysemu/iommufd.h index fa1a866237..44ec1335b2 100644 --- a/include/sysemu/iommufd.h +++ b/include/sysemu/iommufd.h @@ -39,6 +39,13 @@ int iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid, enum iommu_hw_info_type *type, void *data, uint32_t len, Error **errp); +typedef struct HIOD_IOMMUFD_INFO { + enum iommu_hw_info_type type; + union { + struct iommu_hw_info_vtd vtd; + } data; +} HIOD_IOMMUFD_INFO; + #define TYPE_HIOD_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" OBJECT_DECLARE_TYPE(HIODIOMMUFD, HIODIOMMUFDClass, HIOD_IOMMUFD) diff --git a/backends/iommufd.c b/backends/iommufd.c index 559affa9ec..1e9c469e65 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -240,8 +240,25 @@ void hiod_iommufd_init(HIODIOMMUFD *idev, IOMMUFDBackend *iommufd, idev->devid = devid; } +static int hiod_iommufd_get_host_iommu_info(HostIOMMUDevice *hiod, + void *data, uint32_t len, + Error **errp) +{ + HIODIOMMUFD *idev = HIOD_IOMMUFD(hiod); + HIOD_IOMMUFD_INFO *info = data; + + assert(sizeof(HIOD_IOMMUFD_INFO) <= len); + + return iommufd_backend_get_device_info(idev->iommufd, idev->devid, + &info->type, &info->data, + sizeof(info->data), errp); +} + static void hiod_iommufd_class_init(ObjectClass *oc, void *data) { + HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc); + + hiodc->get_host_iommu_info = hiod_iommufd_get_host_iommu_info; } static const TypeInfo types[] = { -- 2.34.1