aboutsummaryrefslogtreecommitdiff
path: root/hw/vfio/platform.c
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2016-03-10 09:39:07 -0700
committerAlex Williamson <alex.williamson@redhat.com>2016-03-10 09:39:07 -0700
commit469002263a295ec471c1498c3b456ccd9f85a841 (patch)
tree71ee90f35f8dc2d6887047e5cb07e4009301e01e /hw/vfio/platform.c
parent7df9381b7aa56c897e344f3bfe43bf5848bbd3e0 (diff)
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 <alex.williamson@redhat.com>
Diffstat (limited to 'hw/vfio/platform.c')
-rw-r--r--hw/vfio/platform.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 6c8b54a7c3..f9b9c207ee 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -476,23 +476,24 @@ static int vfio_populate_device(VFIODevice *vbasedev)
vdev->regions = g_new0(VFIORegion *, vbasedev->num_regions);
for (i = 0; i < vbasedev->num_regions; i++) {
- struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
+ struct vfio_region_info *reg_info;
VFIORegion *ptr;
vdev->regions[i] = g_new0(VFIORegion, 1);
ptr = vdev->regions[i];
- reg_info.index = i;
- ret = ioctl(vbasedev->fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info);
+ ret = vfio_get_region_info(vbasedev, i, &reg_info);
if (ret) {
error_report("vfio: Error getting region %d info: %m", i);
goto reg_error;
}
- ptr->flags = reg_info.flags;
- ptr->size = reg_info.size;
- ptr->fd_offset = reg_info.offset;
+ ptr->flags = reg_info->flags;
+ ptr->size = reg_info->size;
+ ptr->fd_offset = reg_info->offset;
ptr->nr = i;
ptr->vbasedev = vbasedev;
+ g_free(reg_info);
+
trace_vfio_platform_populate_regions(ptr->nr,
(unsigned long)ptr->flags,
(unsigned long)ptr->size,