[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v2 2/4] spapr: fix error reporting in xics_system_
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v2 2/4] spapr: fix error reporting in xics_system_init() |
Date: |
Sat, 20 May 2017 16:45:09 +1000 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Fri, May 19, 2017 at 12:32:12PM +0200, Greg Kurz wrote:
> If the user explicitely asked for kernel-irqchip support and "xics-kvm"
> initialization fails, we shouldn't fallback to emulated "xics" as we
> do now. It is also awkward to print an error message when we have an
> errp pointer argument.
>
> Let's use the errp argument to report the error and let the caller decide.
> This simplifies the code as we don't need a local Error * here.
>
> Signed-off-by: Greg Kurz <address@hidden>
Concept looks good, but..
> ---
> v2: - total rewrite
> ---
> hw/ppc/spapr.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 91f7434861a8..75e298b4c6be 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -128,18 +128,14 @@ static void xics_system_init(MachineState *machine, int
> nr_irqs, Error **errp)
> sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
>
> if (kvm_enabled()) {
> - Error *err = NULL;
> -
> if (machine_kernel_irqchip_allowed(machine) &&
> !xics_kvm_init(spapr, errp)) {
> 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,
> errp);
I believe there are reasons you're not supposed to just pass an errp
through to a subordinate function. Instead you're supposed to have a
local Error * and use error_propagate().
> }
> if (machine_kernel_irqchip_required(machine) && !spapr->ics) {
> - error_reportf_err(err,
> - "kernel_irqchip requested but unavailable: ");
> - } else {
> - error_free(err);
> + error_prepend(errp, "kernel_irqchip requested but unavailable:
> ");
> + return;
> }
> }
>
> @@ -147,6 +143,9 @@ static void xics_system_init(MachineState *machine, int
> nr_irqs, Error **errp)
> xics_spapr_init(spapr);
> spapr->icp_type = TYPE_ICP;
> spapr->ics = spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs, errp);
> + if (!spapr->ics) {
It would also be more standard to check the returned error, rather
than the other result.
> + return;
> + }
> }
> }
>
>
--
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
signature.asc
Description: PGP signature
[Qemu-ppc] [PATCH v2 3/4] target/ppc: consolidate CPU device-tree id computation in helper, Greg Kurz, 2017/05/19