From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAIC-0005Pk-7Z for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYAI5-0003LT-Tx for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:25:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYAI5-0003LH-Lr for qemu-devel@nongnu.org; Thu, 10 Apr 2014 04:24:57 -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 s3A8OvGH008309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 10 Apr 2014 04:24:57 -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 s3A8OlIY005705 for ; Thu, 10 Apr 2014 04:24:56 -0400 From: Laszlo Ersek Date: Thu, 10 Apr 2014 10:24:37 +0200 Message-Id: <1397118285-11715-9-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 08/16] pci-assign: accept Error from pci_add_capability2() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Propagate any errors while adding PCI capabilities to assigned_device_pci_cap_init(). We'll continue the propagation upwards when assigned_device_pci_cap_init() becomes a leaf itself (when none of its callees will report errors internally any longer when detecting and returning them). Signed-off-by: Laszlo Ersek --- hw/i386/kvm/pci-assign.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index b4696aa..f91d4fb 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -1261,12 +1261,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) error_free(local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; /* Only 32-bit/no-mask currently supported */ - ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSI, pos, 10, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } pci_dev->msi_cap = pos; pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS, @@ -1292,12 +1295,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) error_report("%s", error_get_pretty(local_err)); error_free(local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; - ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSIX, pos, 12, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } pci_dev->msix_cap = pos; pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS, @@ -1320,12 +1326,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) /* Minimal PM support, nothing writable, device appears to NAK changes */ pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0); if (pos) { uint16_t pmc; - ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF); @@ -1386,12 +1395,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) error_report("%s: Unsupported PCI express capability version %d", __func__, version); return -EINVAL; } - ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_EXP, pos, size, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, size); @@ -1460,12 +1472,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) if (pos) { uint16_t cmd; uint32_t status; /* Only expose the minimum, 8 byte capability */ - ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PCIX, pos, 8, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, 8); @@ -1486,12 +1501,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0); if (pos) { /* Direct R/W passthrough */ - ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VPD, pos, 8, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, 8); @@ -1502,12 +1520,15 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) /* Devices can have multiple vendor capabilities, get them all */ for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos)); pos += PCI_CAP_LIST_NEXT) { uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS); /* Direct R/W passthrough */ - ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len); + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VNDR, pos, len, + &local_err); if (ret < 0) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, len); -- 1.8.3.1