mirror of https://github.com/xemu-project/xemu.git
vfio/common: Introduce vfio_container_init/destroy helper
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 functional change intended. Suggested-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
b08501a999
commit
ed2f7f8017
|
@ -30,3 +30,12 @@ int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
|
||||||
g_assert(bcontainer->ops->dma_unmap);
|
g_assert(bcontainer->ops->dma_unmap);
|
||||||
return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb);
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -559,7 +559,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
QLIST_INIT(&container->giommu_list);
|
QLIST_INIT(&container->giommu_list);
|
||||||
QLIST_INIT(&container->vrdl_list);
|
QLIST_INIT(&container->vrdl_list);
|
||||||
bcontainer = &container->bcontainer;
|
bcontainer = &container->bcontainer;
|
||||||
bcontainer->ops = &vfio_legacy_ops;
|
vfio_container_init(bcontainer, &vfio_legacy_ops);
|
||||||
|
|
||||||
ret = vfio_init_container(container, group->fd, errp);
|
ret = vfio_init_container(container, group->fd, errp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -661,6 +661,7 @@ put_space_exit:
|
||||||
static void vfio_disconnect_container(VFIOGroup *group)
|
static void vfio_disconnect_container(VFIOGroup *group)
|
||||||
{
|
{
|
||||||
VFIOContainer *container = group->container;
|
VFIOContainer *container = group->container;
|
||||||
|
VFIOContainerBase *bcontainer = &container->bcontainer;
|
||||||
|
|
||||||
QLIST_REMOVE(group, container_next);
|
QLIST_REMOVE(group, container_next);
|
||||||
group->container = NULL;
|
group->container = NULL;
|
||||||
|
@ -695,6 +696,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
|
||||||
QLIST_REMOVE(giommu, giommu_next);
|
QLIST_REMOVE(giommu, giommu_next);
|
||||||
g_free(giommu);
|
g_free(giommu);
|
||||||
}
|
}
|
||||||
|
vfio_container_destroy(bcontainer);
|
||||||
|
|
||||||
trace_vfio_disconnect_container(container->fd);
|
trace_vfio_disconnect_container(container->fd);
|
||||||
close(container->fd);
|
close(container->fd);
|
||||||
|
|
|
@ -38,6 +38,10 @@ int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
|
||||||
hwaddr iova, ram_addr_t size,
|
hwaddr iova, ram_addr_t size,
|
||||||
IOMMUTLBEntry *iotlb);
|
IOMMUTLBEntry *iotlb);
|
||||||
|
|
||||||
|
void vfio_container_init(VFIOContainerBase *bcontainer,
|
||||||
|
const VFIOIOMMUOps *ops);
|
||||||
|
void vfio_container_destroy(VFIOContainerBase *bcontainer);
|
||||||
|
|
||||||
struct VFIOIOMMUOps {
|
struct VFIOIOMMUOps {
|
||||||
/* basic feature */
|
/* basic feature */
|
||||||
int (*dma_map)(VFIOContainerBase *bcontainer,
|
int (*dma_map)(VFIOContainerBase *bcontainer,
|
||||||
|
|
Loading…
Reference in New Issue