From 005b8d10450d2d41e9c1bcf8da4085f23cb85b76 Mon Sep 17 00:00:00 2001 From: Cédric Le Goater Date: Wed, 26 Mar 2025 08:51:04 +0100 Subject: vfio: Move vfio_get_device_info() to helpers.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vfio_get_device_info() is a low level routine. Move it with the other helpers. Reviewed-by: Zhenzhong Duan Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-19-clg@redhat.com Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-20-clg@redhat.com Signed-off-by: Cédric Le Goater --- hw/vfio/helpers.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'hw/vfio/helpers.c') diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index e6b75baa80..b7f75b47af 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -312,6 +312,30 @@ int vfio_kvm_device_del_fd(int fd, Error **errp) return 0; } +struct vfio_device_info *vfio_get_device_info(int fd) +{ + struct vfio_device_info *info; + uint32_t argsz = sizeof(*info); + + info = g_malloc0(argsz); + +retry: + info->argsz = argsz; + + if (ioctl(fd, VFIO_DEVICE_GET_INFO, info)) { + g_free(info); + return NULL; + } + + if (info->argsz > argsz) { + argsz = info->argsz; + info = g_realloc(info, argsz); + goto retry; + } + + return info; +} + int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **info) { -- cgit 1.4.1