diff options
| author | John Levon <john.levon@nutanix.com> | 2025-05-07 16:20:06 +0100 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2025-05-09 12:42:28 +0200 |
| commit | a901682f53b51c07dc27aab7e30256855a2a1f2f (patch) | |
| tree | 03b8c4d33b72387927553ae4ab3c8e9e58c37a28 /hw/vfio/device.c | |
| parent | 1cab5a02ab8144aad2abd001835e49104e4aae0f (diff) | |
| download | focaccia-qemu-a901682f53b51c07dc27aab7e30256855a2a1f2f.tar.gz focaccia-qemu-a901682f53b51c07dc27aab7e30256855a2a1f2f.zip | |
vfio: add vfio_device_prepare()
Commonize some initialization code shared by the legacy and iommufd vfio implementations. Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: John Levon <john.levon@nutanix.com> Link: https://lore.kernel.org/qemu-devel/20250507152020.1254632-2-john.levon@nutanix.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio/device.c')
| -rw-r--r-- | hw/vfio/device.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/vfio/device.c b/hw/vfio/device.c index d625a7c4db..f3b9902d21 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -398,3 +398,17 @@ void vfio_device_detach(VFIODevice *vbasedev) } VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); } + +void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontainer, + struct vfio_device_info *info) +{ + vbasedev->num_irqs = info->num_irqs; + vbasedev->num_regions = info->num_regions; + vbasedev->flags = info->flags; + vbasedev->reset_works = !!(info->flags & VFIO_DEVICE_FLAGS_RESET); + + vbasedev->bcontainer = bcontainer; + QLIST_INSERT_HEAD(&bcontainer->device_list, vbasedev, container_next); + + QLIST_INSERT_HEAD(&vfio_device_list, vbasedev, global_next); +} |