Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eD69Y-0002mf-8m for mharc-qemu-trivial@gnu.org; Fri, 10 Nov 2017 05:03:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eD69Q-0002im-IT for qemu-trivial@nongnu.org; Fri, 10 Nov 2017 05:03:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eD69K-00007a-3O for qemu-trivial@nongnu.org; Fri, 10 Nov 2017 05:03:04 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:16895) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eD69J-0008W6-P7; Fri, 10 Nov 2017 05:02:58 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vAAA2r3o007665 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2017 10:02:54 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vAAA2qXa029454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2017 10:02:53 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vAAA2n6c017812; Fri, 10 Nov 2017 10:02:49 GMT Received: from [10.169.110.250] (/10.169.110.250) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 10 Nov 2017 02:02:48 -0800 To: Michael Tokarev , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, alex.williamson@redhat.com, laurent@vivier.eu, Jim Quigley References: <1507630928-28307-1-git-send-email-Jim.Quigley@oracle.com> <78aed453-49b8-a9e4-ae7c-39c731158eaa@msgid.tls.msk.ru> From: Jim Quigley Organization: Oracle Corporation Message-ID: <1c3087f3-9019-26b3-b4be-df71da2033fc@oracle.com> Date: Fri, 10 Nov 2017 10:03:07 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <78aed453-49b8-a9e4-ae7c-39c731158eaa@msgid.tls.msk.ru> Content-Type: multipart/alternative; boundary="------------AC770E9CCE772B8741A440C9" Content-Language: en-US X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 Subject: Re: [Qemu-trivial] [PATCH] hw/vfio: improve error message when cannot init vfio event notifiers X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Nov 2017 10:03:11 -0000 This is a multi-part message in MIME format. --------------AC770E9CCE772B8741A440C9 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp1040.oracle.com id vAAA2r3o007665 On 16/10/2017 19:07, Michael Tokarev wrote: > 10.10.2017 13:22, Jim Quigley wrote: >> More information is required to assist trouble-shooting when >> QEMU fails to initialise the event notifications for devices >> assigned with VFIO-PCI. Instead of supplying the user with a cryptic >> error number only, print out a proper error message with strerror() >> so that the user has a better way to figure out what the problem is. >> >> Reviewed-by: Liam Merwick >> Signed-off-by: Jim Quigley >> --- >> Cc: qemu-trivial@nongnu.org >> Cc: mjt@tls.msk.ru >> Cc: laurent@vivier.eu >> Cc: alex.williamson@redhat.com >> --- >> hw/vfio/pci.c | 35 ++++++++++++++++++++++++----------- >> 1 file changed, 24 insertions(+), 11 deletions(-) >> >> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c >> index 31e1edf..3bffb93 100644 >> --- a/hw/vfio/pci.c >> +++ b/hw/vfio/pci.c >> @@ -430,13 +430,16 @@ static int vfio_enable_vectors(VFIOPCIDevice *vd= ev, bool msix) >> static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector= *vector, >> int vector_n, bool msix) >> { >> - int virq; >> + int virq, ret; >> =20 >> if ((msix && vdev->no_kvm_msix) || (!msix && vdev->no_kvm_msi)) = { >> return; >> } >> =20 >> - if (event_notifier_init(&vector->kvm_interrupt, 0)) { >> + ret =3D event_notifier_init(&vector->kvm_interrupt, 0); >> + if (ret) { >> + error_report("vfio (%s): Error: unable to init event notifier= : %s (%d)", >> + __func__, strerror(-ret), -ret); > Since this pattern gets repeated again and again, maybe we can either > use a common wrapper or move that eror reporting into event_notifier_in= it()? > Note there are other users of this function, besides hw/vfio, and maybe > these, too, can benefit from better error reporting? =C2=A0=C2=A0=C2=A0 Ideally the strerror() would be included in the error= _report()=20 function, =C2=A0=C2=A0=C2=A0 (as per the error_setg() function), which obviously w= ould involve a=20 more =C2=A0=C2=A0=C2=A0 extensive change to the code base. Would that be an a= cceptable=20 solution ? =C2=A0=C2=A0=C2=A0 Or I can move the reporting into theevent_notifier_in= it() function=20 if that is =C2=A0=C2=A0=C2=A0 the preferred approach ? =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 thanks =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 regards =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 Jim Q. > > Thanks, > > /mjt > > --------------AC770E9CCE772B8741A440C9 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp1040.oracle.com id vAAA2r3o007665



On 16/10/2017 19:07, Michael Tokarev wrote:
10.10.2017 13:22, Jim Quigley wrote:
More information is required to assist trouble-sho=
oting when
QEMU fails to initialise the event notifications for devices
assigned with VFIO-PCI. Instead of supplying the user with a cryptic
error number only, print out a proper error message with strerror()
so that the user has a better way to figure out what the problem is.

Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
Signed-off-by: Jim Quigley <Jim.Quigley@oracle.com>
---
Cc: qemu-trivial@nongnu.org
Cc: =
mjt@tls.msk.ru
Cc: laurent@vivier.eu
Cc: alex.williamson@redhat.com
---
 hw/vfio/pci.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 31e1edf..3bffb93 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -430,13 +430,16 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev,=
 bool msix)
 static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *ve=
ctor,
                                   int vector_n, bool msix)
 {
-    int virq;
+    int virq, ret;
=20
     if ((msix && vdev->no_kvm_msix) || (!msix && vdev=
->no_kvm_msi)) {
         return;
     }
=20
-    if (event_notifier_init(&vector->kvm_interrupt, 0)) {
+    ret =3D event_notifier_init(&vector->kvm_interrupt, 0);
+    if (ret) {
+        error_report("vfio (%s): Error: unable to init event notifier: %=
s (%d)",
+                     __func__, strerror(-ret), -ret);
Since this pattern gets repeated again and again, maybe we can either
use a common wrapper or move that eror reporting into event_notifier_init=
()?
Note there are other users of this function, besides hw/vfio, and maybe
these, too, can benefit from better error reporting?

=C2=A0=C2=A0=C2=A0 Ideal= ly the strerror() would be included in the error_report() function,
=C2=A0=C2=A0=C2=A0 (as per the er= ror_setg() function), which obviously would involve a more =C2=A0=C2=A0=C2=A0 extensive chan= ge to the code base. Would that be an acceptable solution ?
=C2=A0=C2=A0=C2=A0 Or I can move the reporti= ng into the event_notifier_init() function if that is
=C2=A0=C2=A0=C2=A0 the preferred approach ?
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 thanks

=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 regards

=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 Jim Q.
=C2=A0=C2=A0=C2=A0

Thanks,

/mjt



--------------AC770E9CCE772B8741A440C9--