mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-20 00:22:02 -06:00
vfio/common: Store the parent container in VFIODevice
let's store the parent contaienr within the VFIODevice. This simplifies the logic in vfio_viommu_preset() and brings the benefice to hide the group specificity which is useful for IOMMUFD migration. Signed-off-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
7103ef7e76
commit
0bddd88027
2 changed files with 8 additions and 1 deletions
|
@ -184,7 +184,7 @@ void vfio_unblock_multiple_devices_migration(void)
|
||||||
|
|
||||||
bool vfio_viommu_preset(VFIODevice *vbasedev)
|
bool vfio_viommu_preset(VFIODevice *vbasedev)
|
||||||
{
|
{
|
||||||
return vbasedev->group->container->space->as != &address_space_memory;
|
return vbasedev->container->space->as != &address_space_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_set_migration_error(int err)
|
static void vfio_set_migration_error(int err)
|
||||||
|
@ -2655,6 +2655,7 @@ int vfio_attach_device(char *name, VFIODevice *vbasedev,
|
||||||
}
|
}
|
||||||
|
|
||||||
container = group->container;
|
container = group->container;
|
||||||
|
vbasedev->container = container;
|
||||||
QLIST_INSERT_HEAD(&container->device_list, vbasedev, container_next);
|
QLIST_INSERT_HEAD(&container->device_list, vbasedev, container_next);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2664,7 +2665,12 @@ void vfio_detach_device(VFIODevice *vbasedev)
|
||||||
{
|
{
|
||||||
VFIOGroup *group = vbasedev->group;
|
VFIOGroup *group = vbasedev->group;
|
||||||
|
|
||||||
|
if (!vbasedev->container) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QLIST_REMOVE(vbasedev, container_next);
|
QLIST_REMOVE(vbasedev, container_next);
|
||||||
|
vbasedev->container = NULL;
|
||||||
trace_vfio_detach_device(vbasedev->name, group->groupid);
|
trace_vfio_detach_device(vbasedev->name, group->groupid);
|
||||||
vfio_put_base_device(vbasedev);
|
vfio_put_base_device(vbasedev);
|
||||||
vfio_put_group(group);
|
vfio_put_group(group);
|
||||||
|
|
|
@ -132,6 +132,7 @@ typedef struct VFIODevice {
|
||||||
QLIST_ENTRY(VFIODevice) next;
|
QLIST_ENTRY(VFIODevice) next;
|
||||||
QLIST_ENTRY(VFIODevice) container_next;
|
QLIST_ENTRY(VFIODevice) container_next;
|
||||||
struct VFIOGroup *group;
|
struct VFIOGroup *group;
|
||||||
|
VFIOContainer *container;
|
||||||
char *sysfsdev;
|
char *sysfsdev;
|
||||||
char *name;
|
char *name;
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue