diff mbox

[16/16] pci-assign: assigned_initfn(): set monitor error in common error handler

Message ID 1397118285-11715-17-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek April 10, 2014, 8:24 a.m. UTC
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 hw/i386/kvm/pci-assign.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

Comments

Eric Blake April 29, 2014, 11:25 p.m. UTC | #1
On 04/10/2014 02:24 AM, Laszlo Ersek wrote:
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  hw/i386/kvm/pci-assign.c | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
Laszlo Ersek April 30, 2014, 12:35 a.m. UTC | #2
On 04/30/14 01:25, Eric Blake wrote:
> On 04/10/2014 02:24 AM, Laszlo Ersek wrote:
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>  hw/i386/kvm/pci-assign.c | 26 ++++++++++----------------
>>  1 file changed, 10 insertions(+), 16 deletions(-)
>>
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 

Your (surprisingly lenient! :)) review is greatly appreciated! Let's see
what maintainers say.

Thanks!
Laszlo
Luiz Capitulino May 7, 2014, 1:52 p.m. UTC | #3
On Wed, 30 Apr 2014 02:35:28 +0200
Laszlo Ersek <lersek@redhat.com> wrote:

> On 04/30/14 01:25, Eric Blake wrote:
> > On 04/10/2014 02:24 AM, Laszlo Ersek wrote:
> >> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> >> ---
> >>  hw/i386/kvm/pci-assign.c | 26 ++++++++++----------------
> >>  1 file changed, 10 insertions(+), 16 deletions(-)
> >>
> > 
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> > 
> 
> Your (surprisingly lenient! :)) review is greatly appreciated! Let's see
> what maintainers say.

Eric is a maintainer too.
Laszlo Ersek May 7, 2014, 3:17 p.m. UTC | #4
On 05/07/14 15:52, Luiz Capitulino wrote:
> On Wed, 30 Apr 2014 02:35:28 +0200
> Laszlo Ersek <lersek@redhat.com> wrote:
> 
>> On 04/30/14 01:25, Eric Blake wrote:
>>> On 04/10/2014 02:24 AM, Laszlo Ersek wrote:
>>>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>>>> ---
>>>>  hw/i386/kvm/pci-assign.c | 26 ++++++++++----------------
>>>>  1 file changed, 10 insertions(+), 16 deletions(-)
>>>>
>>>
>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>>
>>
>> Your (surprisingly lenient! :)) review is greatly appreciated! Let's see
>> what maintainers say.
> 
> Eric is a maintainer too.

(I'm aware; it was him referring to maintainers other than himself.)

Laszlo
diff mbox

Patch

diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index 6891729..e55421a 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -1754,18 +1754,18 @@  static int assigned_initfn(struct PCIDevice *pci_dev)
     uint8_t e_intx;
     int r;
     Error *local_err = NULL;
 
     if (!kvm_enabled()) {
-        error_report("pci-assign: error: requires KVM support");
-        return -1;
+        error_setg(&local_err, "pci-assign requires KVM support");
+        goto exit_with_error;
     }
 
     if (!dev->host.domain && !dev->host.bus && !dev->host.slot &&
         !dev->host.function) {
-        error_report("pci-assign: error: no host device specified");
-        return -1;
+        error_setg(&local_err, "no host device specified");
+        goto exit_with_error;
     }
 
     /*
      * Set up basic config space access control. Will be further refined during
      * device initialization.
@@ -1786,38 +1786,30 @@  static int assigned_initfn(struct PCIDevice *pci_dev)
     memcpy(dev->emulate_config_write, dev->emulate_config_read,
            sizeof(dev->emulate_config_read));
 
     get_real_device(dev, &local_err);
     if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
         goto out;
     }
 
     if (assigned_device_pci_cap_init(pci_dev, &local_err) < 0) {
-        qerror_report_err(local_err);
-        error_free(local_err);
         goto out;
     }
 
     /* intercept MSI-X entry page in the MMIO */
     if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) {
         assigned_dev_register_msix_mmio(dev, &local_err);
         if (local_err) {
-            qerror_report_err(local_err);
-            error_free(local_err);
             goto out;
         }
     }
 
     /* handle real device's MMIO/PIO BARs */
     assigned_dev_register_regions(dev->real_device.regions,
                                   dev->real_device.region_number, dev,
                                   &local_err);
     if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
         goto out;
     }
 
     /* handle interrupt routing */
     e_intx = dev->dev.config[PCI_INTERRUPT_PIN] - 1;
@@ -1826,20 +1818,16 @@  static int assigned_initfn(struct PCIDevice *pci_dev)
     dev->intx_route.irq = -1;
 
     /* assign device to guest */
     assign_device(dev, &local_err);
     if (local_err) {
-        qerror_report_err(local_err);
-        error_free(local_err);
         goto out;
     }
 
     /* assign legacy INTx to the device */
     r = assign_intx(dev, &local_err);
     if (r < 0) {
-        qerror_report_err(local_err);
-        error_free(local_err);
         goto assigned_out;
     }
 
     assigned_dev_load_option_rom(dev);
 
@@ -1847,12 +1835,18 @@  static int assigned_initfn(struct PCIDevice *pci_dev)
 
     return 0;
 
 assigned_out:
     deassign_device(dev);
+
 out:
     free_assigned_device(dev);
+
+exit_with_error:
+    assert(local_err);
+    qerror_report_err(local_err);
+    error_free(local_err);
     return -1;
 }
 
 static void assigned_exitfn(struct PCIDevice *pci_dev)
 {