[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 13/15] vfio/common: Store the parent container in VFIODevice
|
From: |
Eric Auger |
|
Subject: |
[PATCH v4 13/15] vfio/common: Store the parent container in VFIODevice |
|
Date: |
Wed, 4 Oct 2023 17:44:00 +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>
---
v3 -> v4:
- Dropped check on !vbasedev->container
---
include/hw/vfio/vfio-common.h | 1 +
hw/vfio/common.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 8ca70dd821..bf12e40667 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 ef9dc7c747..b14f04c9b0 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;
@@ -2665,6 +2666,7 @@ void vfio_detach_device(VFIODevice *vbasedev)
VFIOGroup *group = vbasedev->group;
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
- [PATCH v4 00/15] Prerequisite changes for IOMMUFD support, Eric Auger, 2023/10/04
- [PATCH v4 01/15] scripts/update-linux-headers: Add iommufd.h, Eric Auger, 2023/10/04
- [PATCH v4 03/15] vfio/common: Move IOMMU agnostic helpers to a separate file, Eric Auger, 2023/10/04
- [PATCH v4 02/15] linux-headers: Add iommufd.h, Eric Auger, 2023/10/04
- [PATCH v4 05/15] vfio/common: Introduce vfio_container_add|del_section_window(), Eric Auger, 2023/10/04
- [PATCH v4 04/15] vfio/common: Propagate KVM_SET_DEVICE_ATTR error if any, Eric Auger, 2023/10/04
- [PATCH v4 07/15] vfio/pci: Introduce vfio_[attach/detach]_device, Eric Auger, 2023/10/04
- [PATCH v4 08/15] vfio/platform: Use vfio_[attach/detach]_device, Eric Auger, 2023/10/04
- [PATCH v4 09/15] vfio/ap: Use vfio_[attach/detach]_device, Eric Auger, 2023/10/04
- [PATCH v4 11/15] vfio/common: Move VFIO reset handler registration to a group agnostic function, Eric Auger, 2023/10/04
- [PATCH v4 13/15] vfio/common: Store the parent container in VFIODevice,
Eric Auger <=
- [PATCH v4 12/15] vfio/common: Introduce a per container device list, Eric Auger, 2023/10/04
- [PATCH v4 06/15] vfio/common: Extract out vfio_kvm_device_[add/del]_fd, Eric Auger, 2023/10/04
- [PATCH v4 14/15] vfio/common: Introduce a global VFIODevice list, Eric Auger, 2023/10/04
- [PATCH v4 10/15] vfio/ccw: Use vfio_[attach/detach]_device, Eric Auger, 2023/10/04