From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAII-0005aR-F7 for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYAIC-0003Xn-5o for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAIB-0003Vn-Ts for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:04 -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 s3A8P3UM017084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 10 Apr 2014 04:25:03 -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 s3A8OlIe005705 for ; Thu, 10 Apr 2014 04:25:02 -0400 From: Laszlo Ersek Date: Thu, 10 Apr 2014 10:24:43 +0200 Message-Id: <1397118285-11715-15-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 14/16] pci-assign: propagate errors from assign_device() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Also, change the return type to "void"; the function is static (with a sole caller) and the negative errno values are not distinguished from each other. Signed-off-by: Laszlo Ersek --- hw/i386/kvm/pci-assign.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index 9aa92a1..0fedca8 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -793,27 +793,27 @@ static char *assign_failed_examine(const AssignedDevice *dev) fail: return g_strdup("Couldn't find out why."); } -static int assign_device(AssignedDevice *dev) +static void assign_device(AssignedDevice *dev, Error **errp) { uint32_t flags = KVM_DEV_ASSIGN_ENABLE_IOMMU; int r; /* Only pass non-zero PCI segment to capable module */ if (!kvm_check_extension(kvm_state, KVM_CAP_PCI_SEGMENT) && dev->host.domain) { - error_report("Can't assign device inside non-zero PCI segment " - "as this KVM module doesn't support it."); - return -ENODEV; + error_setg(errp, "Can't assign device inside non-zero PCI segment " + "as this KVM module doesn't support it."); + return; } if (!kvm_check_extension(kvm_state, KVM_CAP_IOMMU)) { - error_report("No IOMMU found. Unable to assign device \"%s\"", - dev->dev.qdev.id); - return -ENODEV; + error_setg(errp, "No IOMMU found. Unable to assign device \"%s\"", + dev->dev.qdev.id); + return; } if (dev->features & ASSIGNED_DEVICE_SHARE_INTX_MASK && kvm_has_intx_set_mask()) { flags |= KVM_DEV_ASSIGN_PCI_2_3; @@ -824,22 +824,21 @@ static int assign_device(AssignedDevice *dev) switch (r) { case -EBUSY: { char *cause; cause = assign_failed_examine(dev); - error_report("Failed to assign device \"%s\" : %s\n%s", - dev->dev.qdev.id, strerror(-r), cause); + error_setg_errno(errp, -r, "Failed to assign device \"%s\"\n%s", + dev->dev.qdev.id, cause); g_free(cause); break; } default: - error_report("Failed to assign device \"%s\" : %s", - dev->dev.qdev.id, strerror(-r)); + error_setg_errno(errp, -r, "Failed to assign device \"%s\"", + dev->dev.qdev.id); break; } } - return r; } static void verify_irqchip_in_kernel(Error **errp) { if (kvm_irqchip_in_kernel()) { @@ -1810,12 +1809,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev) dev->intpin = e_intx; dev->intx_route.mode = PCI_INTX_DISABLED; dev->intx_route.irq = -1; /* assign device to guest */ - r = assign_device(dev); - if (r < 0) { + 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); -- 1.8.3.1