vfio/container: Move vfio_container_destroy() to an instance_finalize() handler
vfio_container_destroy() clears the resources allocated VFIOContainerBase object. Now that VFIOContainerBase is a QOM object, add an instance_finalize() handler to do the cleanup. It will be called through object_unref(). Suggested-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
b052f73cbe
commit
96b7af4388
@ -83,8 +83,9 @@ int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
|
||||
errp);
|
||||
}
|
||||
|
||||
void vfio_container_destroy(VFIOContainerBase *bcontainer)
|
||||
static void vfio_container_instance_finalize(Object *obj)
|
||||
{
|
||||
VFIOContainerBase *bcontainer = VFIO_IOMMU(obj);
|
||||
VFIOGuestIOMMU *giommu, *tmp;
|
||||
|
||||
QLIST_REMOVE(bcontainer, next);
|
||||
@ -116,6 +117,7 @@ static const TypeInfo types[] = {
|
||||
.name = TYPE_VFIO_IOMMU,
|
||||
.parent = TYPE_OBJECT,
|
||||
.instance_init = vfio_container_instance_init,
|
||||
.instance_finalize = vfio_container_instance_finalize,
|
||||
.instance_size = sizeof(VFIOContainerBase),
|
||||
.class_size = sizeof(VFIOIOMMUClass),
|
||||
.abstract = true,
|
||||
|
@ -712,8 +712,6 @@ static void vfio_disconnect_container(VFIOGroup *group)
|
||||
if (QLIST_EMPTY(&container->group_list)) {
|
||||
VFIOAddressSpace *space = bcontainer->space;
|
||||
|
||||
vfio_container_destroy(bcontainer);
|
||||
|
||||
trace_vfio_disconnect_container(container->fd);
|
||||
vfio_cpr_unregister_container(bcontainer);
|
||||
close(container->fd);
|
||||
|
@ -237,7 +237,6 @@ static void iommufd_cdev_container_destroy(VFIOIOMMUFDContainer *container)
|
||||
return;
|
||||
}
|
||||
memory_listener_unregister(&bcontainer->listener);
|
||||
vfio_container_destroy(bcontainer);
|
||||
iommufd_backend_free_id(container->be, container->ioas_id);
|
||||
object_unref(container);
|
||||
}
|
||||
|
@ -86,9 +86,6 @@ int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer,
|
||||
int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
|
||||
VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp);
|
||||
|
||||
void vfio_container_destroy(VFIOContainerBase *bcontainer);
|
||||
|
||||
|
||||
#define TYPE_VFIO_IOMMU "vfio-iommu"
|
||||
#define TYPE_VFIO_IOMMU_LEGACY TYPE_VFIO_IOMMU "-legacy"
|
||||
#define TYPE_VFIO_IOMMU_SPAPR TYPE_VFIO_IOMMU "-spapr"
|
||||
|
Loading…
Reference in New Issue
Block a user