All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org, groug@kaod.org
Cc: Laurent Vivier <lvivier@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PULL 08/40] spapr: Use error_append_hint() in spapr_caps.c
Date: Tue, 18 Aug 2020 14:18:50 +1000	[thread overview]
Message-ID: <20200818041922.251708-9-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20200818041922.251708-1-david@gibson.dropbear.id.au>

From: Greg Kurz <groug@kaod.org>

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.

While here, have cap_fwnmi_apply(), which already uses
error_append_hint(), to call ERRP_GUARD() as well.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <159594297421.8262.14314530897345809924.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr_caps.c | 89 +++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 39 deletions(-)

diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 3225fc5a2e..275f5bd034 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -180,24 +180,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_GUARD();
     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");
+        error_append_hint(errp, "Try appending -machine cap-htm=off\n");
     }
 }
 
 static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
 {
+    ERRP_GUARD();
     PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
     CPUPPCState *env = &cpu->env;
 
@@ -209,13 +209,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_GUARD();
     PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
     CPUPPCState *env = &cpu->env;
 
@@ -224,8 +225,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");
     }
 }
 
@@ -239,6 +240,7 @@ SpaprCapPossible cap_cfpc_possible = {
 static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
                                  Error **errp)
 {
+    ERRP_GUARD();
     uint8_t kvm_val =  kvmppc_get_cap_safe_cache();
 
     if (tcg_enabled() && val) {
@@ -247,9 +249,9 @@ 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");
+        error_append_hint(errp, "Try appending -machine cap-cfpc=%s\n",
+                          cap_cfpc_possible.vals[kvm_val]);
     }
 }
 
@@ -263,6 +265,7 @@ SpaprCapPossible cap_sbbc_possible = {
 static void cap_safe_bounds_check_apply(SpaprMachineState *spapr, uint8_t val,
                                         Error **errp)
 {
+    ERRP_GUARD();
     uint8_t kvm_val =  kvmppc_get_cap_safe_bounds_check();
 
     if (tcg_enabled() && val) {
@@ -271,9 +274,9 @@ 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]);
     }
 }
 
@@ -290,6 +293,7 @@ SpaprCapPossible cap_ibs_possible = {
 static void cap_safe_indirect_branch_apply(SpaprMachineState *spapr,
                                            uint8_t val, Error **errp)
 {
+    ERRP_GUARD();
     uint8_t kvm_val = kvmppc_get_cap_safe_indirect_branch();
 
     if (tcg_enabled() && val) {
@@ -298,9 +302,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]);
     }
 }
 
@@ -377,23 +381,25 @@ static void cap_hpt_maxpagesize_cpu_apply(SpaprMachineState *spapr,
 static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
                                     uint8_t val, Error **errp)
 {
+    ERRP_GUARD();
     if (!val) {
         /* capability disabled by default */
         return;
     }
 
     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\n");
     } 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\n");
         } 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\n");
         }
     }
 }
@@ -401,6 +407,7 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
 static void cap_large_decr_apply(SpaprMachineState *spapr,
                                  uint8_t val, Error **errp)
 {
+    ERRP_GUARD();
     PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
     PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 
@@ -411,22 +418,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");
         }
     }
 }
@@ -435,14 +443,15 @@ static void cap_large_decr_cpu_apply(SpaprMachineState *spapr,
                                      PowerPCCPU *cpu,
                                      uint8_t val, Error **errp)
 {
+    ERRP_GUARD();
     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");
         }
     }
 
@@ -457,6 +466,7 @@ static void cap_large_decr_cpu_apply(SpaprMachineState *spapr,
 static void cap_ccf_assist_apply(SpaprMachineState *spapr, uint8_t val,
                                  Error **errp)
 {
+    ERRP_GUARD();
     uint8_t kvm_val = kvmppc_get_cap_count_cache_flush_assist();
 
     if (tcg_enabled() && val) {
@@ -479,14 +489,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_GUARD();
     if (!val) {
         return; /* Disabled by default */
     }
-- 
2.26.2



  parent reply	other threads:[~2020-08-18  4:26 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  4:18 [PULL 00/40] ppc-for-5.2 queue 20200818 David Gibson
2020-08-18  4:18 ` [PULL 01/40] target/ppc: Fix TCG leak with the evmwsmiaa instruction David Gibson
2020-08-18  4:18 ` [PULL 02/40] target/ppc: Introduce Power ISA 3.1 flag David Gibson
2020-08-18  4:18 ` [PULL 03/40] target/ppc: Enable Power ISA 3.1 David Gibson
2020-08-18  4:18 ` [PULL 04/40] target/ppc: add byte-reverse br[dwh] instructions David Gibson
2020-08-18  4:18 ` [PULL 05/40] target/ppc: convert vmuluwm to tcg_gen_gvec_mul David Gibson
2020-08-18  4:18 ` [PULL 06/40] target/ppc: add vmulld instruction David Gibson
2020-08-18  4:18 ` [PULL 07/40] ppc/spapr: Fix 32 bit logical memory block size assumptions David Gibson
2020-08-18  4:18 ` David Gibson [this message]
2020-08-18  4:18 ` [PULL 09/40] spapr: Forbid nested KVM-HV in pre-power9 compat mode David Gibson
2020-08-18  4:18 ` [PULL 10/40] ppc/xive: Fix some typos in comments David Gibson
2020-08-18  4:18 ` [PULL 11/40] Update PowerPC AT_HWCAP2 definition David Gibson
2020-08-18  4:18 ` [PULL 12/40] target/ppc: add vmulld to INDEX_op_mul_vec case David Gibson
2020-08-18  4:18 ` [PULL 13/40] target/ppc: add vmulh{su}w instructions David Gibson
2020-08-18  4:18 ` [PULL 14/40] target/ppc: add vmulh{su}d instructions David Gibson
2020-08-18  4:18 ` [PULL 15/40] target/ppc: Fix SPE unavailable exception triggering David Gibson
2020-08-18  4:18 ` [PULL 16/40] docs: adding NUMA documentation for pseries David Gibson
2020-08-18  4:18 ` [PULL 17/40] docs: Update POWER9 XIVE support for nested guests David Gibson
2020-08-18  4:19 ` [PULL 18/40] spapr: Clarify error and documentation for broken KVM XICS David Gibson
2020-08-18  4:19 ` [PULL 19/40] spapr/xive: Fix xive->fd if kvm_create_device() fails David Gibson
2020-08-18  4:19 ` [PULL 20/40] spapr/xive: Simplify kvmppc_xive_disconnect() David Gibson
2020-08-18  4:19 ` [PULL 21/40] target/ppc: Integrate icount to purr, vtb, and tbu40 David Gibson
2020-08-18  4:19 ` [PULL 22/40] ppc/xive: Rework setup of XiveSource::esb_mmio David Gibson
2020-08-18  4:19 ` [PULL 23/40] ppc/xive: Introduce dedicated kvm_irqchip_in_kernel() wrappers David Gibson
2020-08-18  4:19 ` [PULL 24/40] spapr/xive: Convert KVM device fd checks to assert() David Gibson
2020-08-18  4:19 ` [PULL 25/40] spapr: Simplify error handling in spapr_phb_realize() David Gibson
2020-08-18  4:19 ` [PULL 26/40] spapr/xive: Rework error handling of kvmppc_xive_cpu_connect() David Gibson
2020-08-18  4:19 ` [PULL 27/40] spapr/xive: Rework error handling of kvmppc_xive_source_reset() David Gibson
2020-08-18  4:19 ` [PULL 28/40] spapr/xive: Rework error handling of kvmppc_xive_mmap() David Gibson
2020-08-18  4:19 ` [PULL 29/40] spapr/xive: Rework error handling of kvmppc_xive_cpu_[gs]et_state() David Gibson
2020-08-18  4:19 ` [PULL 30/40] spapr/xive: Rework error handling of kvmppc_xive_[gs]et_queue_config() David Gibson
2020-08-18  4:19 ` [PULL 31/40] spapr/xive: Rework error handling in kvmppc_xive_get_queues() David Gibson
2020-08-18  4:19 ` [PULL 32/40] spapr/xive: Rework error handling of kvmppc_xive_set_source_config() David Gibson
2020-08-18  4:19 ` [PULL 33/40] spapr/kvm: Fix error handling in kvmppc_xive_pre_save() David Gibson
2020-08-18  4:19 ` [PULL 34/40] spapr/xive: Fix error handling in kvmppc_xive_post_load() David Gibson
2020-08-18  4:19 ` [PULL 35/40] ppc/xive: Fix error handling in vmstate_xive_tctx_*() callbacks David Gibson
2020-08-18  4:19 ` [PULL 36/40] spapr/xive: Simplify error handling in kvmppc_xive_connect() David Gibson
2020-08-18  4:19 ` [PULL 37/40] ppc/xive: Simplify error handling in xive_tctx_realize() David Gibson
2020-08-18  4:19 ` [PULL 38/40] spapr/xive: Simplify error handling of kvmppc_xive_cpu_synchronize_state() David Gibson
2020-08-18  4:19 ` [PULL 39/40] nvram: Exit QEMU if NVRAM cannot contain all -prom-env data David Gibson
2020-08-18  4:19 ` [PULL 40/40] spapr/xive: Use xive_source_esb_len() David Gibson
2020-08-23 13:54 ` [PULL 00/40] ppc-for-5.2 queue 20200818 Peter Maydell
2020-08-23 23:21   ` David Gibson
2020-08-24  8:36     ` Peter Maydell
2020-08-24 11:12 ` Peter Maydell

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=20200818041922.251708-9-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.