[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 09/41] vfio/common: Introduce vfio_container_init/destroy help
|
From: |
Zhenzhong Duan |
|
Subject: |
[PATCH v4 09/41] vfio/common: Introduce vfio_container_init/destroy helper |
|
Date: |
Thu, 2 Nov 2023 15:12:30 +0800 |
This adds two helper functions vfio_container_init/destroy which will be
used by both legacy and iommufd containers to do base container specific
initialization and release.
No fucntional change intended.
Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
include/hw/vfio/vfio-container-base.h | 4 ++++
hw/vfio/container-base.c | 9 +++++++++
hw/vfio/container.c | 4 +++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/hw/vfio/vfio-container-base.h
b/include/hw/vfio/vfio-container-base.h
index 56b033f59f..577f52ccbc 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -38,6 +38,10 @@ int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
hwaddr iova, ram_addr_t size,
IOMMUTLBEntry *iotlb);
+void vfio_container_init(VFIOContainerBase *bcontainer,
+ const VFIOIOMMUOps *ops);
+void vfio_container_destroy(VFIOContainerBase *bcontainer);
+
struct VFIOIOMMUOps {
/* basic feature */
int (*dma_map)(VFIOContainerBase *bcontainer,
diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c
index 55d3a35fa4..e929435751 100644
--- a/hw/vfio/container-base.c
+++ b/hw/vfio/container-base.c
@@ -30,3 +30,12 @@ int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
g_assert(bcontainer->ops->dma_unmap);
return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb);
}
+
+void vfio_container_init(VFIOContainerBase *bcontainer, const VFIOIOMMUOps
*ops)
+{
+ bcontainer->ops = ops;
+}
+
+void vfio_container_destroy(VFIOContainerBase *bcontainer)
+{
+}
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index c04df26323..32a0251dd1 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -559,7 +559,7 @@ static int vfio_connect_container(VFIOGroup *group,
AddressSpace *as,
QLIST_INIT(&container->giommu_list);
QLIST_INIT(&container->vrdl_list);
bcontainer = &container->bcontainer;
- bcontainer->ops = &vfio_legacy_ops;
+ vfio_container_init(bcontainer, &vfio_legacy_ops);
ret = vfio_init_container(container, group->fd, errp);
if (ret) {
@@ -661,6 +661,7 @@ put_space_exit:
static void vfio_disconnect_container(VFIOGroup *group)
{
VFIOContainer *container = group->container;
+ VFIOContainerBase *bcontainer = &container->bcontainer;
QLIST_REMOVE(group, container_next);
group->container = NULL;
@@ -695,6 +696,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
QLIST_REMOVE(giommu, giommu_next);
g_free(giommu);
}
+ vfio_container_destroy(bcontainer);
trace_vfio_disconnect_container(container->fd);
close(container->fd);
--
2.34.1
- [PATCH v4 03/41] vfio/container: Move spapr specific init/deinit into spapr.c, (continued)
- [PATCH v4 03/41] vfio/container: Move spapr specific init/deinit into spapr.c, Zhenzhong Duan, 2023/11/02
- [PATCH v4 04/41] vfio/spapr: Make vfio_spapr_create/remove_window static, Zhenzhong Duan, 2023/11/02
- [PATCH v4 05/41] vfio/common: Move vfio_host_win_add/del into spapr.c, Zhenzhong Duan, 2023/11/02
- [PATCH v4 06/41] vfio: Introduce base object for VFIOContainer and targeted interface, Zhenzhong Duan, 2023/11/02
- [PATCH v4 07/41] vfio/container: Introduce a empty VFIOIOMMUOps, Zhenzhong Duan, 2023/11/02
- [PATCH v4 08/41] vfio/container: Switch to dma_map|unmap API, Zhenzhong Duan, 2023/11/02
- [PATCH v4 09/41] vfio/common: Introduce vfio_container_init/destroy helper,
Zhenzhong Duan <=
- [PATCH v4 10/41] vfio/common: Move giommu_list in base container, Zhenzhong Duan, 2023/11/02
- [PATCH v4 11/41] vfio/container: Move space field to base container, Zhenzhong Duan, 2023/11/02
- [PATCH v4 12/41] vfio/container: Switch to IOMMU BE set_dirty_page_tracking/query_dirty_bitmap API, Zhenzhong Duan, 2023/11/02
- [PATCH v4 13/41] vfio/container: Move per container device list in base container, Zhenzhong Duan, 2023/11/02
- [PATCH v4 14/41] vfio/container: Convert functions to base container, Zhenzhong Duan, 2023/11/02
- [PATCH v4 15/41] vfio/container: Move pgsizes and dma_max_mappings to base container, Zhenzhong Duan, 2023/11/02