From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brPDu-0000cH-MY for qemu-devel@nongnu.org; Tue, 04 Oct 2016 08:53:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brPDq-0002Zz-N2 for qemu-devel@nongnu.org; Tue, 04 Oct 2016 08:53:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brPDq-0002Ye-Gq for qemu-devel@nongnu.org; Tue, 04 Oct 2016 08:53:26 -0400 From: Markus Armbruster References: <1475498477-2695-1-git-send-email-eric.auger@redhat.com> <1475498477-2695-14-git-send-email-eric.auger@redhat.com> Date: Tue, 04 Oct 2016 14:53:22 +0200 In-Reply-To: <1475498477-2695-14-git-send-email-eric.auger@redhat.com> (Eric Auger's message of "Mon, 3 Oct 2016 12:41:13 +0000") Message-ID: <87int8ff7h.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 13/17] vfio/platform: Pass an error object to vfio_base_device_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Auger Cc: eric.auger.pro@gmail.com, qemu-devel@nongnu.org, alex.williamson@redhat.com Eric Auger writes: > This patch propagates errors encountered during vfio_base_device_init > up to the realize function. > > Signed-off-by: Eric Auger > > --- > > v3: creation > --- > hw/vfio/platform.c | 49 ++++++++++++++++++++++++++----------------------- > 1 file changed, 26 insertions(+), 23 deletions(-) > > diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c > index 484e31f..fc06b45 100644 > --- a/hw/vfio/platform.c > +++ b/hw/vfio/platform.c > @@ -541,13 +541,14 @@ static VFIODeviceOps vfio_platform_ops = { > /** > * vfio_base_device_init - perform preliminary VFIO setup > * @vbasedev: the VFIO device handle > + * @errp: error object > * > * Implement the VFIO command sequence that allows to discover > * assigned device resources: group extraction, device > * fd retrieval, resource query. > * Precondition: the device name must be initialized > */ > -static int vfio_base_device_init(VFIODevice *vbasedev) > +static int vfio_base_device_init(VFIODevice *vbasedev, Error **errp) > { > VFIOGroup *group; > VFIODevice *vbasedev_iter; > @@ -555,7 +556,6 @@ static int vfio_base_device_init(VFIODevice *vbasedev) > ssize_t len; > struct stat st; > int groupid; > - Error *err = NULL; > int ret; > > /* @sysfsdev takes precedence over @host */ > @@ -564,6 +564,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev) > vbasedev->name = g_strdup(basename(vbasedev->sysfsdev)); > } else { > if (!vbasedev->name || strchr(vbasedev->name, '/')) { > + error_setg(errp, "wrong host device name"); Error is no longer silent. Worth mentioning in the commit message? > return -EINVAL; > } > > @@ -572,8 +573,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev) > } > > if (stat(vbasedev->sysfsdev, &st) < 0) { > - error_report("vfio: error: no such host device: %s", > - vbasedev->sysfsdev); > + error_setg_errno(errp, errno, "no such host device"); "no such host device" is correct and now redundant when errno is ENOENT, and misleading when it isn't. Suggest to rephrase the message. > return -errno; > } > [...]