From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8I7m-0001eG-Uy for qemu-devel@nongnu.org; Sun, 13 Dec 2015 20:40:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8I7k-0004Ta-Qw for qemu-devel@nongnu.org; Sun, 13 Dec 2015 20:40:26 -0500 Date: Mon, 14 Dec 2015 12:20:13 +1100 From: David Gibson Message-ID: <20151214012013.GH22783@voom.fritz.box> References: <1449792685-17000-1-git-send-email-david@gibson.dropbear.id.au> <1449792685-17000-7-git-send-email-david@gibson.dropbear.id.au> <566A9C34.4070308@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="smOfPzt+Qjm5bNGJ" Content-Disposition: inline In-Reply-To: <566A9C34.4070308@redhat.com> Subject: Re: [Qemu-devel] [PATCH 06/11] pseries: Improve error handling in find_unknown_sysbus_device() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: lvivier@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, armbru@redhat.com, qemu-ppc@nongnu.org --smOfPzt+Qjm5bNGJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 11, 2015 at 10:49:40AM +0100, Thomas Huth wrote: > On 11/12/15 01:11, David Gibson wrote: > > Use error_setg() to return an error instead of using an explicit exit(). > >=20 > > Signed-off-by: David Gibson > > --- > > hw/ppc/spapr.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > >=20 > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > index 0ff09b9..fd16db4 100644 > > --- a/hw/ppc/spapr.c > > +++ b/hw/ppc/spapr.c > > @@ -1107,6 +1107,7 @@ static void spapr_reset_htab(sPAPRMachineState *s= papr, Error **errp) > > =20 > > static int find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaqu= e) > > { > > + Error **errp =3D opaque; > > bool matched =3D false; > > =20 > > if (object_dynamic_cast(OBJECT(sbdev), TYPE_SPAPR_PCI_HOST_BRIDGE)= ) { > > @@ -1114,9 +1115,9 @@ static int find_unknown_sysbus_device(SysBusDevic= e *sbdev, void *opaque) > > } > > =20 > > if (!matched) { > > - error_report("Device %s is not supported by this machine yet.", > > - qdev_fw_name(DEVICE(sbdev))); > > - exit(1); > > + error_setg(errp, > > + "Device %s is not supported by this machine yet", > > + qdev_fw_name(DEVICE(sbdev))); > > } > > =20 > > return 0; > > @@ -1151,7 +1152,7 @@ static void ppc_spapr_reset(void) > > uint32_t rtas_limit; > > =20 > > /* Check for unknown sysbus devices */ > > - foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); > > + foreach_dynamic_sysbus_device(find_unknown_sysbus_device, &error_a= bort); > > =20 > > /* Reset the hash table & recalc the RMA */ > > spapr_reset_htab(spapr, &error_abort); >=20 > Can this error be triggered by the user (by plugging certain devices or > so)? If so, I'm not sure whether error_abort is the right thing to use > here ... it's always ugly if the user can trigger an abort directly. > Maybe error_fatal would be better instead? Hm. So, yes, I think it can be triggered by the user. I used &error_abort on the grounds that this is during reset - after the initial setup phase. Markus, do you have an opinion on what the right handling here is? --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --smOfPzt+Qjm5bNGJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWbhlNAAoJEGw4ysog2bOS/jAQAMrzoLdJMr6E60uLsIqIt381 bZreKDpjS4Qep6HX7YNpaaUSWg0tUcawzNyB6xXIdn579wurXHNsgcy4bD8cIMXq jXg1/rjWKv6vIlbkzM3MLIjAQSOC0coX4XN38N9nURTM+2DoYdfVGecA5kSELs8+ 8V7u4x56l6HwI3ZDI3uaCLsLpdTMdBF4Pm8NQ7oy07g0Jtz86XvEmUWhLZ6yNALl oxUQdwkrMTuS0adKGV4Ke8TGHsrdUDOoWmjQWKh68GZThLxMT2+itfNkg93krTpz PKGFwCeF8MRQ7Tqwm+U78oEReE/QdUSsg5A1rgwgj5dttOK5qsZEmxZTsryyRwxf Tdib3zRmOQPfS/wK3THbDpo6wC7GWgKXBUVS47psvMdUlJGmkhqR+OcFaxrrm+pZ qsvcnxPlB6IwnmcD19+ciDy3mmyJJ7ispnuhXkOQNzPrIUTLrGmruEyxaWC78EH8 Su6GZxoJxACEcvIpVQd69XMjouGok3j6Fi2SsTCMKhTktyrxMKgLyXOqteqYgRb4 LPMRuvWHfU7gziHqnqstvoVbtjtSUAxxgEtNxv9XyvbUczRcUgZ9v8/bZSgr0cSn R6oCStLUhhM8LfGewqa70NBRja/IMkzthFqWTDaM1PvYAoOonhThYa4UmQqVXAJg o+Pv/U6ayfloI1QrmDy3 =z2X3 -----END PGP SIGNATURE----- --smOfPzt+Qjm5bNGJ--