From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAIJ-0005ci-Qi 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 1WYAIA-0003QS-2j for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAI9-0003N2-Q5 for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:02 -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 s3A8P1rP012387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 10 Apr 2014 04:25:01 -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 s3A8OlIc005705 for ; Thu, 10 Apr 2014 04:25:00 -0400 From: Laszlo Ersek Date: Thu, 10 Apr 2014 10:24:41 +0200 Message-Id: <1397118285-11715-13-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 12/16] pci-assign: propagate errors from assigned_dev_register_msix_mmio() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The return type is also changed from "int" to "void", because it was used in a success vs. failure sense only (the caller didn't distinguish error codes from each other, and even assigned_dev_register_msix_mmio() masked mmap()'s errno values with a common -EFAULT). Signed-off-by: Laszlo Ersek --- hw/i386/kvm/pci-assign.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index 2de6559..3a904e8 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -1642,24 +1642,23 @@ static void assigned_dev_msix_reset(AssignedDevice *dev) for (i = 0, entry = dev->msix_table; i < dev->msix_max; i++, entry++) { entry->ctrl = cpu_to_le32(0x1); /* Masked */ } } -static int assigned_dev_register_msix_mmio(AssignedDevice *dev) +static void assigned_dev_register_msix_mmio(AssignedDevice *dev, Error **errp) { dev->msix_table = mmap(NULL, MSIX_PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0); if (dev->msix_table == MAP_FAILED) { - error_report("fail allocate msix_table! %s", strerror(errno)); - return -EFAULT; + error_setg_errno(errp, errno, "failed to allocate msix_table"); + return; } assigned_dev_msix_reset(dev); memory_region_init_io(&dev->mmio, OBJECT(dev), &assigned_dev_msix_mmio_ops, dev, "assigned-dev-msix", MSIX_PAGE_SIZE); - return 0; } static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev) { if (!dev->msix_table) { @@ -1786,11 +1785,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev) goto out; } /* intercept MSI-X entry page in the MMIO */ if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) { - if (assigned_dev_register_msix_mmio(dev)) { + 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 */ -- 1.8.3.1