[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 09/16] vfio: Pass an error object to vfio_get_dev
From: |
Eric Auger |
Subject: |
[Qemu-devel] [PATCH v3 09/16] vfio: Pass an error object to vfio_get_device |
Date: |
Sun, 2 Oct 2016 20:50:07 +0000 |
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 <address@hidden>
---
hw/vfio/common.c | 13 +++++++------
hw/vfio/pci.c | 3 +--
hw/vfio/platform.c | 5 ++---
include/hw/vfio/vfio-common.h | 2 +-
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 0d33b56..096c99e 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1203,23 +1203,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 910c371..40ff4a7 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 7bf525b..9014ea7 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);
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 286fa31..c582de1 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -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;
--
1.9.1
- [Qemu-devel] [PATCH v3 02/16] vfio/pci: Pass an error object to vfio_populate_vga, (continued)
- [Qemu-devel] [PATCH v3 02/16] vfio/pci: Pass an error object to vfio_populate_vga, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 03/16] vfio/pci: Pass an error object to vfio_populate_device, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 06/16] vfio/pci: Pass an error object to vfio_add_capabilities, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 05/16] vfio/pci: Pass an error object to vfio_intx_enable, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 07/16] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 04/16] vfio/pci: Pass an error object to vfio_msix_early_setup, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 08/16] vfio: Pass an error object to vfio_get_group, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 11/16] vfio/platform: fix a wrong returned value in vfio_populate_device, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 10/16] vfio/platform: Pass an error object to vfio_populate_device, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 09/16] vfio: Pass an error object to vfio_get_device,
Eric Auger <=
- [Qemu-devel] [PATCH v3 12/16] vfio/platform: Pass an error object to vfio_base_device_init, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 14/16] vfio/pci: Remove vfio_msix_early_setup returned value, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 15/16] vfio/pci: Remove vfio_populate_device returned value, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 13/16] vfio/pci: Conversion to realize, Eric Auger, 2016/10/02
- [Qemu-devel] [PATCH v3 16/16] vfio/pci: Handle host oversight, Eric Auger, 2016/10/02