From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
Bharata B Rao <bharata@linux.vnet.ibm.com>,
Cedric Le Goater <clg@kaod.org>
Subject: Re: [Qemu-devel] [PATCH 3/6] spapr: fix error reporting in xics_system_init()
Date: Tue, 16 May 2017 14:37:29 +1000 [thread overview]
Message-ID: <20170516043729.GF30022@umbus.fritz.box> (raw)
In-Reply-To: <149484837602.20089.6188552126304330653.stgit@bahia.lan>
[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]
On Mon, May 15, 2017 at 01:39:36PM +0200, Greg Kurz wrote:
> The xics_system_init() function passes its errp argument to xics_kvm_init().
> If the call fails and the user requested in-kernel irqchip, it then ends up
> passing a NULL Error * to error_reportf_err() and the error message is
> silently dropped.
>
> Passing an errp argument is generally wrong, unless you really just need
> to convey an error to the caller.
>
> This patch converts xics_system_init() to *only* pass a pointer to its own
> Error * and then to propagate it with error_propagate(), as recommended
> in error.h.
>
> The local_err name is used for consistency with the rest of the code.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
The change is good, but will need updating to work with the problem in
the previous patch.
> ---
> hw/ppc/spapr.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f477d7b8a210..44f7dc7f40e9 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -121,29 +121,32 @@ static ICSState *spapr_ics_create(sPAPRMachineState *spapr,
> static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp)
> {
> sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
> + Error *local_err = NULL;
>
> if (kvm_enabled()) {
> - Error *err = NULL;
> -
> if (machine_kernel_irqchip_allowed(machine) &&
> - !xics_kvm_init(spapr, errp)) {
> + !xics_kvm_init(spapr, &local_err)) {
> spapr->icp_type = TYPE_KVM_ICP;
> - spapr->ics = spapr_ics_create(spapr, TYPE_ICS_KVM, nr_irqs, &err);
> + spapr->ics = spapr_ics_create(spapr, TYPE_ICS_KVM, nr_irqs,
> + &local_err);
> }
> if (machine_kernel_irqchip_required(machine) && !spapr->ics) {
> - error_reportf_err(err,
> + error_reportf_err(local_err,
> "kernel_irqchip requested but unavailable: ");
> exit(EXIT_FAILURE);
> } else {
> - error_free(err);
> + error_free(local_err);
> }
> }
>
> if (!spapr->ics) {
> xics_spapr_init(spapr);
> spapr->icp_type = TYPE_ICP;
> - spapr->ics = spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs, errp);
> + spapr->ics = spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs,
> + &local_err);
> }
> +
> + error_propagate(errp, local_err);
> }
>
> static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
>
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-05-16 4:52 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 11:38 [Qemu-devel] [PATCH 0/6] spapr/xics: fix migration of older machine types Greg Kurz
2017-05-15 11:39 ` [Qemu-devel] [PATCH 1/6] ppc/xics: simplify prototype of xics_spapr_init() Greg Kurz
2017-05-15 12:09 ` Cédric Le Goater
2017-05-15 13:36 ` Philippe Mathieu-Daudé
2017-05-16 4:30 ` David Gibson
2017-05-15 11:39 ` [Qemu-devel] [PATCH 2/6] spapr: fix error path of required kernel-irqchip Greg Kurz
2017-05-15 11:47 ` Cédric Le Goater
2017-05-16 4:35 ` David Gibson
2017-05-16 5:56 ` Greg Kurz
2017-05-16 6:08 ` David Gibson
2017-05-16 6:22 ` Greg Kurz
2017-05-15 11:39 ` [Qemu-devel] [PATCH 3/6] spapr: fix error reporting in xics_system_init() Greg Kurz
2017-05-15 11:48 ` Cédric Le Goater
2017-05-16 4:37 ` David Gibson [this message]
2017-05-15 11:39 ` [Qemu-devel] [PATCH 4/6] spapr: sanitize error handling in spapr_ics_create() Greg Kurz
2017-05-15 11:59 ` Cédric Le Goater
2017-05-15 12:06 ` Greg Kurz
2017-05-16 4:39 ` David Gibson
2017-05-16 4:39 ` David Gibson
2017-05-15 11:39 ` [Qemu-devel] [PATCH 5/6] spapr-cpu-core: release ICP object when realization fails Greg Kurz
2017-05-15 12:02 ` Cédric Le Goater
2017-05-15 12:17 ` Greg Kurz
2017-05-16 4:41 ` David Gibson
2017-05-15 11:40 ` [Qemu-devel] [PATCH 6/6] spapr: fix migration of ICP objects from/to older QEMU Greg Kurz
2017-05-15 12:22 ` Cédric Le Goater
2017-05-15 13:16 ` Greg Kurz
2017-05-15 16:09 ` Cédric Le Goater
2017-05-15 16:20 ` Greg Kurz
2017-05-17 4:17 ` David Gibson
2017-05-15 16:11 ` Cédric Le Goater
2017-05-15 16:22 ` Greg Kurz
2017-05-17 4:18 ` David Gibson
2017-05-17 20:33 ` Greg Kurz
2017-05-19 6:40 ` David Gibson
2017-05-17 4:16 ` David Gibson
2017-05-17 4:14 ` David Gibson
2017-05-16 9:53 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-05-15 12:13 ` [Qemu-devel] [PATCH 0/6] spapr/xics: fix migration of older machine types no-reply
2017-05-15 12:19 ` Greg Kurz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170516043729.GF30022@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=bharata@linux.vnet.ibm.com \
--cc=clg@kaod.org \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).