From patchwork Mon Oct 3 12:41:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 677721 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 3snhnl4Rx2z9ryv for ; Mon, 3 Oct 2016 23:54:19 +1100 (AEDT) Received: from localhost ([::1]:36949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br2l6-0008RX-FH for incoming@patchwork.ozlabs.org; Mon, 03 Oct 2016 08:54:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br2Yv-000696-7C for qemu-devel@nongnu.org; Mon, 03 Oct 2016 08:41:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1br2Yt-00070L-1M for qemu-devel@nongnu.org; Mon, 03 Oct 2016 08:41:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br2Ys-000706-Ny for qemu-devel@nongnu.org; Mon, 03 Oct 2016 08:41:38 -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 3F93966C9B; Mon, 3 Oct 2016 12:41:38 +0000 (UTC) Received: from localhost.redhat.com (vpn1-5-72.ams2.redhat.com [10.36.5.72]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u93CfJGM008953; Mon, 3 Oct 2016 08:41:36 -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: Mon, 3 Oct 2016 12:41:10 +0000 Message-Id: <1475498477-2695-11-git-send-email-eric.auger@redhat.com> In-Reply-To: <1475498477-2695-1-git-send-email-eric.auger@redhat.com> References: <1475498477-2695-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.38]); Mon, 03 Oct 2016 12:41:38 +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 v4 10/17] vfio: Pass an error object to vfio_get_device 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" Pass an error object to prepare for migration to VFIO-PCI realize. In vfio platform vfio_base_device_init we currently just report the error. Subsequent patches will propagate the error up to the realize function. Signed-off-by: Eric Auger --- hw/vfio/common.c | 13 +++++++------ hw/vfio/pci.c | 3 +-- hw/vfio/platform.c | 5 ++--- include/hw/vfio/vfio-common.h | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 4749384..1757853 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1210,23 +1210,24 @@ void vfio_put_group(VFIOGroup *group) } int vfio_get_device(VFIOGroup *group, const char *name, - VFIODevice *vbasedev) + VFIODevice *vbasedev, Error **errp) { struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) }; int ret, fd; fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name); if (fd < 0) { - error_report("vfio: error getting device %s from group %d: %m", - name, group->groupid); - error_printf("Verify all devices in group %d are bound to vfio- " - "or pci-stub and not already in use\n", group->groupid); + error_setg_errno(errp, errno, "error getting device from group %d", + group->groupid); + error_append_hint(errp, + "Verify all devices in group %d are bound to vfio- " + "or pci-stub and not already in use\n", group->groupid); return fd; } ret = ioctl(fd, VFIO_DEVICE_GET_INFO, &dev_info); if (ret) { - error_report("vfio: error getting device info: %m"); + error_setg_errno(errp, errno, "error getting device info"); close(fd); return ret; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 910c371..40ff4a7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2578,9 +2578,8 @@ static int vfio_initfn(PCIDevice *pdev) } } - ret = vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev); + ret = vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev, &err); if (ret) { - error_setg_errno(&err, -ret, "failed to get device"); vfio_put_group(group); goto error; } diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 7bf525b..9014ea7 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -607,11 +607,10 @@ static int vfio_base_device_init(VFIODevice *vbasedev) return -EBUSY; } } - ret = vfio_get_device(group, vbasedev->name, vbasedev); + ret = vfio_get_device(group, vbasedev->name, vbasedev, &err); if (ret) { - error_report("vfio: failed to get device %s", vbasedev->name); vfio_put_group(group); - return ret; + goto error; } ret = vfio_populate_device(vbasedev); diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 286fa31..c582de1 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -158,7 +158,7 @@ void vfio_reset_handler(void *opaque); VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp); void vfio_put_group(VFIOGroup *group); int vfio_get_device(VFIOGroup *group, const char *name, - VFIODevice *vbasedev); + VFIODevice *vbasedev, Error **errp); extern const MemoryRegionOps vfio_region_ops; extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list;