From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7P64-0000B8-J5 for qemu-devel@nongnu.org; Fri, 11 Dec 2015 09:55:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7P61-0002Ys-CW for qemu-devel@nongnu.org; Fri, 11 Dec 2015 09:55:00 -0500 References: <1449792685-17000-1-git-send-email-david@gibson.dropbear.id.au> <1449792685-17000-3-git-send-email-david@gibson.dropbear.id.au> From: Eric Blake Message-ID: <566AE3B8.7010100@redhat.com> Date: Fri, 11 Dec 2015 07:54:48 -0700 MIME-Version: 1.0 In-Reply-To: <1449792685-17000-3-git-send-email-david@gibson.dropbear.id.au> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Picqjdjue33Au8gQOjFk7x7Fxxb8Jh0uG" Subject: Re: [Qemu-devel] [PATCH 02/11] pseries: Cleanup error handling of spapr_cpu_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , armbru@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com Cc: lvivier@redhat.com, thuth@redhat.com, qemu-ppc@nongnu.org, agraf@suse.de, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Picqjdjue33Au8gQOjFk7x7Fxxb8Jh0uG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/10/2015 05:11 PM, David Gibson wrote: > Currently spapr_cpu_init() is hardcoded to handle any errors as fatal. > That works for now, since it's only called from initial setup where an > error here means we really can't proceed. >=20 > However, we'll want to handle this more flexibly for cpu hotplug in fut= ure > so generalize this using the error reporting infrastructure. While we'= re > at it make a small cleanup in a related part of ppc_spapr_init() to use= > the error infrastructure instead of an old-style explicit fprintf / exi= t. >=20 > Signed-off-by: David Gibson > --- > hw/ppc/spapr.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > @@ -1633,7 +1634,7 @@ static void spapr_cpu_init(sPAPRMachineState *spa= pr, PowerPCCPU *cpu) > } > =20 > if (cpu->max_compat) { > - ppc_set_compat(cpu, cpu->max_compat, &error_fatal); > + ppc_set_compat(cpu, cpu->max_compat, errp); > } > =20 > xics_cpu_setup(spapr->icp, cpu); Pre-patch: you can't reach the xics_cpu_setup() call on error. Post-patch: depending on what the caller passed in, you can fall through to xics_cpu_setup() with a potentially incomplete cpu. I think a more robust solution is probably along the lines of: Error *err =3D NULL; if (cpu->max_compat) { ppc_set_compat(cpu, cpu->max_compat, &err); if (err) { error_propagate(errp, err); return; } } xics_cpu_setup(spapr_icp, cpu); > @@ -1802,10 +1803,9 @@ static void ppc_spapr_init(MachineState *machine= ) > for (i =3D 0; i < smp_cpus; i++) { > cpu =3D cpu_ppc_init(machine->cpu_model); > if (cpu =3D=3D NULL) { > - fprintf(stderr, "Unable to find PowerPC CPU definition\n")= ; > - exit(1); > + error_setg(&error_fatal, "Unable to find PowerPC CPU defin= ition"); > } > - spapr_cpu_init(spapr, cpu); > + spapr_cpu_init(spapr, cpu, &error_fatal); Of course, in _this_ patch, since the (only) caller is passing &error_fatal, you don't hit the situation of fallthrough to xics_cpu_setup(). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Picqjdjue33Au8gQOjFk7x7Fxxb8Jh0uG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWauO4AAoJEKeha0olJ0NqrTMH/Rnrcv/YCWEGBBX8A+fJ4QhE yjL3lSvbXY32gSw74ee0AwT/A9pirObvC0e4fTRyKx46l/VmIcf7GzF6WL8F0D4z 5iXjO4Ayph5Q6hABGh0UyciP6HsaEeCd3q5rPK5OUNV9cG9wviS8UAoe1nV2gs+t p2YvpqD1ZA8O4/7WxdN3I02t+jhf3DjKCJih98k8vUX7VKnFhnlu7FqtcB+YFcRE dxbPMmKg1TQLgny3ioqORpC9lBiXi1uhXJ/ecIWXx4QrrvYV0rFm3AvUmOjY470c GUPMdRTNmrG47INwZQ00lvQw5I1HOJ9pELpmmUywexDj4JIzad9AY8LwfrZNJ1M= =/gfI -----END PGP SIGNATURE----- --Picqjdjue33Au8gQOjFk7x7Fxxb8Jh0uG--