Skip to contentSkip to conversation

spapr: quantify error messages regarding capability settings

PATCH Superseded Daniel Black 3 participants 5 messages Aug 1, 2019 – Aug 4, 2019

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spapr: quantify error messages regarding capability settings

Its not immediately obvious how cap-X=Y setting need to be applied to the command line so, for spapr capability error messages, this has been clarified to:

..[try] appending -machine cap-X=Y

The wrong value messages have been left as is, as the user has found the right location.

---
v2 Improved error message thanks David Gibson

Left the "appending" as its not obvious more that one -machine arguement is allowed.

---
 hw/ppc/spapr_caps.c | 47 ++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)
hw/ppc/spapr_caps.c +32 -15
index bbb001f84a..1c0222a081 100644
@@ -37,6 +37,8 @@
 
 #include "hw/ppc/spapr.h"
 
+#define CAPABILITY_ERROR(X) "appending -machine " X
+
 typedef struct SpaprCapPossible {
     int num;            /* size of vals array below */
     const char *help;   /* help text for vals */
@@ -194,10 +196,12 @@ static void cap_htm_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
     }
     if (tcg_enabled()) {
         error_setg(errp,
-                   "No Transactional Memory support in TCG, try cap-htm=off");
+                   "No Transactional Memory support in TCG, try "
+                   CAPABILITY_ERROR("cap-htm=off"));
     } else if (kvm_enabled() && !kvmppc_has_cap_htm()) {
         error_setg(errp,
-"KVM implementation does not support Transactional Memory, try cap-htm=off"
+"KVM implementation does not support Transactional Memory, try "
+                   CAPABILITY_ERROR("cap-htm=off")
             );
     }
 }
@@ -215,7 +219,8 @@ 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 cap-vsx=off");
+        error_setg(errp, "VSX support not available, try "
+                   CAPABILITY_ERROR("cap-vsx=off"));
     }
 }
 
@@ -229,7 +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 cap-dfp=off");
+        error_setg(errp, "DFP support not available, try "
+                   CAPABILITY_ERROR("cap-dfp=off"));
     }
 }
 
@@ -249,11 +255,13 @@ static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
     if (tcg_enabled() && val) {
         /* TCG only supports broken, allow other values and print a warning */
         error_setg(&local_err,
-                   "TCG doesn't support requested feature, cap-cfpc=%s",
+                   "TCG doesn't support requested feature, "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),
                    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 cap-cfpc=%s",
+"Requested safe cache capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),
                    cap_cfpc_possible.vals[kvm_val]);
     }
 
@@ -281,7 +289,8 @@ 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 cap-sbbc=%s",
+"Requested safe bounds check capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-sbbc=%s"),
                    cap_sbbc_possible.vals[kvm_val]);
     }
 
@@ -312,7 +321,8 @@ 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 cap-ibs=%s",
+"Requested safe indirect branch capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-ibs=%s"),
                    cap_ibs_possible.vals[kvm_val]);
     }
 
@@ -401,11 +411,13 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
 
     if (tcg_enabled()) {
         error_setg(errp,
-                   "No Nested KVM-HV support in tcg, try cap-nested-hv=off");
+                   "No Nested KVM-HV support in tcg, try "
+                   CAPABILITY_ERROR("cap-nested-hv=off"));
     } else if (kvm_enabled()) {
         if (!kvmppc_has_cap_nested_kvm_hv()) {
             error_setg(errp,
-"KVM implementation does not support Nested KVM-HV, try cap-nested-hv=off");
+"KVM implementation does not support Nested KVM-HV, try "
+                       CAPABILITY_ERROR("cap-nested-hv=off"));
         } 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");
@@ -435,10 +447,12 @@ static void cap_large_decr_apply(SpaprMachineState *spapr,
 
         if (!kvm_nr_bits) {
             error_setg(errp,
-                       "No large decrementer support, try cap-large-decr=off");
+                       "No large decrementer support, try "
+                        CAPABILITY_ERROR("cap-large-decr=off"));
         } else if (pcc->lrg_decr_bits != kvm_nr_bits) {
             error_setg(errp,
-"KVM large decrementer size (%d) differs to model (%d), try -cap-large-decr=off",
+"KVM large decrementer size (%d) differs to model (%d), try "
+                CAPABILITY_ERROR("cap-large-decr=off"),
                 kvm_nr_bits, pcc->lrg_decr_bits);
         }
     }
@@ -454,7 +468,8 @@ static void cap_large_decr_cpu_apply(SpaprMachineState *spapr,
     if (kvm_enabled()) {
         if (kvmppc_enable_cap_large_decr(cpu, val)) {
             error_setg(errp,
-                       "No large decrementer support, try cap-large-decr=off");
+                       "No large decrementer support, try "
+                       CAPABILITY_ERROR("cap-large-decr=off"));
         }
     }
 
@@ -474,10 +489,12 @@ static void cap_ccf_assist_apply(SpaprMachineState *spapr, uint8_t val,
     if (tcg_enabled() && val) {
         /* TODO - for now only allow broken for TCG */
         error_setg(errp,
-"Requested count cache flush assist capability level not supported by tcg, try cap-ccf-assist=off");
+"Requested count cache flush assist capability level not supported by tcg, try "
+                   CAPABILITY_ERROR("cap-ccf-assist=off"));
     } else if (kvm_enabled() && (val > kvm_val)) {
         error_setg(errp,
-"Requested count cache flush assist capability level not supported by kvm, try cap-ccf-assist=off");
+"Requested count cache flush assist capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-ccf-assist=off"));
     }
 }
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 24 lines · On Thu, 1 Aug 2019 13:38:19 +1000 Daniel Black <[email protected]> wrote:

Its not immediately obvious how cap-X=Y setting need to be applied to the command line so, for spapr capability error messages, this has been clarified to:

..[try] appending -machine cap-X=Y

The wrong value messages have been left as is, as the user has found the right location.

---
v2 Improved error message thanks David Gibson

Left the "appending" as its not obvious more that one -machine arguement is allowed.

---
 hw/ppc/spapr_caps.c | 47 ++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)
hw/ppc/spapr_caps.c +0 -0
index bbb001f84a..1c0222a081 100644

hw/ppc/spapr_caps.c line 40

Quoted 4 lines
hw/ppc/spapr_caps.c +1 -0
@@ -37,6 +37,8 @@
 
 #include "hw/ppc/spapr.h"
 
+#define CAPABILITY_ERROR(X) "appending -machine " X

I would make that:

#define CAPABILITY_HINT() "try appending -machine " X

because it is really an hint for the user, not an error, and all original strings have "try", except...

Quoted 40 lines
hw/ppc/spapr_caps.c +9 -4
+
 typedef struct SpaprCapPossible {
     int num;            /* size of vals array below */
     const char *help;   /* help text for vals */
@@ -194,10 +196,12 @@ static void cap_htm_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
     }
     if (tcg_enabled()) {
         error_setg(errp,
-                   "No Transactional Memory support in TCG, try cap-htm=off");
+                   "No Transactional Memory support in TCG, try "
+                   CAPABILITY_ERROR("cap-htm=off"));
     } else if (kvm_enabled() && !kvmppc_has_cap_htm()) {
         error_setg(errp,
-"KVM implementation does not support Transactional Memory, try cap-htm=off"
+"KVM implementation does not support Transactional Memory, try "
+                   CAPABILITY_ERROR("cap-htm=off")
             );
     }
 }
@@ -215,7 +219,8 @@ 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 cap-vsx=off");
+        error_setg(errp, "VSX support not available, try "
+                   CAPABILITY_ERROR("cap-vsx=off"));
     }
 }
 
@@ -229,7 +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 cap-dfp=off");
+        error_setg(errp, "DFP support not available, try "
+                   CAPABILITY_ERROR("cap-dfp=off"));
     }
 }
 

hw/ppc/spapr_caps.c static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val, · line 259

Quoted 6 lines
hw/ppc/spapr_caps.c +2 -1
@@ -249,11 +255,13 @@ static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val,
     if (tcg_enabled() && val) {
         /* TCG only supports broken, allow other values and print a warning */
         error_setg(&local_err,
-                   "TCG doesn't support requested feature, cap-cfpc=%s",
+                   "TCG doesn't support requested feature, "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),

... this one, but it doesn't look like a hint to me. It just tells which is the unsupported cap.

hw/ppc/spapr_caps.c static void cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val, · line 265

Quoted 7 lines
hw/ppc/spapr_caps.c +2 -1
                    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 cap-cfpc=%s",
+"Requested safe cache capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),
                    cap_cfpc_possible.vals[kvm_val]);

Also, we have a dedicated API for hints, which are only printed under the monitor but ignored under QMP.

Not sure why it isn't used here but it should be something like:

        error_setg(errp, 
                   "Requested safe cache capability level not supported by kvm");
        error_append_hint(errp, CAPABILITY_HINT("cap-cfpc=%s") "\n",
                          cap_cfpc_possible.vals[kvm_val]);
Quoted 78 lines
hw/ppc/spapr_caps.c +18 -9
     }
 
@@ -281,7 +289,8 @@ 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 cap-sbbc=%s",
+"Requested safe bounds check capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-sbbc=%s"),
                    cap_sbbc_possible.vals[kvm_val]);
     }
 
@@ -312,7 +321,8 @@ 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 cap-ibs=%s",
+"Requested safe indirect branch capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-ibs=%s"),
                    cap_ibs_possible.vals[kvm_val]);
     }
 
@@ -401,11 +411,13 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
 
     if (tcg_enabled()) {
         error_setg(errp,
-                   "No Nested KVM-HV support in tcg, try cap-nested-hv=off");
+                   "No Nested KVM-HV support in tcg, try "
+                   CAPABILITY_ERROR("cap-nested-hv=off"));
     } else if (kvm_enabled()) {
         if (!kvmppc_has_cap_nested_kvm_hv()) {
             error_setg(errp,
-"KVM implementation does not support Nested KVM-HV, try cap-nested-hv=off");
+"KVM implementation does not support Nested KVM-HV, try "
+                       CAPABILITY_ERROR("cap-nested-hv=off"));
         } 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");
@@ -435,10 +447,12 @@ static void cap_large_decr_apply(SpaprMachineState *spapr,
 
         if (!kvm_nr_bits) {
             error_setg(errp,
-                       "No large decrementer support, try cap-large-decr=off");
+                       "No large decrementer support, try "
+                        CAPABILITY_ERROR("cap-large-decr=off"));
         } else if (pcc->lrg_decr_bits != kvm_nr_bits) {
             error_setg(errp,
-"KVM large decrementer size (%d) differs to model (%d), try -cap-large-decr=off",
+"KVM large decrementer size (%d) differs to model (%d), try "
+                CAPABILITY_ERROR("cap-large-decr=off"),
                 kvm_nr_bits, pcc->lrg_decr_bits);
         }
     }
@@ -454,7 +468,8 @@ static void cap_large_decr_cpu_apply(SpaprMachineState *spapr,
     if (kvm_enabled()) {
         if (kvmppc_enable_cap_large_decr(cpu, val)) {
             error_setg(errp,
-                       "No large decrementer support, try cap-large-decr=off");
+                       "No large decrementer support, try "
+                       CAPABILITY_ERROR("cap-large-decr=off"));
         }
     }
 
@@ -474,10 +489,12 @@ static void cap_ccf_assist_apply(SpaprMachineState *spapr, uint8_t val,
     if (tcg_enabled() && val) {
         /* TODO - for now only allow broken for TCG */
         error_setg(errp,
-"Requested count cache flush assist capability level not supported by tcg, try cap-ccf-assist=off");
+"Requested count cache flush assist capability level not supported by tcg, try "
+                   CAPABILITY_ERROR("cap-ccf-assist=off"));
     } else if (kvm_enabled() && (val > kvm_val)) {
         error_setg(errp,
-"Requested count cache flush assist capability level not supported by kvm, try cap-ccf-assist=off");
+"Requested count cache flush assist capability level not supported by kvm, try "
+                   CAPABILITY_ERROR("cap-ccf-assist=off"));
     }
 }
 
#2 lore raw
Quoted 7 lines · On Thu, 1 Aug 2019 12:41:59 +0200 Greg Kurz <[email protected]> wrote:
Quoted 4 lines · On Thu, 1 Aug 2019 13:38:19 +1000 Daniel Black <[email protected]> wrote:

Its not immediately obvious how cap-X=Y setting need to be applied to the command line so, for spapr capability error messages, this has been clarified to:

...

Quoted 7 lines
Quoted 7 lines

index bbb001f84a..1c0222a081 100644

hw/ppc/spapr_caps.c +0 -0
@@ -37,6 +37,8 @@
 
 #include "hw/ppc/spapr.h"
 
Quoted 8 lines

hw/ppc/spapr_caps.c line 40

Quoted 1 line
hw/ppc/spapr_caps.c +1 -0
+#define CAPABILITY_ERROR(X) "appending -machine " X  

I would make that:

#define CAPABILITY_HINT() "try appending -machine " X

because it is really an hint for the user, not an
error,

Works for me. At the lowest layer it is a hint.

Quoted 1 line

and all original strings have "try",

True.

Quoted 14 lines

except...

hw/ppc/spapr_caps.c

Quoted 8 lines
hw/ppc/spapr_caps.c +0 -0
@@ -249,11 +255,13 @@ static void

cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val, if (tcg_enabled() && val) { /* TCG only supports broken, allow other values and print a warning */ error_setg(&local_err,
- "TCG doesn't support requested feature,
cap-cfpc=%s",

hw/ppc/spapr_caps.c +2 -0
+                   "TCG doesn't support requested feature, "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),  

... this one, but it doesn't look like a hint to me. It just tells which is the unsupported cap.

This is one of 3 that local_error (commit 006e9d3618698eeef2f3e07628d22cb6f5c2a039) - intentionally just a warning and to TLDR the commit/Suraj conversation; defaults apply to all machine types; hardware security measures don't make sense in TCG; hence warning.

For every function with CAPABILITY_[ERROR|HINT] its called by spapr_caps_apply, has its errp as &error_fatal (intentionally - spoke to Suraj - migrations to machines without capabilities need to fail and defaults (kvm) should be secure unless explicitly disabled).

Quoted 11 lines
Quoted 8 lines
                    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 cap-cfpc=%s", +"Requested safe cache capability level not supported by kvm, try "
+ CAPABILITY_ERROR("cap-cfpc=%s"),

                    cap_cfpc_possible.vals[kvm_val]);  

Also, we have a dedicated API for hints, which are only printed under the monitor but ignored under QMP.

Ok.

Quoted 1 line

Not sure why it isn't used here but it should be something like:

If error_append_hint should be used for fatal errors (all that use errp), then this patten should be applied further to CAPABILITY_[HINT|ERROR] functions.

If error_append_hint needs to apply to warnings cap_[cfpc/sbbc/ibs]_apply functions need to use it.

Would I be right in I'm assuming that the below pattern needs to apply to both of these cases?

Quoted 5 lines

error_setg(errp,
"Requested safe cache capability level not
supported by kvm");
error_append_hint(errp,
CAPABILITY_HINT("cap-cfpc=%s") "\n", cap_cfpc_possible.vals[kvm_val]);

This is going a little beyond the scope of fixing a message, ok, but lets not extend the scope too much more.

Reviewed-by
#3 lore raw
Quoted 48 lines · On Fri, 2 Aug 2019 11:03:48 +1000 Daniel Black <[email protected]> wrote:
Quoted 7 lines · On Thu, 1 Aug 2019 12:41:59 +0200 Greg Kurz <[email protected]> wrote:
Quoted 4 lines · On Thu, 1 Aug 2019 13:38:19 +1000 Daniel Black <[email protected]> wrote:

Its not immediately obvious how cap-X=Y setting need to be applied to the command line so, for spapr capability error messages, this has been clarified to:

...

Quoted 7 lines
Quoted 7 lines

index bbb001f84a..1c0222a081 100644

hw/ppc/spapr_caps.c +0 -0
@@ -37,6 +37,8 @@
 
 #include "hw/ppc/spapr.h"
 
Quoted 8 lines

hw/ppc/spapr_caps.c line 40

Quoted 1 line
hw/ppc/spapr_caps.c +1 -0
+#define CAPABILITY_ERROR(X) "appending -machine " X  

I would make that:

#define CAPABILITY_HINT() "try appending -machine " X

because it is really an hint for the user, not an
error,

Works for me. At the lowest layer it is a hint.

Quoted 1 line

and all original strings have "try",

True.

Quoted 14 lines

except...

hw/ppc/spapr_caps.c

Quoted 8 lines
hw/ppc/spapr_caps.c +0 -0
@@ -249,11 +255,13 @@ static void

cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val, if (tcg_enabled() && val) { /* TCG only supports broken, allow other values and print a warning */ error_setg(&local_err,
- "TCG doesn't support requested feature,
cap-cfpc=%s",

hw/ppc/spapr_caps.c +2 -0
+                   "TCG doesn't support requested feature, "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),  

... this one, but it doesn't look like a hint to me. It just tells which is the unsupported cap.

Quoted 6 lines

This is one of 3 that local_error (commit 006e9d3618698eeef2f3e07628d22cb6f5c2a039) - intentionally just a warning and to TLDR the commit/Suraj conversation; defaults apply to all machine types; hardware security measures don't make sense in TCG; hence warning.

Sure. What I meant is that the warning for "cap-cfpc" should be left alone, otherwise we get:

$ ppc64-softmmu/qemu-system-ppc64 -nodefaults -nographic -machine pseries,accel=tcg
qemu-system-ppc64: warning: TCG doesn't support requested feature, appending -machine cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-sbbc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ibs=workaround

and even weirder:

$ ppc64-softmmu/qemu-system-ppc64 -nodefaults -nographic -machine pseries,accel=tcg -machine cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, appending -machine cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-sbbc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ibs=workaround
Quoted 17 lines

For every function with CAPABILITY_[ERROR|HINT] its called by spapr_caps_apply, has its errp as &error_fatal (intentionally - spoke to Suraj - migrations to machines without capabilities need to fail and defaults (kvm) should be secure unless explicitly disabled).

Quoted 11 lines
Quoted 8 lines
                    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 cap-cfpc=%s", +"Requested safe cache capability level not supported by kvm, try "
+ CAPABILITY_ERROR("cap-cfpc=%s"),

                    cap_cfpc_possible.vals[kvm_val]);  

Also, we have a dedicated API for hints, which are only printed under the monitor but ignored under QMP.

Quoted 8 lines

Ok.

Quoted 1 line

Not sure why it isn't used here but it should be something like:

If error_append_hint should be used for fatal errors (all that use errp), then this patten should be applied further to CAPABILITY_[HINT|ERROR] functions.

Hmm... looking again at error_append_hint(), it shouldn't be passed &error_fatal or &error_abort. This calls for an extra local_err and error_propagate() dance... Definitely not in the scope of this patch.

Quoted 3 lines

If error_append_hint needs to apply to warnings cap_[cfpc/sbbc/ibs]_apply functions need to use it.

The current warnings from commit 006e9d3618698eeef2f3e07628d22cb6f5c2a039 don't contain hints. We could potentially add one that says "try appending -machine cap-blah=broken" but it doesn't bring much...

Quoted 12 lines

Would I be right in I'm assuming that the below pattern needs to apply to both of these cases?

Quoted 5 lines

error_setg(errp,
"Requested safe cache capability level not
supported by kvm");
error_append_hint(errp,
CAPABILITY_HINT("cap-cfpc=%s") "\n", cap_cfpc_possible.vals[kvm_val]);

This is going a little beyond the scope of fixing a message, ok, but lets not extend the scope too much more.

Yes, I agree. Your patch should only be about fixing the message. I'll have a look at the error_append_hint() story when I'm back from holidays :)

So, to sum up:
- s/CAPABILITY_ERROR/CAPABILITY_HINT and move "try" there
- drop the unwanted change in the "cap-cfpc" warning

With these fixed:

Cheers,

--
Greg

#4 lore raw
In reply to Daniel Black
Quoted 22 lines · Daniel Black
Quoted 7 lines · On Thu, 1 Aug 2019 12:41:59 +0200 Greg Kurz <[email protected]> wrote:
Quoted 4 lines · On Thu, 1 Aug 2019 13:38:19 +1000 Daniel Black <[email protected]> wrote:

Its not immediately obvious how cap-X=Y setting need to be applied to the command line so, for spapr capability error messages, this has been clarified to:

...

Quoted 11 lines

hw/ppc/spapr_caps.c line 40

Quoted 8 lines

index bbb001f84a..1c0222a081 100644

hw/ppc/spapr_caps.c +1 -0
@@ -37,6 +37,8 @@
 
 #include "hw/ppc/spapr.h"
 
+#define CAPABILITY_ERROR(X) "appending -machine " X  

I would make that:

Quoted 6 lines
Quoted 4 lines

#define CAPABILITY_HINT() "try appending -machine " X

because it is really an hint for the user, not an
error,

Works for me. At the lowest layer it is a hint.

Oh.. of course it is. Which means we should be using the error_append_hint() system that's for exactly this sort of information.

Sorry I didn't think of that earlier.

Quoted 66 lines
Quoted 2 lines

and all original strings have "try",

True.

Quoted 14 lines

except...

hw/ppc/spapr_caps.c

Quoted 8 lines
hw/ppc/spapr_caps.c +0 -0
@@ -249,11 +255,13 @@ static void

cap_safe_cache_apply(SpaprMachineState *spapr, uint8_t val, if (tcg_enabled() && val) { /* TCG only supports broken, allow other values and print a warning */ error_setg(&local_err,
- "TCG doesn't support requested feature,
cap-cfpc=%s",

hw/ppc/spapr_caps.c +2 -0
+                   "TCG doesn't support requested feature, "
+                   CAPABILITY_ERROR("cap-cfpc=%s"),  

... this one, but it doesn't look like a hint to me. It just tells which is the unsupported cap.

This is one of 3 that local_error (commit 006e9d3618698eeef2f3e07628d22cb6f5c2a039) - intentionally just a warning and to TLDR the commit/Suraj conversation; defaults apply to all machine types; hardware security measures don't make sense in TCG; hence warning.

For every function with CAPABILITY_[ERROR|HINT] its called by spapr_caps_apply, has its errp as &error_fatal (intentionally - spoke to Suraj - migrations to machines without capabilities need to fail and defaults (kvm) should be secure unless explicitly disabled).

Quoted 11 lines
Quoted 8 lines
                    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 cap-cfpc=%s", +"Requested safe cache capability level not supported by kvm, try "
+ CAPABILITY_ERROR("cap-cfpc=%s"),

                    cap_cfpc_possible.vals[kvm_val]);  

Also, we have a dedicated API for hints, which are only printed under the monitor but ignored under QMP.

Ok.

Quoted 1 line

Not sure why it isn't used here but it should be something like:

If error_append_hint should be used for fatal errors (all that use errp), then this patten should be applied further to CAPABILITY_[HINT|ERROR] functions.

If error_append_hint needs to apply to warnings cap_[cfpc/sbbc/ibs]_apply functions need to use it.

Would I be right in I'm assuming that the below pattern needs to apply to both of these cases?

Quoted 5 lines

error_setg(errp,
"Requested safe cache capability level not
supported by kvm");
error_append_hint(errp,
CAPABILITY_HINT("cap-cfpc=%s") "\n", cap_cfpc_possible.vals[kvm_val]);

This is going a little beyond the scope of fixing a message, ok, but lets not extend the scope too much more.

Signature · 4 lines
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