aboutsummaryrefslogtreecommitdiff
path: root/hw/vfio
diff options
context:
space:
mode:
authorCédric Le Goater <clg@redhat.com>2023-12-19 07:58:19 +0100
committerCédric Le Goater <clg@redhat.com>2024-01-05 21:25:20 +0100
commitfdaa774e67435a328c0e28006c4d749f2198294a (patch)
tree57847ace36a36aa938474f1c680641a990c611dd /hw/vfio
parentbffe92af0e7571868d47a1d1cd2205e13054d492 (diff)
vfio/container: Introduce a VFIOIOMMU QOM interface
VFIOContainerBase was not introduced as an abstract QOM object because it felt unnecessary to expose all the IOMMU backends to the QEMU machine and human interface. However, we can still abstract the IOMMU backend handlers using a QOM interface class. This provides more flexibility when referencing the various implementations. Simply transform the VFIOIOMMUOps struct in an InterfaceClass and do some initial name replacements. Next changes will start converting VFIOIOMMUOps. Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Tested-by: Eric Farman <farman@linux.ibm.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio')
-rw-r--r--hw/vfio/common.c2
-rw-r--r--hw/vfio/container-base.c12
-rw-r--r--hw/vfio/pci.c2
3 files changed, 13 insertions, 3 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 08a3e57672..49dab41566 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1503,7 +1503,7 @@ retry:
int vfio_attach_device(char *name, VFIODevice *vbasedev,
AddressSpace *as, Error **errp)
{
- const VFIOIOMMUOps *ops = &vfio_legacy_ops;
+ const VFIOIOMMUClass *ops = &vfio_legacy_ops;
#ifdef CONFIG_IOMMUFD
if (vbasedev->iommufd) {
diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c
index 1ffd25bbfa..913ae49077 100644
--- a/hw/vfio/container-base.c
+++ b/hw/vfio/container-base.c
@@ -72,7 +72,7 @@ int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
}
void vfio_container_init(VFIOContainerBase *bcontainer, VFIOAddressSpace *space,
- const VFIOIOMMUOps *ops)
+ const VFIOIOMMUClass *ops)
{
bcontainer->ops = ops;
bcontainer->space = space;
@@ -99,3 +99,13 @@ void vfio_container_destroy(VFIOContainerBase *bcontainer)
g_list_free_full(bcontainer->iova_ranges, g_free);
}
+
+static const TypeInfo types[] = {
+ {
+ .name = TYPE_VFIO_IOMMU,
+ .parent = TYPE_INTERFACE,
+ .class_size = sizeof(VFIOIOMMUClass),
+ },
+};
+
+DEFINE_TYPES(types)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 9f838978be..d7fe06715c 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2488,7 +2488,7 @@ int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev,
static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single)
{
VFIODevice *vbasedev = &vdev->vbasedev;
- const VFIOIOMMUOps *ops = vbasedev->bcontainer->ops;
+ const VFIOIOMMUClass *ops = vbasedev->bcontainer->ops;
return ops->pci_hot_reset(vbasedev, single);
}