From patchwork Mon Oct 17 19:53:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 9380483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45E5C607D4 for ; Mon, 17 Oct 2016 20:20:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E6228D74 for ; Mon, 17 Oct 2016 20:20:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27E4F28D77; Mon, 17 Oct 2016 20:20:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C73928D74 for ; Mon, 17 Oct 2016 20:20:10 +0000 (UTC) Received: from localhost ([::1]:35718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwEOH-0004Y0-KL for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Oct 2016 16:20:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwDyJ-00055f-TD for qemu-devel@nongnu.org; Mon, 17 Oct 2016 15:53:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwDyH-00007n-7O for qemu-devel@nongnu.org; Mon, 17 Oct 2016 15:53:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwDyG-000075-Vt for qemu-devel@nongnu.org; Mon, 17 Oct 2016 15:53:17 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 26C5BC04B927 for ; Mon, 17 Oct 2016 19:53:13 +0000 (UTC) Received: from gimli.home (ovpn-116-107.phx2.redhat.com [10.3.116.107]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9HJrCZ7002459; Mon, 17 Oct 2016 15:53:12 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 13:53:12 -0600 Message-ID: <20161017195310.17307.70877.stgit@gimli.home> In-Reply-To: <20161017194945.17307.78340.stgit@gimli.home> References: <20161017194945.17307.78340.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Oct 2016 19:53:13 +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] [PULL 10/19] 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: , Cc: Eric Auger , Markus Armbruster Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Auger 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 Reviewed-by: Markus Armbruster Signed-off-by: Alex Williamson --- 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 90b1ebb..9505fb3 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1211,23 +1211,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 fdb0616..0ba0711 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;