mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
vfio/platform: Pass an error object to vfio_populate_device
Propagate the vfio_populate_device errors up to vfio_base_device_init. The error object also is passed to vfio_init_intp. At the moment we only report the error. Subsequent patches will propagate the error up to the realize function. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
59f7d6743c
commit
5ff7419d4c
1 changed files with 13 additions and 12 deletions
|
@ -44,9 +44,10 @@ static inline bool vfio_irq_is_automasked(VFIOINTp *intp)
|
||||||
* and add it into the list of IRQs
|
* and add it into the list of IRQs
|
||||||
* @vbasedev: the VFIO device handle
|
* @vbasedev: the VFIO device handle
|
||||||
* @info: irq info struct retrieved from VFIO driver
|
* @info: irq info struct retrieved from VFIO driver
|
||||||
|
* @errp: error object
|
||||||
*/
|
*/
|
||||||
static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
|
static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
|
||||||
struct vfio_irq_info info)
|
struct vfio_irq_info info, Error **errp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
VFIOPlatformDevice *vdev =
|
VFIOPlatformDevice *vdev =
|
||||||
|
@ -69,7 +70,8 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
|
||||||
if (ret) {
|
if (ret) {
|
||||||
g_free(intp->interrupt);
|
g_free(intp->interrupt);
|
||||||
g_free(intp);
|
g_free(intp);
|
||||||
error_report("vfio: Error: trigger event_notifier_init failed ");
|
error_setg_errno(errp, -ret,
|
||||||
|
"failed to initialize trigger eventd notifier");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (vfio_irq_is_automasked(intp)) {
|
if (vfio_irq_is_automasked(intp)) {
|
||||||
|
@ -80,7 +82,8 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
|
||||||
g_free(intp->interrupt);
|
g_free(intp->interrupt);
|
||||||
g_free(intp->unmask);
|
g_free(intp->unmask);
|
||||||
g_free(intp);
|
g_free(intp);
|
||||||
error_report("vfio: Error: resamplefd event_notifier_init failed");
|
error_setg_errno(errp, -ret,
|
||||||
|
"failed to initialize resample eventd notifier");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,9 +459,10 @@ static int vfio_platform_hot_reset_multi(VFIODevice *vbasedev)
|
||||||
* vfio_populate_device - Allocate and populate MMIO region
|
* vfio_populate_device - Allocate and populate MMIO region
|
||||||
* and IRQ structs according to driver returned information
|
* and IRQ structs according to driver returned information
|
||||||
* @vbasedev: the VFIO device handle
|
* @vbasedev: the VFIO device handle
|
||||||
|
* @errp: error object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int vfio_populate_device(VFIODevice *vbasedev)
|
static int vfio_populate_device(VFIODevice *vbasedev, Error **errp)
|
||||||
{
|
{
|
||||||
VFIOINTp *intp, *tmp;
|
VFIOINTp *intp, *tmp;
|
||||||
int i, ret = -1;
|
int i, ret = -1;
|
||||||
|
@ -466,7 +470,7 @@ static int vfio_populate_device(VFIODevice *vbasedev)
|
||||||
container_of(vbasedev, VFIOPlatformDevice, vbasedev);
|
container_of(vbasedev, VFIOPlatformDevice, vbasedev);
|
||||||
|
|
||||||
if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) {
|
if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) {
|
||||||
error_report("vfio: Um, this isn't a platform device");
|
error_setg(errp, "this isn't a platform device");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +484,7 @@ static int vfio_populate_device(VFIODevice *vbasedev)
|
||||||
vdev->regions[i], i, name);
|
vdev->regions[i], i, name);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_report("vfio: Error getting region %d info: %m", i);
|
error_setg_errno(errp, -ret, "failed to get region %d info", i);
|
||||||
goto reg_error;
|
goto reg_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,16 +500,14 @@ static int vfio_populate_device(VFIODevice *vbasedev)
|
||||||
irq.index = i;
|
irq.index = i;
|
||||||
ret = ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, &irq);
|
ret = ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, &irq);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_report("vfio: error getting device %s irq info",
|
error_setg_errno(errp, -ret, "failed to get device irq info");
|
||||||
vbasedev->name);
|
|
||||||
goto irq_err;
|
goto irq_err;
|
||||||
} else {
|
} else {
|
||||||
trace_vfio_platform_populate_interrupts(irq.index,
|
trace_vfio_platform_populate_interrupts(irq.index,
|
||||||
irq.count,
|
irq.count,
|
||||||
irq.flags);
|
irq.flags);
|
||||||
intp = vfio_init_intp(vbasedev, irq);
|
intp = vfio_init_intp(vbasedev, irq, errp);
|
||||||
if (!intp) {
|
if (!intp) {
|
||||||
error_report("vfio: Error installing IRQ %d up", i);
|
|
||||||
goto irq_err;
|
goto irq_err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,9 +615,8 @@ static int vfio_base_device_init(VFIODevice *vbasedev)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = vfio_populate_device(vbasedev);
|
ret = vfio_populate_device(vbasedev, &err);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_report("vfio: failed to populate device %s", vbasedev->name);
|
|
||||||
vfio_put_group(group);
|
vfio_put_group(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue