diff mbox

[v4,07/17] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init

Message ID 1475498477-2695-8-git-send-email-eric.auger@redhat.com
State New
Headers show

Commit Message

Eric Auger Oct. 3, 2016, 12:41 p.m. UTC
Pass an error object to prepare for migration to VFIO-PCI realize.

In vfio_probe_igd_bar4_quirk, simply report the error.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 hw/vfio/pci-quirks.c | 10 +++++-----
 hw/vfio/pci.c        |  3 +--
 hw/vfio/pci.h        |  3 ++-
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Markus Armbruster Oct. 4, 2016, 11:56 a.m. UTC | #1
Eric Auger <eric.auger@redhat.com> writes:

> Pass an error object to prepare for migration to VFIO-PCI realize.
>
> In vfio_probe_igd_bar4_quirk, simply report the error.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>  hw/vfio/pci-quirks.c | 10 +++++-----
>  hw/vfio/pci.c        |  3 +--
>  hw/vfio/pci.h        |  3 ++-
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> index 806ea5d..2cbda08 100644
> --- a/hw/vfio/pci-quirks.c
> +++ b/hw/vfio/pci-quirks.c
> @@ -1056,7 +1056,7 @@ typedef struct VFIOIGDQuirk {
>   * of the IGD device.
>   */
>  int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
> -                               struct vfio_region_info *info)
> +                               struct vfio_region_info *info, Error **errp)
>  {
>      int ret;
>  
> @@ -1064,7 +1064,7 @@ 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;
> @@ -1489,10 +1489,10 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
>      }
>  
>      /* Setup OpRegion access */
> -    ret = vfio_pci_igd_opregion_init(vdev, opregion);
> +    ret = vfio_pci_igd_opregion_init(vdev, opregion, &err);
>      if (ret) {
> -        error_report("IGD device %s failed to setup OpRegion, "
> -                     "legacy mode disabled", vdev->vbasedev.name);
> +        error_append_hint(&err, "IGD legacy mode disabled\n");
> +        error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name);
>          goto out;
>      }
>  
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 7436248..3757bc3 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2721,10 +2721,9 @@ static int vfio_initfn(PCIDevice *pdev)
>              goto out_teardown;
>          }
>  
> -        ret = vfio_pci_igd_opregion_init(vdev, opregion);
> +        ret = vfio_pci_igd_opregion_init(vdev, opregion, &err);
>          g_free(opregion);
>          if (ret) {
> -            error_setg_errno(&err, -ret, "IGD OpRegion initialization failed");
>              goto out_teardown;
>          }
>      }
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index 87a62f9..198adac 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -164,6 +164,7 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
>  int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp);
>  
>  int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
> -                               struct vfio_region_info *info);
> +                                struct vfio_region_info *info,
> +                                Error **errp);
>  
>  #endif /* HW_VFIO_VFIO_PCI_H */

Indentation is off by one.  Could perhaps be touched up on commit.
diff mbox

Patch

diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 806ea5d..2cbda08 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1056,7 +1056,7 @@  typedef struct VFIOIGDQuirk {
  * of the IGD device.
  */
 int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
-                               struct vfio_region_info *info)
+                               struct vfio_region_info *info, Error **errp)
 {
     int ret;
 
@@ -1064,7 +1064,7 @@  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;
@@ -1489,10 +1489,10 @@  static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
     }
 
     /* Setup OpRegion access */
-    ret = vfio_pci_igd_opregion_init(vdev, opregion);
+    ret = vfio_pci_igd_opregion_init(vdev, opregion, &err);
     if (ret) {
-        error_report("IGD device %s failed to setup OpRegion, "
-                     "legacy mode disabled", vdev->vbasedev.name);
+        error_append_hint(&err, "IGD legacy mode disabled\n");
+        error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name);
         goto out;
     }
 
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 7436248..3757bc3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2721,10 +2721,9 @@  static int vfio_initfn(PCIDevice *pdev)
             goto out_teardown;
         }
 
-        ret = vfio_pci_igd_opregion_init(vdev, opregion);
+        ret = vfio_pci_igd_opregion_init(vdev, opregion, &err);
         g_free(opregion);
         if (ret) {
-            error_setg_errno(&err, -ret, "IGD OpRegion initialization failed");
             goto out_teardown;
         }
     }
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 87a62f9..198adac 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -164,6 +164,7 @@  void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev);
 int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp);
 
 int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
-                               struct vfio_region_info *info);
+                                struct vfio_region_info *info,
+                                Error **errp);
 
 #endif /* HW_VFIO_VFIO_PCI_H */