[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/21] vfio/common: Store the parent container in VFIODevice
|
From: |
Cédric Le Goater |
|
Subject: |
[PULL 19/21] vfio/common: Store the parent container in VFIODevice |
|
Date: |
Fri, 6 Oct 2023 08:20:03 +0200 |
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
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>
[ clg: Add test on !vbasedev->container in vfio_detach_device() ]
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/hw/vfio/vfio-common.h | 1 +
hw/vfio/common.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index
8ca70dd82156e25610fe96917843f334549818fe..bf12e406676e5577ad9454152aec9340666241dc
100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -132,6 +132,7 @@ typedef struct VFIODevice {
QLIST_ENTRY(VFIODevice) next;
QLIST_ENTRY(VFIODevice) container_next;
struct VFIOGroup *group;
+ VFIOContainer *container;
char *sysfsdev;
char *name;
DeviceState *dev;
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index
ef9dc7c74713f113a459db61aad7a017e21cf99a..55f8a113ea82afeb9620d46286f04f85dd9e8b54
100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -184,7 +184,7 @@ void vfio_unblock_multiple_devices_migration(void)
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)
@@ -2655,6 +2655,7 @@ int vfio_attach_device(char *name, VFIODevice *vbasedev,
}
container = group->container;
+ vbasedev->container = container;
QLIST_INSERT_HEAD(&container->device_list, vbasedev, container_next);
return ret;
@@ -2664,7 +2665,12 @@ void vfio_detach_device(VFIODevice *vbasedev)
{
VFIOGroup *group = vbasedev->group;
+ if (!vbasedev->container) {
+ return;
+ }
+
QLIST_REMOVE(vbasedev, container_next);
+ vbasedev->container = NULL;
trace_vfio_detach_device(vbasedev->name, group->groupid);
vfio_put_base_device(vbasedev);
vfio_put_group(group);
--
2.41.0
- [PULL 11/21] vfio/common: Introduce vfio_container_add|del_section_window(), (continued)
- [PULL 11/21] vfio/common: Introduce vfio_container_add|del_section_window(), Cédric Le Goater, 2023/10/06
- [PULL 12/21] vfio/common: Extract out vfio_kvm_device_[add/del]_fd, Cédric Le Goater, 2023/10/06
- [PULL 15/21] vfio/ap: Use vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 14/21] vfio/platform: Use vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 13/21] vfio/pci: Introduce vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 18/21] vfio/common: Introduce a per container device list, Cédric Le Goater, 2023/10/06
- [PULL 16/21] vfio/ccw: Use vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 21/21] vfio/common: Move legacy VFIO backend code into separate container.c, Cédric Le Goater, 2023/10/06
- [PULL 17/21] vfio/common: Move VFIO reset handler registration to a group agnostic function, Cédric Le Goater, 2023/10/06
- [PULL 20/21] vfio/common: Introduce a global VFIODevice list, Cédric Le Goater, 2023/10/06
- [PULL 19/21] vfio/common: Store the parent container in VFIODevice,
Cédric Le Goater <=
- Re: [PULL 00/21] vfio queue, Cédric Le Goater, 2023/10/06
- Re: [PULL 00/21] vfio queue, Eric Auger, 2023/10/06
- Re: [PULL 00/21] vfio queue, Eric Auger, 2023/10/06
- Re: [PULL 00/21] vfio queue, Eric Auger, 2023/10/06
- Re: [PULL 00/21] vfio queue, Cédric Le Goater, 2023/10/06
- Re: [PULL 00/21] vfio queue, Eric Auger, 2023/10/06
- Re: [PULL 00/21] vfio queue, Cédric Le Goater, 2023/10/07
- Re: [PULL 00/21] vfio queue, Michael Tokarev, 2023/10/07
Re: [PULL 00/21] vfio queue, Cédric Le Goater, 2023/10/09