]> Git Repo - qemu.git/commitdiff
vfio: Pass an error object to vfio_get_device
authorEric Auger <[email protected]>
Mon, 17 Oct 2016 16:58:00 +0000 (10:58 -0600)
committerAlex Williamson <[email protected]>
Mon, 17 Oct 2016 16:58:00 +0000 (10:58 -0600)
Pass an error object to prepare for migration to VFIO-PCI realize.

In vfio platform vfio_base_device_init we currently just report the
error. Subsequent patches will propagate the error up to the realize
function.

Signed-off-by: Eric Auger <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Alex Williamson <[email protected]>
hw/vfio/common.c
hw/vfio/pci.c
hw/vfio/platform.c
include/hw/vfio/vfio-common.h

index 90b1ebba2ceefc4d53543f3c90ffe961f14c9b22..9505fb30408d452dd77f322a6d6b9bd28aa3e312 100644 (file)
@@ -1211,23 +1211,24 @@ void vfio_put_group(VFIOGroup *group)
 }
 
 int vfio_get_device(VFIOGroup *group, const char *name,
-                       VFIODevice *vbasedev)
+                    VFIODevice *vbasedev, Error **errp)
 {
     struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
     int ret, fd;
 
     fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name);
     if (fd < 0) {
-        error_report("vfio: error getting device %s from group %d: %m",
-                     name, group->groupid);
-        error_printf("Verify all devices in group %d are bound to vfio-<bus> "
-                     "or pci-stub and not already in use\n", group->groupid);
+        error_setg_errno(errp, errno, "error getting device from group %d",
+                         group->groupid);
+        error_append_hint(errp,
+                      "Verify all devices in group %d are bound to vfio-<bus> "
+                      "or pci-stub and not already in use\n", group->groupid);
         return fd;
     }
 
     ret = ioctl(fd, VFIO_DEVICE_GET_INFO, &dev_info);
     if (ret) {
-        error_report("vfio: error getting device info: %m");
+        error_setg_errno(errp, errno, "error getting device info");
         close(fd);
         return ret;
     }
index fdb0616f8d15e0d113e06e7daafd1155127a2958..0ba071172b0d5b58960b67166593721959674bfa 100644 (file)
@@ -2578,9 +2578,8 @@ static int vfio_initfn(PCIDevice *pdev)
         }
     }
 
-    ret = vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev);
+    ret = vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev, &err);
     if (ret) {
-        error_setg_errno(&err, -ret, "failed to get device");
         vfio_put_group(group);
         goto error;
     }
index 7bf525b918ed2ed3d9e285bd65387a5adfc20ce6..9014ea740225da9c8def294504d56858c0317b35 100644 (file)
@@ -607,11 +607,10 @@ static int vfio_base_device_init(VFIODevice *vbasedev)
             return -EBUSY;
         }
     }
-    ret = vfio_get_device(group, vbasedev->name, vbasedev);
+    ret = vfio_get_device(group, vbasedev->name, vbasedev, &err);
     if (ret) {
-        error_report("vfio: failed to get device %s", vbasedev->name);
         vfio_put_group(group);
-        return ret;
+        goto error;
     }
 
     ret = vfio_populate_device(vbasedev);
index 286fa3129007082d8d655fee0393a4879f238aa3..c582de18c9b2a25944ad93dd1e7eda3f6d5037c0 100644 (file)
@@ -158,7 +158,7 @@ void vfio_reset_handler(void *opaque);
 VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp);
 void vfio_put_group(VFIOGroup *group);
 int vfio_get_device(VFIOGroup *group, const char *name,
-                    VFIODevice *vbasedev);
+                    VFIODevice *vbasedev, Error **errp);
 
 extern const MemoryRegionOps vfio_region_ops;
 extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list;
This page took 0.037572 seconds and 4 git commands to generate.