diff options
| author | Cédric Le Goater <clg@redhat.com> | 2025-02-06 14:14:32 +0100 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2025-02-11 14:15:19 +0100 |
| commit | 80936cf7f38e55f41bf5b482ee04f055c76a0df0 (patch) | |
| tree | 86d7717ead3d35f99821be3b8b43088c9f0a7806 /hw/vfio/helpers.c | |
| parent | cdc6f2e0c9fcef2027f4fc5f25ddd15e36283e90 (diff) | |
| download | focaccia-qemu-80936cf7f38e55f41bf5b482ee04f055c76a0df0.tar.gz focaccia-qemu-80936cf7f38e55f41bf5b482ee04f055c76a0df0.zip | |
vfio: Introduce vfio_get_vfio_device()
This helper will be useful in the listener handlers to extract the VFIO device from a memory region using memory_region_owner(). At the moment, we only care for PCI passthrough devices. If the need arises, we will add more. Reviewed-by: Alex Williamson <alex.williamson@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250206131438.1505542-5-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio/helpers.c')
| -rw-r--r-- | hw/vfio/helpers.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 913796f437..4b255d4f3a 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -23,6 +23,7 @@ #include <sys/ioctl.h> #include "hw/vfio/vfio-common.h" +#include "hw/vfio/pci.h" #include "hw/hw.h" #include "trace.h" #include "qapi/error.h" @@ -728,3 +729,12 @@ bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp) return HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp); } + +VFIODevice *vfio_get_vfio_device(Object *obj) +{ + if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) { + return &VFIO_PCI(obj)->vbasedev; + } else { + return NULL; + } +} |