qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger@redhat.com, eric.auger.pro@gmail.com,
	qemu-devel@nongnu.org, alex.williamson@redhat.com,
	armbru@redhat.com
Subject: [Qemu-devel] [PATCH v2 06/12] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init
Date: Tue, 20 Sep 2016 20:45:46 +0000	[thread overview]
Message-ID: <1474404352-28958-7-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1474404352-28958-1-git-send-email-eric.auger@redhat.com>

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(-)

diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index bec694c..57921de 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -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;
     }
 
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 07a44f5..f9a4fe7 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -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;
         }
     }
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 7d482d9..5336aa4 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -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 */
-- 
1.9.1

  parent reply	other threads:[~2016-09-20 20:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 20:45 [Qemu-devel] [PATCH v2 00/12] Convert VFIO-PCI to realize Eric Auger
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 01/12] vfio/pci: Use local error object in vfio_initfn Eric Auger
2016-09-22 15:42   ` Markus Armbruster
2016-09-30 13:35     ` Auger Eric
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 02/12] vfio/pci: Pass an error object to vfio_populate_device Eric Auger
2016-09-22 15:49   ` Markus Armbruster
2016-09-30 13:34     ` Auger Eric
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 03/12] vfio/pci: Pass an error object to vfio_msix_early_setup Eric Auger
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 04/12] vfio/pci: Pass an error object to vfio_intx_enable Eric Auger
2016-09-22 16:27   ` Markus Armbruster
2016-09-30 13:33     ` Auger Eric
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 05/12] vfio/pci: Pass an error object to vfio_add_capabilities Eric Auger
2016-09-22 16:52   ` Markus Armbruster
2016-09-30 13:33     ` Auger Eric
2016-09-20 20:45 ` Eric Auger [this message]
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 07/12] vfio: Pass an error object to vfio_get_group Eric Auger
2016-09-22 17:01   ` Markus Armbruster
2016-09-30 13:34     ` Auger Eric
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 08/12] vfio: Pass an error object to vfio_get_device Eric Auger
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 09/12] vfio/pci: Conversion to realize Eric Auger
2016-09-22 17:24   ` Markus Armbruster
2016-09-30 13:34     ` Auger Eric
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 10/12] vfio/pci: Remove vfio_msix_early_setup returned value Eric Auger
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 11/12] vfio/pci: Remove vfio_populate_device " Eric Auger
2016-09-20 20:45 ` [Qemu-devel] [PATCH v2 12/12] vfio/pci: Handle host oversight Eric Auger
2016-09-22 17:26 ` [Qemu-devel] [PATCH v2 00/12] Convert VFIO-PCI to realize Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474404352-28958-7-git-send-email-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).