From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjTXb-00087O-4J for qemu-devel@nongnu.org; Mon, 12 Sep 2016 11:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjTXV-0002vZ-Mg for qemu-devel@nongnu.org; Mon, 12 Sep 2016 11:53:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjTXV-0002vJ-GK for qemu-devel@nongnu.org; Mon, 12 Sep 2016 11:52:57 -0400 References: <1473145893-17088-1-git-send-email-eric.auger@redhat.com> <1473145893-17088-3-git-send-email-eric.auger@redhat.com> <87oa3txov2.fsf@dusky.pond.sub.org> <1730055d-17a9-6735-3e45-56cb53a3c4b8@redhat.com> <87twdlqfqc.fsf@dusky.pond.sub.org> From: Auger Eric Message-ID: <670110c3-4ef6-fac9-4910-47ed2a6f0f4f@redhat.com> Date: Mon, 12 Sep 2016 17:52:54 +0200 MIME-Version: 1.0 In-Reply-To: <87twdlqfqc.fsf@dusky.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/3] vfio/pci: pass an error object to vfio_populate_device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: alex.williamson@redhat.com, qemu-devel@nongnu.org, eric.auger.pro@gmail.com Hi Markus, On 12/09/2016 17:50, Markus Armbruster wrote: > Auger Eric writes: > >> Hi Markus, >> >> On 12/09/2016 14:51, Markus Armbruster wrote: >>> Eric Auger writes: >>> >>>> Let's expand the usage of QEMU Error objects to vfio_populate_device. >>>> >>>> Signed-off-by: Eric Auger >>>> --- >>>> hw/vfio/pci.c | 45 ++++++++++++++++++++------------------------- >>>> 1 file changed, 20 insertions(+), 25 deletions(-) >>>> >>>> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c >>>> index ae1967c..f7768e9 100644 >>>> --- a/hw/vfio/pci.c >>>> +++ b/hw/vfio/pci.c >>>> @@ -2197,7 +2197,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev) >>>> return 0; >>>> } >>>> >>>> -static int vfio_populate_device(VFIOPCIDevice *vdev) >>>> +static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) >>>> { >>>> VFIODevice *vbasedev = &vdev->vbasedev; >>>> struct vfio_region_info *reg_info; >>> struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) }; >>> int i, ret = -1; >>>> @@ -2206,19 +2206,19 @@ static int vfio_populate_device(VFIOPCIDevice *vdev) >>>> >>>> /* Sanity check device */ >>>> if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PCI)) { >>>> - error_report("vfio: Um, this isn't a PCI device"); >>>> - goto error; >>>> + error_setg(errp, "this isn't a PCI device"); >>>> + return; >>> >>> This is actually a bug fix :) >>> >>> Before your series, vfio_populate_device() returns negative errno on >>> some errors, and -1 on others. Its caller expects the former. >> >> Sorry but I don't get your comment. Who is the caller you refer to? > > Correction: its caller vfio_initfn() doesn't actually expect -errno. > Regardless, mixing -errno and -1 like vfio_populate_device() does in > master is in bad taste. So this isn't a bug fix, just a cleanup. > >>> Please mention the fix in the commit message. Fixing it in a separate >>> commit would also be fine, and possibly clearer. > > Mentioning the cleanup wouldn't hurt. OK Thanks! Eric > > [...] >