From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAIJ-0005cW-CX for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYAID-0003bc-6K for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAIC-0003ab-UZ for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:05 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3A8P44v017088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 10 Apr 2014 04:25:04 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3A8OlIf005705 for ; Thu, 10 Apr 2014 04:25:03 -0400 From: Laszlo Ersek Date: Thu, 10 Apr 2014 10:24:44 +0200 Message-Id: <1397118285-11715-16-git-send-email-lersek@redhat.com> In-Reply-To: <1397118285-11715-1-git-send-email-lersek@redhat.com> References: <1397118285-11715-1-git-send-email-lersek@redhat.com> Subject: [Qemu-devel] [PATCH 15/16] pci-assign: propagate errors from assign_intx() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Among the callers, only assigned_initfn() should set the monitor's stored error. Other callers may run in contexts where the monitor's stored error makes no sense. For example: assigned_dev_pci_write_config() assigned_dev_update_msix() assign_intx() Signed-off-by: Laszlo Ersek --- hw/i386/kvm/pci-assign.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index 0fedca8..6891729 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -845,11 +845,11 @@ static void verify_irqchip_in_kernel(Error **errp) return; } error_setg(errp, "pci-assign requires KVM with in-kernel irqchip enabled"); } -static int assign_intx(AssignedDevice *dev) +static int assign_intx(AssignedDevice *dev, Error **errp) { AssignedIRQType new_type; PCIINTxRoute intx_route; bool intx_host_msi; int r; @@ -861,12 +861,11 @@ static int assign_intx(AssignedDevice *dev) return 0; } verify_irqchip_in_kernel(&local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); + error_propagate(errp, local_err); return -ENOTSUP; } pci_device_set_intx_routing_notifier(&dev->dev, assigned_dev_update_irq_routing); @@ -925,14 +924,15 @@ retry: "using MSI instead"); error_printf("Some devices do not work properly in this mode.\n"); dev->features |= ASSIGNED_DEVICE_PREFER_MSI_MASK; goto retry; } - error_report("Failed to assign irq for \"%s\": %s", - dev->dev.qdev.id, strerror(-r)); - error_report("Perhaps you are assigning a device " - "that shares an IRQ with another device?"); + error_setg_errno(errp, -r, + "Failed to assign irq for \"%s\"\n" + "Perhaps you are assigning a device " + "that shares an IRQ with another device?", + dev->dev.qdev.id); return r; } dev->intx_route = intx_route; dev->assigned_irq_type = new_type; @@ -954,12 +954,15 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev) { AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, dev); Error *err = NULL; int r; - r = assign_intx(assigned_dev); + r = assign_intx(assigned_dev, &err); if (r < 0) { + error_report("%s", error_get_pretty(err)); + error_free(err); + err = NULL; qdev_unplug(&dev->qdev, &err); assert(!err); } } @@ -1006,11 +1009,17 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev) assigned_dev->intx_route.mode = PCI_INTX_DISABLED; assigned_dev->intx_route.irq = -1; assigned_dev->assigned_irq_type = ASSIGNED_IRQ_MSI; } else { - assign_intx(assigned_dev); + Error *local_err = NULL; + + assign_intx(assigned_dev, &local_err); + if (local_err) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); + } } } static void assigned_dev_update_msi_msg(PCIDevice *pci_dev) { @@ -1148,11 +1157,17 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev) } assigned_dev->intx_route.mode = PCI_INTX_DISABLED; assigned_dev->intx_route.irq = -1; assigned_dev->assigned_irq_type = ASSIGNED_IRQ_MSIX; } else { - assign_intx(assigned_dev); + Error *local_err = NULL; + + assign_intx(assigned_dev, &local_err); + if (local_err) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); + } } } static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev, uint32_t address, int len) @@ -1817,12 +1832,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev) error_free(local_err); goto out; } /* assign legacy INTx to the device */ - r = assign_intx(dev); + 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); -- 1.8.3.1