summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/vfio/common.c13
-rw-r--r--hw/vfio/pci.c3
-rw-r--r--hw/vfio/platform.c5
3 files changed, 10 insertions, 11 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 90b1ebba2c..9505fb3040 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -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;
}
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index fdb0616f8d..0ba071172b 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -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;
}
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 7bf525b918..9014ea7402 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -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);