From patchwork Tue Sep 6 07:11:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 666341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sSyYv3pfZz9ryZ for ; Tue, 6 Sep 2016 17:16:03 +1000 (AEST) Received: from localhost ([::1]:59553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhAbw-0008PR-86 for incoming@patchwork.ozlabs.org; Tue, 06 Sep 2016 03:16:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhAXr-0004dv-6Y for qemu-devel@nongnu.org; Tue, 06 Sep 2016 03:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhAXp-0004JM-1n for qemu-devel@nongnu.org; Tue, 06 Sep 2016 03:11:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhAXo-0004J0-Q1 for qemu-devel@nongnu.org; Tue, 06 Sep 2016 03:11:44 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BEB610796; Tue, 6 Sep 2016 07:11:44 +0000 (UTC) Received: from localhost.redhat.com (vpn1-7-38.ams2.redhat.com [10.36.7.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u867Ba9k016423; Tue, 6 Sep 2016 03:11:42 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, qemu-devel@nongnu.org, alex.williamson@redhat.com, armbru@redhat.com Date: Tue, 6 Sep 2016 07:11:33 +0000 Message-Id: <1473145893-17088-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1473145893-17088-1-git-send-email-eric.auger@redhat.com> References: <1473145893-17088-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 06 Sep 2016 07:11:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] vfio/pci: pass an error object to vfio_msix_early_setup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's expand the usage of QEMU Error objects to vfio_msix_early_setup. Signed-off-by: Eric Auger --- hw/vfio/pci.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index f7768e9..b132bf1 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1275,7 +1275,7 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev) * need to first look for where the MSI-X table lives. So we * unfortunately split MSI-X setup across two functions. */ -static int vfio_msix_early_setup(VFIOPCIDevice *vdev) +static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) { uint8_t pos; uint16_t ctrl; @@ -1285,22 +1285,25 @@ static int vfio_msix_early_setup(VFIOPCIDevice *vdev) pos = pci_find_capability(&vdev->pdev, PCI_CAP_ID_MSIX); if (!pos) { - return 0; + return; } if (pread(fd, &ctrl, sizeof(ctrl), vdev->config_offset + pos + PCI_MSIX_FLAGS) != sizeof(ctrl)) { - return -errno; + error_setg_errno(errp, -errno, "failed to read PCI MSIX FLAGS"); + return; } if (pread(fd, &table, sizeof(table), vdev->config_offset + pos + PCI_MSIX_TABLE) != sizeof(table)) { - return -errno; + error_setg_errno(errp, -errno, "failed to read PCI MSIX TABLE"); + return; } if (pread(fd, &pba, sizeof(pba), vdev->config_offset + pos + PCI_MSIX_PBA) != sizeof(pba)) { - return -errno; + error_setg_errno(errp, -errno, "failed to read PCI MSIX PBA"); + return; } ctrl = le16_to_cpu(ctrl); @@ -1330,10 +1333,11 @@ static int vfio_msix_early_setup(VFIOPCIDevice *vdev) (vdev->device_id & 0xff00) == 0x5800) { msix->pba_offset = 0x1000; } else { - error_report("vfio: Hardware reports invalid configuration, " - "MSIX PBA outside of specified BAR"); + error_setg_errno(errp, -EINVAL, + "hardware reports invalid configuration, " + "MSIX PBA outside of specified BAR"); g_free(msix); - return -EINVAL; + return; } } @@ -1343,7 +1347,7 @@ static int vfio_msix_early_setup(VFIOPCIDevice *vdev) vfio_pci_fixup_msix_region(vdev); - return 0; + return; } static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos) @@ -2642,9 +2646,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp) vfio_pci_size_rom(vdev); - ret = vfio_msix_early_setup(vdev); - if (ret) { - error_setg_errno(errp, ret, "msix early setup failure"); + vfio_msix_early_setup(vdev, &err); + if (err) { + error_propagate(errp, err); goto error; }