[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/28] vfio: add vfio_attach_device_by_iommu_type()
From: |
Cédric Le Goater |
Subject: |
[PULL 17/28] vfio: add vfio_attach_device_by_iommu_type() |
Date: |
Fri, 9 May 2025 15:13:06 +0200 |
From: John Levon <john.levon@nutanix.com>
Allow attachment by explicitly passing a TYPE_VFIO_IOMMU_* string;
vfio-user will use this later.
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
Link:
20250507152020.1254632-4-john.levon@nutanix.com">https://lore.kernel.org/qemu-devel/20250507152020.1254632-4-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/hw/vfio/vfio-device.h | 3 +++
hw/vfio/device.c | 22 +++++++++++++++-------
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h
index
342c4ba3bfec8d143a297203dbfa0e6f6fae3535..8b1437ba6654d08f65740f42dc3a50775d7f5cc1
100644
--- a/include/hw/vfio/vfio-device.h
+++ b/include/hw/vfio/vfio-device.h
@@ -127,6 +127,9 @@ bool vfio_device_hiod_create_and_realize(VFIODevice
*vbasedev,
const char *typename, Error **errp);
bool vfio_device_attach(char *name, VFIODevice *vbasedev,
AddressSpace *as, Error **errp);
+bool vfio_device_attach_by_iommu_type(const char *iommu_type, char *name,
+ VFIODevice *vbasedev, AddressSpace *as,
+ Error **errp);
void vfio_device_detach(VFIODevice *vbasedev);
VFIODevice *vfio_get_vfio_device(Object *obj);
diff --git a/hw/vfio/device.c b/hw/vfio/device.c
index
31c441a3dfffdf459994407904ab78b1798bf979..9673b0717ead435e117d8084720fde4ba3a13dd8
100644
--- a/hw/vfio/device.c
+++ b/hw/vfio/device.c
@@ -376,21 +376,29 @@ VFIODevice *vfio_get_vfio_device(Object *obj)
}
}
-bool vfio_device_attach(char *name, VFIODevice *vbasedev,
- AddressSpace *as, Error **errp)
+bool vfio_device_attach_by_iommu_type(const char *iommu_type, char *name,
+ VFIODevice *vbasedev, AddressSpace *as,
+ Error **errp)
{
const VFIOIOMMUClass *ops =
- VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY));
-
- if (vbasedev->iommufd) {
- ops = VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMMUFD));
- }
+ VFIO_IOMMU_CLASS(object_class_by_name(iommu_type));
assert(ops);
return ops->attach_device(name, vbasedev, as, errp);
}
+bool vfio_device_attach(char *name, VFIODevice *vbasedev,
+ AddressSpace *as, Error **errp)
+{
+ const char *iommu_type = vbasedev->iommufd ?
+ TYPE_VFIO_IOMMU_IOMMUFD :
+ TYPE_VFIO_IOMMU_LEGACY;
+
+ return vfio_device_attach_by_iommu_type(iommu_type, name, vbasedev,
+ as, errp);
+}
+
void vfio_device_detach(VFIODevice *vbasedev)
{
if (!vbasedev->bcontainer) {
--
2.49.0
- [PULL 23/28] vfio: implement unmap all for DMA unmap callbacks, (continued)
- [PULL 23/28] vfio: implement unmap all for DMA unmap callbacks, Cédric Le Goater, 2025/05/09
- [PULL 15/28] vfio: add vfio_device_prepare(), Cédric Le Goater, 2025/05/09
- [PULL 21/28] vfio: add vfio_pci_config_space_read/write(), Cédric Le Goater, 2025/05/09
- [PULL 22/28] vfio: add unmap_all flag to DMA unmap callback, Cédric Le Goater, 2025/05/09
- [PULL 24/28] vfio: add device IO ops vector, Cédric Le Goater, 2025/05/09
- [PULL 26/28] vfio: add read/write to device IO ops vector, Cédric Le Goater, 2025/05/09
- [PULL 28/28] vfio/container: pass listener_begin/commit callbacks, Cédric Le Goater, 2025/05/09
- [PULL 27/28] vfio: add vfio-pci-base class, Cédric Le Goater, 2025/05/09
- [PULL 25/28] vfio: add region info cache, Cédric Le Goater, 2025/05/09
- [PULL 20/28] vfio: add strread/writeerror(), Cédric Le Goater, 2025/05/09
- [PULL 17/28] vfio: add vfio_attach_device_by_iommu_type(),
Cédric Le Goater <=
- [PULL 18/28] vfio: add vfio_device_get_irq_info() helper, Cédric Le Goater, 2025/05/09
- Re: [PULL 00/28] vfio queue, Stefan Hajnoczi, 2025/05/10