mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
vfio/container: Move listener to base container
Move listener to base container. Also error and initialized fields are moved at the same time. No functional change intended. Signed-off-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.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
dc74a4b005
commit
c7b313d300
6 changed files with 74 additions and 73 deletions
|
@ -453,6 +453,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
|
|||
{
|
||||
struct vfio_info_cap_header *hdr;
|
||||
struct vfio_iommu_type1_info_cap_migration *cap_mig;
|
||||
VFIOContainerBase *bcontainer = &container->bcontainer;
|
||||
|
||||
hdr = vfio_get_iommu_info_cap(info, VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION);
|
||||
if (!hdr) {
|
||||
|
@ -467,7 +468,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
|
|||
* qemu_real_host_page_size to mark those dirty.
|
||||
*/
|
||||
if (cap_mig->pgsize_bitmap & qemu_real_host_page_size()) {
|
||||
container->bcontainer.dirty_pages_supported = true;
|
||||
bcontainer->dirty_pages_supported = true;
|
||||
container->max_dirty_bitmap_size = cap_mig->max_dirty_bitmap_size;
|
||||
container->dirty_pgsizes = cap_mig->pgsize_bitmap;
|
||||
}
|
||||
|
@ -558,7 +559,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|||
|
||||
container = g_malloc0(sizeof(*container));
|
||||
container->fd = fd;
|
||||
container->error = NULL;
|
||||
container->iova_ranges = NULL;
|
||||
bcontainer = &container->bcontainer;
|
||||
vfio_container_init(bcontainer, space, &vfio_legacy_ops);
|
||||
|
@ -621,25 +621,24 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|||
group->container = container;
|
||||
QLIST_INSERT_HEAD(&container->group_list, group, container_next);
|
||||
|
||||
container->listener = vfio_memory_listener;
|
||||
bcontainer->listener = vfio_memory_listener;
|
||||
memory_listener_register(&bcontainer->listener, bcontainer->space->as);
|
||||
|
||||
memory_listener_register(&container->listener, bcontainer->space->as);
|
||||
|
||||
if (container->error) {
|
||||
if (bcontainer->error) {
|
||||
ret = -1;
|
||||
error_propagate_prepend(errp, container->error,
|
||||
error_propagate_prepend(errp, bcontainer->error,
|
||||
"memory listener initialization failed: ");
|
||||
goto listener_release_exit;
|
||||
}
|
||||
|
||||
container->initialized = true;
|
||||
bcontainer->initialized = true;
|
||||
|
||||
return 0;
|
||||
listener_release_exit:
|
||||
QLIST_REMOVE(group, container_next);
|
||||
QLIST_REMOVE(bcontainer, next);
|
||||
vfio_kvm_device_del_group(group);
|
||||
memory_listener_unregister(&container->listener);
|
||||
memory_listener_unregister(&bcontainer->listener);
|
||||
if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU ||
|
||||
container->iommu_type == VFIO_SPAPR_TCE_IOMMU) {
|
||||
vfio_spapr_container_deinit(container);
|
||||
|
@ -674,7 +673,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
|
|||
* group.
|
||||
*/
|
||||
if (QLIST_EMPTY(&container->group_list)) {
|
||||
memory_listener_unregister(&container->listener);
|
||||
memory_listener_unregister(&bcontainer->listener);
|
||||
if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU ||
|
||||
container->iommu_type == VFIO_SPAPR_TCE_IOMMU) {
|
||||
vfio_spapr_container_deinit(container);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue