From: Greg Kurz <groug@kaod.org>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH 2/3] spapr: Use error_append_hint() in spapr_caps.c
Date: Thu, 11 Jun 2020 10:33:41 +0200 [thread overview]
Message-ID: <20200611103341.3e84e565@bahia.lan> (raw)
In-Reply-To: <3bbcf90e-13c3-1c45-b100-69e0e5bcb0ef@virtuozzo.com>
On Wed, 10 Jun 2020 21:03:15 +0300
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
> 10.06.2020 20:17, Greg Kurz wrote:
> > We have a dedicated error API for hints. Use it instead of embedding
> > the hint in the error message, as recommanded in the "qapi/error.h"
> > header file.
> >
> > Since spapr_caps_apply() passes &error_fatal, all functions must
> > also call the ERRP_AUTO_PROPAGATE() macro for error_append_hint()
> > to be functional.
> >
> > While here, add some missing braces around one line statements that
> > are part of the patch context. Also have cap_fwnmi_apply(), which
> > already uses error_append_hint() to call ERRP_AUTO_PROPAGATE() as
> > well.
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > hw/ppc/spapr_caps.c | 93 +++++++++++++++++++++++++++++----------------------
> > 1 file changed, 52 insertions(+), 41 deletions(-)
> >
> > diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> > index efdc0dbbcfc0..0c3d3b64a508 100644
> > --- a/hw/ppc/spapr_caps.c
> > +++ b/hw/ppc/spapr_caps.c
> > @@ -189,24 +189,24 @@ static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
> >
> > static void cap_htm_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > if (!val) {
> > /* TODO: We don't support disabling htm yet */
> > return;
> > }
> > if (tcg_enabled()) {
> > - error_setg(errp,
> > - "No Transactional Memory support in TCG,"
> > - " try appending -machine cap-htm=off");
> > + error_setg(errp, "No Transactional Memory support in TCG");
> > + error_append_hint(errp, "Try appending -machine cap-htm=off\n");
> > } else if (kvm_enabled() && !kvmppc_has_cap_htm()) {
> > error_setg(errp,
> > -"KVM implementation does not support Transactional Memory,"
> > - " try appending -machine cap-htm=off"
> > - );
> > +"KVM implementation does not support Transactional Memory");
>
> Should be indented after opening '('
>
Many error_setg() lines in this file follow the same style of tweaking
indentation to stay below the 80 character limit. I've just kept the
existing style.
> > + error_append_hint(errp, "Try appending -machine cap-htm=off\n");
> > }
> > }
> >
> > static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
> > CPUPPCState *env = &cpu->env;
> >
> > @@ -218,13 +218,14 @@ static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
> > * rid of anything that doesn't do VMX */
> > g_assert(env->insns_flags & PPC_ALTIVEC);
> > if (!(env->insns_flags2 & PPC2_VSX)) {
> > - error_setg(errp, "VSX support not available,"
> > - " try appending -machine cap-vsx=off");
> > + error_setg(errp, "VSX support not available");
> > + error_append_hint(errp, "Try appending -machine cap-vsx=off\n");
> > }
> > }
> >
> > static void cap_dfp_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
> > CPUPPCState *env = &cpu->env;
> >
> > @@ -233,8 +234,8 @@ static void cap_dfp_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
> > return;
> > }
> > if (!(env->insns_flags2 & PPC2_DFP)) {
> > - error_setg(errp, "DFP support not available,"
> > - " try appending -machine cap-dfp=off");
> > + error_setg(errp, "DFP support not available");
> > + error_append_hint(errp, "Try appending -machine cap-dfp=off\n");
> > }
> > }
> >
> > @@ -248,6 +249,7 @@ SpaprCapPossible cap_cfpc_possible = {
> > static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
> > Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > Error *local_err = NULL;
> > uint8_t kvm_val = kvmppc_get_cap_safe_cache();
> >
> > @@ -258,13 +260,14 @@ static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
> > cap_cfpc_possible.vals[val]);
> > } else if (kvm_enabled() && (val > kvm_val)) {
> > error_setg(errp,
> > - "Requested safe cache capability level not supported by kvm,"
> > - " try appending -machine cap-cfpc=%s",
> > - cap_cfpc_possible.vals[kvm_val]);
> > +"Requested safe cache capability level not supported by KVM");
>
> Hmm you do this intentionally.. OK, than, it's a kind of taste.
>
Yes, but as said above, there's precedence in this file.
I'm okay with fixing the indent. It is acceptable to have error_setg()
lines span over 80 characters for the sake of being able to grep error
strings in the code base.
> > + error_append_hint(errp, "Try appending -machine cap-cfpc=%s\n",
> > + cap_cfpc_possible.vals[kvm_val]);
> > }
> >
> > - if (local_err != NULL)
> > + if (local_err != NULL) {
> > warn_report_err(local_err);
> > + }
> > }
> >
> > SpaprCapPossible cap_sbbc_possible = {
> > @@ -277,6 +280,7 @@ SpaprCapPossible cap_sbbc_possible = {
> > static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
> > Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > Error *local_err = NULL;
> > uint8_t kvm_val = kvmppc_get_cap_safe_bounds_check();
> >
> > @@ -287,13 +291,14 @@ static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
> > cap_sbbc_possible.vals[val]);
> > } else if (kvm_enabled() && (val > kvm_val)) {
> > error_setg(errp,
> > -"Requested safe bounds check capability level not supported by kvm,"
> > - " try appending -machine cap-sbbc=%s",
> > - cap_sbbc_possible.vals[kvm_val]);
> > +"Requested safe bounds check capability level not supported by KVM");
> > + error_append_hint(errp, "Try appending -machine cap-sbbc=%s\n",
> > + cap_sbbc_possible.vals[kvm_val]);
> > }
> >
> > - if (local_err != NULL)
> > + if (local_err != NULL) {
> > warn_report_err(local_err);
> > + }
> > }
> >
> > SpaprCapPossible cap_ibs_possible = {
> > @@ -309,6 +314,7 @@ SpaprCapPossible cap_ibs_possible = {
> > static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
> > uint8_t val, Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > Error *local_err = NULL;
> > uint8_t kvm_val = kvmppc_get_cap_safe_indirect_branch();
> >
> > @@ -319,9 +325,9 @@ static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
> > cap_ibs_possible.vals[val]);
> > } else if (kvm_enabled() && (val > kvm_val)) {
> > error_setg(errp,
> > -"Requested safe indirect branch capability level not supported by kvm,"
> > - " try appending -machine cap-ibs=%s",
> > - cap_ibs_possible.vals[kvm_val]);
> > +"Requested safe indirect branch capability level not supported by KVM");
> > + error_append_hint(errp, "Try appending -machine cap-ibs=%s\n",
> > + cap_ibs_possible.vals[kvm_val]);
> > }
> >
> > if (local_err != NULL) {
> > @@ -408,17 +414,17 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
>
> You forget to add ERRP_AUTO_PROPAGATE
>
Oops, it's in the next patch... I've re-ordered the patches and
I simply forgot to move that hunk here. I will fix that in v2.
> > }
> >
> > if (tcg_enabled()) {
> > - error_setg(errp,
> > - "No Nested KVM-HV support in tcg,"
> > - " try appending -machine cap-nested-hv=off");
> > + error_setg(errp, "No Nested KVM-HV support in TCG");
> > + error_append_hint(errp, "Try appending -machine cap-nested-hv=off");
>
> Hmm, didn't you forget '\n' ? You consistantly add it in previous hints. (I do think that it's strange that we should add it by hand, but it seems a common thing to add it)
>
Oops indeed I forgot. Good catch ! :)
From the documentation of error_append_hint() in "qapi/error.h" :
* May be called multiple times. The resulting hint should end with a
* newline.
> > } else if (kvm_enabled()) {
> > if (!kvmppc_has_cap_nested_kvm_hv()) {
> > error_setg(errp,
> > -"KVM implementation does not support Nested KVM-HV,"
> > - " try appending -machine cap-nested-hv=off");
> > +"KVM implementation does not support Nested KVM-HV");
> > + error_append_hint(errp, "Try appending -machine cap-nested-hv=off");
>
> and here
>
Oops
> > } else if (kvmppc_set_cap_nested_kvm_hv(val) < 0) {
> > - error_setg(errp,
> > -"Error enabling cap-nested-hv with KVM, try cap-nested-hv=off");
> > + error_setg(errp, "Error enabling cap-nested-hv with KVM");
> > + error_append_hint(errp,
> > + "Try appending -machine cap-nested-hv=off");
>
> and here
>
Thanks for all the catches !
> > }
> > }
> > }
> > @@ -426,6 +432,7 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
> > static void cap_large_decr_apply(SpaprMachineState *spapr,
> > uint8_t val, Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
> > PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
> >
> > @@ -436,22 +443,23 @@ static void cap_large_decr_apply(SpaprMachineState *spapr,
> > if (tcg_enabled()) {
> > if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_3_00, 0,
> > spapr->max_compat_pvr)) {
> > - error_setg(errp,
> > - "Large decrementer only supported on POWER9, try -cpu POWER9");
> > + error_setg(errp, "Large decrementer only supported on POWER9");
> > + error_append_hint(errp, "Try -cpu POWER9\n");
> > return;
> > }
> > } else if (kvm_enabled()) {
> > int kvm_nr_bits = kvmppc_get_cap_large_decr();
> >
> > if (!kvm_nr_bits) {
> > - error_setg(errp,
> > - "No large decrementer support,"
> > - " try appending -machine cap-large-decr=off");
> > + error_setg(errp, "No large decrementer support");
> > + error_append_hint(errp,
> > + "Try appending -machine cap-large-decr=off\n");
> > } else if (pcc->lrg_decr_bits != kvm_nr_bits) {
> > error_setg(errp,
> > -"KVM large decrementer size (%d) differs to model (%d),"
> > - " try appending -machine cap-large-decr=off",
> > - kvm_nr_bits, pcc->lrg_decr_bits);
> > + "KVM large decrementer size (%d) differs to model (%d)",
> > + kvm_nr_bits, pcc->lrg_decr_bits);
> > + error_append_hint(errp,
> > + "Try appending -machine cap-large-decr=off\n");
> > }
> > }
> > }
> > @@ -460,14 +468,15 @@ static void cap_large_decr_cpu_apply(SpaprMachineState *spapr,
> > PowerPCCPU *cpu,
> > uint8_t val, Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > CPUPPCState *env = &cpu->env;
> > target_ulong lpcr = env->spr[SPR_LPCR];
> >
> > if (kvm_enabled()) {
> > if (kvmppc_enable_cap_large_decr(cpu, val)) {
> > - error_setg(errp,
> > - "No large decrementer support,"
> > - " try appending -machine cap-large-decr=off");
> > + error_setg(errp, "No large decrementer support");
> > + error_append_hint(errp,
> > + "Try appending -machine cap-large-decr=off\n");
> > }
> > }
> >
> > @@ -482,6 +491,7 @@ static void cap_large_decr_cpu_apply(SpaprMachineState *spapr,
> > static void cap_ccf_assist_apply(SpaprMachineState *spapr, uint8_t val,
> > Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > uint8_t kvm_val = kvmppc_get_cap_count_cache_flush_assist();
> >
> > if (tcg_enabled() && val) {
> > @@ -504,14 +514,15 @@ static void cap_ccf_assist_apply(SpaprMachineState *spapr, uint8_t val,
> > return;
> > }
> > error_setg(errp,
> > -"Requested count cache flush assist capability level not supported by kvm,"
> > - " try appending -machine cap-ccf-assist=off");
> > +"Requested count cache flush assist capability level not supported by KVM");
> > + error_append_hint(errp, "Try appending -machine cap-ccf-assist=off\n");
> > }
> > }
> >
> > static void cap_fwnmi_apply(SpaprMachineState *spapr, uint8_t val,
> > Error **errp)
> > {
> > + ERRP_AUTO_PROPAGATE();
> > if (!val) {
> > return; /* Disabled by default */
> > }
> >
> >
>
>
next prev parent reply other threads:[~2020-06-11 8:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 17:17 [PATCH 0/3] spapr: Improve error reporting in spapr_caps.c Greg Kurz
2020-06-10 17:17 ` [PATCH 1/3] error: auto propagated local_err Greg Kurz
2020-06-10 17:17 ` [PATCH 2/3] spapr: Use error_append_hint() in spapr_caps.c Greg Kurz
2020-06-10 18:03 ` Vladimir Sementsov-Ogievskiy
2020-06-11 8:33 ` Greg Kurz [this message]
2020-06-10 17:17 ` [PATCH 3/3] spapr: Forbid nested KVM-HV in pre-power9 compat mode Greg Kurz
2020-06-10 18:14 ` Vladimir Sementsov-Ogievskiy
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=20200611103341.3e84e565@bahia.lan \
--to=groug@kaod.org \
--cc=armbru@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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).