From patchwork Sun Oct 2 20:50:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 677554 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 3snHkS3KNrz9s5g for ; Mon, 3 Oct 2016 08:05:04 +1100 (AEDT) Received: from localhost ([::1]:60847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqnwT-00021v-9M for incoming@patchwork.ozlabs.org; Sun, 02 Oct 2016 17:05:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqnif-0007hg-6v for qemu-devel@nongnu.org; Sun, 02 Oct 2016 16:50:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bqnid-0004Zn-0v for qemu-devel@nongnu.org; Sun, 02 Oct 2016 16:50:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqnic-0004Za-NU for qemu-devel@nongnu.org; Sun, 02 Oct 2016 16:50:42 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 3659167EB4; Sun, 2 Oct 2016 20:50:42 +0000 (UTC) Received: from localhost.redhat.com (vpn1-6-108.ams2.redhat.com [10.36.6.108]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u92KoHtl032661; Sun, 2 Oct 2016 16:50:40 -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: Sun, 2 Oct 2016 20:50:08 +0000 Message-Id: <1475441414-3118-11-git-send-email-eric.auger@redhat.com> In-Reply-To: <1475441414-3118-1-git-send-email-eric.auger@redhat.com> References: <1475441414-3118-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 02 Oct 2016 20:50:42 +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 v3 10/16] vfio/platform: Pass an error object to vfio_populate_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" Propagate the vfio_populate_device errors up to vfio_base_device_init. The error object also is passed to vfio_init_intp. At the moment we only report the error. Subsequent patches will propagate the error up to the realize function. Signed-off-by: Eric Auger --- hw/vfio/platform.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 9014ea7..1a35da0 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -44,9 +44,10 @@ static inline bool vfio_irq_is_automasked(VFIOINTp *intp) * and add it into the list of IRQs * @vbasedev: the VFIO device handle * @info: irq info struct retrieved from VFIO driver + * @errp: error object */ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, - struct vfio_irq_info info) + struct vfio_irq_info info, Error **errp) { int ret; VFIOPlatformDevice *vdev = @@ -69,7 +70,8 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, if (ret) { g_free(intp->interrupt); g_free(intp); - error_report("vfio: Error: trigger event_notifier_init failed "); + error_setg_errno(errp, -ret, + "failed to initialize trigger eventd notifier"); return NULL; } if (vfio_irq_is_automasked(intp)) { @@ -80,7 +82,8 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, g_free(intp->interrupt); g_free(intp->unmask); g_free(intp); - error_report("vfio: Error: resamplefd event_notifier_init failed"); + error_setg_errno(errp, -ret, + "failed to initialize resample eventd notifier"); return NULL; } } @@ -456,9 +459,10 @@ static int vfio_platform_hot_reset_multi(VFIODevice *vbasedev) * vfio_populate_device - Allocate and populate MMIO region * and IRQ structs according to driver returned information * @vbasedev: the VFIO device handle + * @errp: error object * */ -static int vfio_populate_device(VFIODevice *vbasedev) +static int vfio_populate_device(VFIODevice *vbasedev, Error **errp) { VFIOINTp *intp, *tmp; int i, ret = -1; @@ -466,7 +470,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) container_of(vbasedev, VFIOPlatformDevice, vbasedev); if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) { - error_report("vfio: Um, this isn't a platform device"); + error_setg(errp, "this isn't a platform device"); return ret; } @@ -480,7 +484,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) vdev->regions[i], i, name); g_free(name); if (ret) { - error_report("vfio: Error getting region %d info: %m", i); + error_setg_errno(errp, -ret, "failed to get region %d info", i); goto reg_error; } } @@ -496,16 +500,14 @@ static int vfio_populate_device(VFIODevice *vbasedev) irq.index = i; ret = ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, &irq); if (ret) { - error_report("vfio: error getting device %s irq info", - vbasedev->name); + error_setg_errno(errp, -ret, "failed to get device irq info"); goto irq_err; } else { trace_vfio_platform_populate_interrupts(irq.index, irq.count, irq.flags); - intp = vfio_init_intp(vbasedev, irq); + intp = vfio_init_intp(vbasedev, irq, errp); if (!intp) { - error_report("vfio: Error installing IRQ %d up", i); goto irq_err; } } @@ -613,9 +615,8 @@ static int vfio_base_device_init(VFIODevice *vbasedev) goto error; } - ret = vfio_populate_device(vbasedev); + ret = vfio_populate_device(vbasedev, &err); if (ret) { - error_report("vfio: failed to populate device %s", vbasedev->name); vfio_put_group(group); }