From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8I7n-0001eJ-0N 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-0004Tl-Sl for qemu-devel@nongnu.org; Sun, 13 Dec 2015 20:40:26 -0500 Date: Mon, 14 Dec 2015 12:24:22 +1100 From: David Gibson Message-ID: <20151214012422.GJ22783@voom.fritz.box> References: <1449792685-17000-1-git-send-email-david@gibson.dropbear.id.au> <1449792685-17000-8-git-send-email-david@gibson.dropbear.id.au> <566A9F01.7090203@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="x0KprKst+ZOYEj2z" Content-Disposition: inline In-Reply-To: <566A9F01.7090203@redhat.com> Subject: Re: [Qemu-devel] [PATCH 07/11] pseries: Cleanup error handling in spapr_kvm_type() 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 --x0KprKst+ZOYEj2z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 11, 2015 at 11:01:37AM +0100, Thomas Huth wrote: > On 11/12/15 01:11, David Gibson wrote: > > Use error_setg() and &error_fatal instead of an explicit exit(). > >=20 > > Signed-off-by: David Gibson > > --- > > hw/ppc/spapr.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > index fd16db4..546d2f5 100644 > > --- a/hw/ppc/spapr.c > > +++ b/hw/ppc/spapr.c > > @@ -2035,8 +2035,8 @@ static int spapr_kvm_type(const char *vm_type) > > return 2; > > } > > =20 > > - error_report("Unknown kvm-type specified '%s'", vm_type); > > - exit(1); > > + error_setg(&error_fatal, "Unknown kvm-type specified '%s'", vm_typ= e); > > + return 0; > > } >=20 > Honestly, I'd rather prefer the original code here. error_setg() should > IMHO be used to set an error in an "flexible" error variable. Using it > with an "hard-coded" error_fatal sounds ugly to me. And as far as I can > see, no other code in QEMU uses error_setg(&error_fatal, ...) - so we > should maybe not start with this in the spapr code as well. Whereas I was thinking that if we have a standard way of tripping a fatal error, we should use that, rather than using an explicit exit(). > If you still would like to get rid of the exit() here ... maybe you > could introduce some kind of error_report_fatal() function instead that > exits after reporting the error with error_report() ? I don't see that there's any point adding an error_report_fatal() that would be semantically equivalent to error_setg(&error_fatal, ...). Markus, an opnion on the right way to do this? --=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 --x0KprKst+ZOYEj2z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWbhpGAAoJEGw4ysog2bOSJAoP/Atl8Yax0vpvExbm2NxYT4RD j9p3fGBAqfYMmHhGj4dNvgRBcFx92Q8VBSk1F4vqehjfN6hH4mekc80cBSfwyZTK Zx9HKFsmEE6STsaeESr0kQbvl4iIZ3Cqrp5livns7H1yUM3tQ+SMqEsKrBC8M6T3 lgoCX9T0cD8WqqFSQaE2ZMyM8GfkiLq+S6F47Gdb9RDlYvGLNFQAFLSdqzp6OMDk /HCDMbXvZdwU5cUYlzdQ9LUt+rYYfRnS3GjKHYGALHE3sBQPwlldoPOsYfdeQ/6I /MJ95/HVuqKHVL6+f84Ax3u19jn2bE63uGXu5Ee+rfnCmhMndgVbyhv7NEcsZ5Q7 y9c9jHCxENelV1QprXyfdLELqe9zQlHb/AGxrl4a9hh1Go8SfH8nppnnWtI9H5Nh tuTj0j7+NoizEqrHle2P/ha4nzIXhvMyiVwEJE2/KO9ZL8Z8hnHBbAn6jpfBNIYb X5g88KhxDjtkra9fu1xeW03B6hF6kpVQ6WORoTwJ5B8FiTWV8qfiP+LYiVIUia6I g5xNGfQHBETAxEG+yqgQv7YbbnpcnUU+KUTex5vbgdryGlI6E7lifMygsb+FFkip 56ql2x1ddWgKDWYmqYXiVQ1VAWxix0HSeBOhAlZJhfXWgLXiuaYlz71L9NoMKaYV nBh99CYFSoraZEWt72bj =Sq3g -----END PGP SIGNATURE----- --x0KprKst+ZOYEj2z--