From 469002263a295ec471c1498c3b456ccd9f85a841 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Thu, 10 Mar 2016 09:39:07 -0700 Subject: vfio: Wrap VFIO_DEVICE_GET_REGION_INFO In preparation for supporting capability chains on regions, wrap ioctl(VFIO_DEVICE_GET_REGION_INFO) so we don't duplicate the code for each caller. Signed-off-by: Alex Williamson --- hw/vfio/common.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'hw/vfio/common.c') diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 607ec70be3..e20fc4f794 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -959,6 +959,24 @@ void vfio_put_base_device(VFIODevice *vbasedev) close(vbasedev->fd); } +int vfio_get_region_info(VFIODevice *vbasedev, int index, + struct vfio_region_info **info) +{ + size_t argsz = sizeof(struct vfio_region_info); + + *info = g_malloc0(argsz); + + (*info)->index = index; + (*info)->argsz = argsz; + + if (ioctl(vbasedev->fd, VFIO_DEVICE_GET_REGION_INFO, *info)) { + g_free(*info); + return -errno; + } + + return 0; +} + static int vfio_container_do_ioctl(AddressSpace *as, int32_t groupid, int req, void *param) { -- cgit v1.2.3