Skip to contentSkip to conversation

target: RFC: display deprecation flag for '-cpu help'

PATCH In review Daniel P. Berrangé 2 participants 7 messages Jul 22, 2022

lore
Share & tools
lore
#0 lore raw

v2 cover target: RFC: display deprecation flag for '-cpu help'

When querying '-cpu help' there is no presentation of fact that a CPU may be deprecated. The user just has to try it and see if they get a depecation message at runtime. The QMP command for querying CPUs report a deprecation bool flagreason.

The Icelake-Client CPU (removed in 6df39f5e583ca0f67bd934d1327f9ead2e3bd49c) handled this by modifying the '.notes' section to add the word 'deprecated':

            {
                .version = 2,
                .note = "no TSX, deprecated",
                .alias = "Icelake-Client-noTSX",
                .props = (PropValue[]) {
                    { "hle", "off" },
                    { "rtm", "off" },
                    { /* end of list */ }
                },
            },

This relies on the person deprecating the CPU to remember to do this, and is redundant when this info is already expressed in the '.deprecation_note' field.

This short series suggests just modifying the '-cpu help' formatter so that it displays '(deprecated)' next to any CPUs

eg

$ qemu-system-x86_64 -cpu help:
Available CPUs:
x86 486                   (alias configured by machine type) (deprecated)

This series touched x86_64, s390x, and aarch64 because that's all I personally needed from a downstream POV, but any & all of the targets would benefit from this. They have each implemented the '-cpu help' logic independantly though, and unifying that code is not entirely straightforward.

Changed in v2:

- Just include "deprecated" as a flag, not full description which made the output too verbose and long lines.

Daniel P. Berrangé (3):
target/i386: display deprecation status in '-cpu help' target/s390x: display deprecation status in '-cpu help' target/arm: display deprecation status in '-cpu help'

 target/arm/helper.c       |  7 ++++++-
 target/i386/cpu.c         |  5 +++++
 target/s390x/cpu_models.c | 23 ++++++++++++++++++-----
 3 files changed, 29 insertions(+), 6 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH v2 1/3 target/i386: display deprecation status in '-cpu help'

When the user queries CPU models via QMP there is a 'deprecated' flag present, however, this is not done for the CLI '-cpu help' command.

---
 target/i386/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)
target/i386/cpu.c +5 -0
index 6a57ef13af..70f78340e1 100644
@@ -4837,6 +4837,11 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data)
         desc = g_strdup_printf("%s", model_id);
     }
 
+    if (cc->model && cc->model->cpudef->deprecation_note) {
+        g_autofree char *olddesc = desc;
+        desc = g_strdup_printf("%s (deprecated)", olddesc);
+    }
+
     qemu_printf("x86 %-20s  %s\n", name, desc);
 }
 
Signature · 1 line
2.36.1
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] target/i386: display deprecation status in '-cpu help'

Quoted 7 lines · Daniel P. Berrangé

When the user queries CPU models via QMP there is a 'deprecated' flag present, however, this is not done for the CLI '-cpu help' command.

---
 target/i386/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)
#3 lore raw

PATCH v2 2/3 target/s390x: display deprecation status in '-cpu help'

In reply to Daniel P. Berrangé

When the user queries CPU models via QMP there is a 'deprecated' flag present, however, this is not done for the CLI '-cpu help' command.

---
 target/s390x/cpu_models.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
target/s390x/cpu_models.c +18 -5
index 1a562d2801..c3a4f80633 100644
@@ -334,18 +334,31 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,
 static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_data)
 {
     const S390CPUClass *scc = S390_CPU_CLASS((ObjectClass *)data);
+    CPUClass *cc = CPU_CLASS(scc);
     char *name = g_strdup(object_class_get_name((ObjectClass *)data));
-    const char *details = "";
+    g_autoptr(GString) details = g_string_new("");
 
     if (scc->is_static) {
-        details = "(static, migration-safe)";
-    } else if (scc->is_migration_safe) {
-        details = "(migration-safe)";
+        g_string_append(details, "static, ");
+    }
+    if (scc->is_migration_safe) {
+        g_string_append(details, "migration-safe, ");
+    }
+    if (cc->deprecation_note) {
+        g_string_append(details, "deprecated, ");
+    }
+    if (details->len) {
+        /* cull trailing ', ' */
+        g_string_truncate(details, details->len - 2);
     }
 
     /* strip off the -s390x-cpu */
     g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
-    qemu_printf("s390 %-15s %-35s %s\n", name, scc->desc, details);
+    if (details->len) {
+        qemu_printf("s390 %-15s %-35s (%s)\n", name, scc->desc, details->str);
+    } else {
+        qemu_printf("s390 %-15s %-35s\n", name, scc->desc);
+    }
     g_free(name);
 }
 
Signature · 1 line
2.36.1
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] target/s390x: display deprecation status in '-cpu help'

Quoted 7 lines · Daniel P. Berrangé

When the user queries CPU models via QMP there is a 'deprecated' flag present, however, this is not done for the CLI '-cpu help' command.

---
 target/s390x/cpu_models.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
#5 lore raw

PATCH v2 3/3 target/arm: display deprecation status in '-cpu help'

In reply to Daniel P. Berrangé

When the user queries CPU models via QMP there is a 'deprecated' flag present, however, this is not done for the CLI '-cpu help' command.

---
 target/arm/helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
target/arm/helper.c +6 -1
index 1a8b06410e..ef4e33f309 100644
@@ -8185,12 +8185,17 @@ static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)
 static void arm_cpu_list_entry(gpointer data, gpointer user_data)
 {
     ObjectClass *oc = data;
+    CPUClass *cc = CPU_CLASS(oc);
     const char *typename;
     char *name;
 
     typename = object_class_get_name(oc);
     name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_ARM_CPU));
-    qemu_printf("  %s\n", name);
+    if (cc->deprecation_note) {
+        qemu_printf("  %s (deprecated)\n", name);
+    } else {
+        qemu_printf("  %s\n", name);
+    }
     g_free(name);
 }
 
Signature · 1 line
2.36.1
Reviewed-by on v2 3/3
#6 lore raw

Re: [PATCH v2 3/3] target/arm: display deprecation status in '-cpu help'

Quoted 7 lines · Daniel P. Berrangé

When the user queries CPU models via QMP there is a 'deprecated' flag present, however, this is not done for the CLI '-cpu help' command.

---
 target/arm/helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)