@@ -46,6 +46,7 @@ struct VFIOContainer {
VFIOIOMMUBackendOpsClass *ops;
};
+#define TYPE_VFIO_IOMMU_BACKEND_LEGACY_OPS "vfio-iommu-backend-legacy-ops"
#define TYPE_VFIO_IOMMU_BACKEND_OPS "vfio-iommu-backend-ops"
DECLARE_CLASS_CHECKERS(VFIOIOMMUBackendOpsClass,
new file mode 100644
@@ -0,0 +1,40 @@
+/*
+ * VFIO BASE CONTAINER
+ *
+ * Copyright (C) 2023 Intel Corporation.
+ * Copyright Red Hat, Inc. 2023
+ *
+ * Authors: Yi Liu <yi.l.liu@intel.com>
+ * Eric Auger <eric.auger@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qemu/error-report.h"
+#include "hw/vfio/vfio-container-base.h"
+
+static const TypeInfo vfio_iommu_backend_ops_type_info = {
+ .name = TYPE_VFIO_IOMMU_BACKEND_OPS,
+ .parent = TYPE_OBJECT,
+ .abstract = true,
+ .class_size = sizeof(VFIOIOMMUBackendOpsClass),
+};
+
+static void vfio_iommu_backend_ops_register_types(void)
+{
+ type_register_static(&vfio_iommu_backend_ops_type_info);
+}
+type_init(vfio_iommu_backend_ops_register_types);
@@ -539,6 +539,9 @@ static void vfio_get_iommu_info_migration(VFIOLegacyContainer *container,
static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
Error **errp)
{
+ VFIOIOMMUBackendOpsClass *ops = VFIO_IOMMU_BACKEND_OPS_CLASS(
+ object_class_by_name(TYPE_VFIO_IOMMU_BACKEND_LEGACY_OPS));
+ VFIOContainer *bcontainer;
VFIOLegacyContainer *container;
int ret, fd;
VFIOAddressSpace *space;
@@ -620,6 +623,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
QLIST_INIT(&container->giommu_list);
QLIST_INIT(&container->hostwin_list);
QLIST_INIT(&container->vrdl_list);
+ bcontainer = &container->bcontainer;
+ bcontainer->ops = ops;
ret = vfio_init_container(container, group->fd, errp);
if (ret) {
@@ -1160,3 +1165,20 @@ void vfio_detach_device(VFIODevice *vbasedev)
vfio_put_base_device(vbasedev);
vfio_put_group(group);
}
+
+static void vfio_iommu_backend_legacy_ops_class_init(ObjectClass *oc,
+ void *data) {
+}
+
+static const TypeInfo vfio_iommu_backend_legacy_ops_type = {
+ .name = TYPE_VFIO_IOMMU_BACKEND_LEGACY_OPS,
+
+ .parent = TYPE_VFIO_IOMMU_BACKEND_OPS,
+ .class_init = vfio_iommu_backend_legacy_ops_class_init,
+ .abstract = true,
+};
+static void vfio_iommu_backend_legacy_ops_register_types(void)
+{
+ type_register_static(&vfio_iommu_backend_legacy_ops_type);
+}
+type_init(vfio_iommu_backend_legacy_ops_register_types);
@@ -2,6 +2,7 @@ vfio_ss = ss.source_set()
vfio_ss.add(files(
'helpers.c',
'common.c',
+ 'container-base.c',
'container.c',
'spapr.c',
'migration.c',