HostIOMMUDeviceIOMMUFDVFIO represents a host IOMMU device under VFIO iommufd backend. It will be created during VFIO device attaching and passed to vIOMMU.
It includes a link to VFIODevice so that we can do VFIO device specific operations, i.e., [at/de]taching hwpt, etc. Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> --- include/hw/vfio/vfio-common.h | 13 +++++++++++++ hw/vfio/iommufd.c | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index aa3abe0a18..0943add3bc 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -32,6 +32,7 @@ #include "sysemu/sysemu.h" #include "hw/vfio/vfio-container-base.h" #include "sysemu/host_iommu_device.h" +#include "sysemu/iommufd.h" #define VFIO_MSG_PREFIX "vfio %s: " @@ -159,6 +160,18 @@ struct HostIOMMUDeviceLegacyVFIO { VFIODevice *vdev; }; +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ + TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" +OBJECT_DECLARE_SIMPLE_TYPE(HostIOMMUDeviceIOMMUFDVFIO, + HOST_IOMMU_DEVICE_IOMMUFD_VFIO) + +/* Abstraction of host IOMMU device with VFIO IOMMUFD backend */ +struct HostIOMMUDeviceIOMMUFDVFIO { + HostIOMMUDeviceIOMMUFD parent; + + VFIODevice *vdev; +}; + typedef struct VFIODMABuf { QemuDmaBuf buf; uint32_t pos_x, pos_y, pos_updates; diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 8827ffe636..997f4ac43e 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -639,7 +639,11 @@ static const TypeInfo types[] = { .name = TYPE_VFIO_IOMMU_IOMMUFD, .parent = TYPE_VFIO_IOMMU, .class_init = vfio_iommu_iommufd_class_init, - }, + }, { + .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, + .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD, + .instance_size = sizeof(HostIOMMUDeviceIOMMUFDVFIO), + } }; DEFINE_TYPES(types) -- 2.34.1