@@ -1055,8 +1055,8 @@ typedef struct VFIOIGDQuirk {
* the table and to write the base address of that memory to the ASLS register
* of the IGD device.
*/
-int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
- struct vfio_region_info *info)
+void vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
+ struct vfio_region_info *info, Error **errp)
{
int ret;
@@ -1064,10 +1064,10 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
ret = pread(vdev->vbasedev.fd, vdev->igd_opregion,
info->size, info->offset);
if (ret != info->size) {
- error_report("vfio: Error reading IGD OpRegion");
+ error_setg(errp, "failed to read IGD OpRegion");
g_free(vdev->igd_opregion);
vdev->igd_opregion = NULL;
- return -EINVAL;
+ return;
}
/*
@@ -1091,8 +1091,6 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
pci_set_long(vdev->pdev.config + IGD_ASLS, 0);
pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0);
pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0);
-
- return 0;
}
/*
@@ -1363,6 +1361,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
uint64_t *bdsm_size;
uint32_t gmch;
uint16_t cmd_orig, cmd;
+ Error *err = NULL;
/*
* This must be an Intel VGA device at address 00:02.0 for us to even
@@ -1487,10 +1486,10 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
}
/* Setup OpRegion access */
- ret = vfio_pci_igd_opregion_init(vdev, opregion);
- if (ret) {
- error_report("IGD device %s failed to setup OpRegion, "
- "legacy mode disabled", vdev->vbasedev.name);
+ vfio_pci_igd_opregion_init(vdev, opregion, &err);
+ if (err) {
+ error_append_hint(&err, "IGD legacy mode disabled\n");
+ error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name);
goto out;
}
@@ -2720,10 +2720,10 @@ static int vfio_initfn(PCIDevice *pdev)
goto out_teardown;
}
- ret = vfio_pci_igd_opregion_init(vdev, opregion);
+ vfio_pci_igd_opregion_init(vdev, opregion, &err);
g_free(opregion);
- if (ret) {
- error_setg_errno(&err, -ret, "IGD OpRegion initialization failed");
+ if (err) {
+ ret = -EINVAL;
goto out_teardown;
}
}
@@ -163,7 +163,8 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
int vfio_populate_vga(VFIOPCIDevice *vdev);
-int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
- struct vfio_region_info *info);
+void vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
+ struct vfio_region_info *info,
+ Error **errp);
#endif /* HW_VFIO_VFIO_PCI_H */
Pass an error object to prepare for migration to VFIO-PCI realize. In vfio_probe_igd_bar4_quirk, simply report the error without propagating. Transform vfio_pci_igd_opregion_init into a void function. The -EINVAL returned value only is used in vfio_initfn and during migration to realize, this will not be used anymore. Signed-off-by: Eric Auger <eric.auger@redhat.com> --- hw/vfio/pci-quirks.c | 19 +++++++++---------- hw/vfio/pci.c | 6 +++--- hw/vfio/pci.h | 5 +++-- 3 files changed, 15 insertions(+), 15 deletions(-)