mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
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>
This commit is contained in:
parent
cdc6f2e0c9
commit
80936cf7f3
2 changed files with 11 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,7 @@ bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp);
|
|||
bool vfio_attach_device(char *name, VFIODevice *vbasedev,
|
||||
AddressSpace *as, Error **errp);
|
||||
void vfio_detach_device(VFIODevice *vbasedev);
|
||||
VFIODevice *vfio_get_vfio_device(Object *obj);
|
||||
|
||||
int vfio_kvm_device_add_fd(int fd, Error **errp);
|
||||
int vfio_kvm_device_del_fd(int fd, Error **errp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue