Patchwork [RFC,08/11] s390/qemu: cpu model command line option help

login
register
mail settings
Submitter Michael Mueller
Date Oct. 2, 2013, 11:33 a.m.
Message ID <1380713622-22325-9-git-send-email-mimu@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/279699/
State New
Headers show

Comments

Michael Mueller - Oct. 2, 2013, 11:33 a.m.
This patch provides a list of supported cpu models and aliases in the
current host context. See command line option -cpu {help|?}

The returned list is determined from the current host and and contains
also well know alias names. It is sorted by appearance of the respective
system:

s390 2064-ga1   IBM zSeries 900 GA1
s390 2064-ga2   IBM zSeries 900 GA2
s390 2064-ga3   IBM zSeries 900 GA3
s390 2064       (alias for 2064-ga3)
s390 z900       (alias for 2064-ga3)
s390 2066-ga1   IBM zSeries 800 GA1
s390 2066       (alias for 2066-ga1)
s390 z800       (alias for 2066-ga1)
s390 2084-ga1   IBM zSeries 990 GA1
s390 2084-ga2   IBM zSeries 990 GA2
s390 2084-ga3   IBM zSeries 990 GA3
s390 2084-ga4   IBM zSeries 990 GA4
s390 2084-ga5   IBM zSeries 990 GA5
s390 2084       (alias for 2084-ga5)
s390 z990       (alias for 2084-ga5)
s390 2086-ga1   IBM zSeries 890 GA1
s390 2086-ga2   IBM zSeries 890 GA2
s390 2086-ga3   IBM zSeries 890 GA3
s390 2086       (alias for 2086-ga3)
s390 z890       (alias for 2086-ga3)
s390 2094-ga1   IBM Sytems z9 EC GA1
s390 2094-ga2   IBM Sytems z9 EC GA2
s390 2094-ga3   IBM Sytems z9 EC GA3
s390 2094       (alias for 2094-ga3)
s390 z9         (alias for 2094-ga3)
s390 2096-ga1   IBM Sytems z9 BC GA1
s390 2096-ga2   IBM Sytems z9 BC GA2
s390 2096       (alias for 2096-ga2)
s390 z9-bc      (alias for 2096-ga2)
s390 2097-ga1   IBM Sytems z10 EC GA1
s390 2097-ga2   IBM Sytems z10 EC GA2
s390 2097-ga3   IBM Sytems z10 EC GA3
s390 2097       (alias for 2097-ga3)
s390 z10        (alias for 2097-ga3)
s390 2098-ga1   IBM Sytems z10 BC GA1
s390 2098-ga2   IBM Sytems z10 BC GA2
s390 2098       (alias for 2098-ga2)
s390 z10-bc     (alias for 2098-ga2)
s390 2817-ga1   IBM zEnterprise 196 GA1
s390 2817-ga2   IBM zEnterprise 196 GA2
s390 2817       (alias for 2817-ga2)
s390 z196       (alias for 2817-ga2)
s390 2818-ga1   IBM zEnterprise 114 GA1
s390 2818       (alias for 2818-ga1)
s390 z114       (alias for 2818-ga1)
s390 2827-ga1   IBM zEnterprise EC12 GA1
s390 2827       (alias for 2827-ga1)
s390 zEC12      (alias for 2827-ga1)
s390 host       (alias for 2827-ga1)

Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
 target-s390x/cpu-models.c | 30 ++++++++++++++++++++++++++++++
 target-s390x/cpu-models.h |  1 +
 target-s390x/cpu.c        | 16 +++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)

Patch

diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index ecf94a4..68b978a 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -558,6 +558,36 @@  out:
     return ret;
 }
 
+void s390_cpu_list_entry(gpointer data, gpointer user_data)
+{
+    ObjectClass *alias_oc, *oc = data;
+    CPUListState *s = user_data;
+    DeviceClass  *dc = DEVICE_CLASS(oc);
+    S390CPUClass *cc = S390_CPU_CLASS(oc);
+    const char *typename = object_class_get_name(oc);
+    S390CPUAlias *alias;
+    GSList *item;
+    char *name;
+
+    if (!cc->is_active) {
+        return;
+    }
+    name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_S390_CPU));
+    (*s->cpu_fprintf)(s->file, "s390 %-10s %s\n", name, dc->desc);
+
+    for (item = s390_cpu_aliases; item != NULL; item = item->next) {
+        alias = (S390CPUAlias *) item->data;
+        alias_oc = s390_cpu_class_by_name(alias->model);
+        if (alias_oc != oc) {
+            continue;
+        }
+        (*s->cpu_fprintf)(s->file, "s390 %-10s (alias for %s)\n",
+                          alias->name, name);
+    }
+
+    g_free(name);
+}
+
 /* define S390 CPU model classes */
 S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
 S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index 6164114..fd01876 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -53,6 +53,7 @@  int s390_request_kvm_cpu_config(S390CPUClass *cc);
 gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b);
 int s390_setup_cpu_classes(struct S390HostProps *prop);
 ObjectClass *s390_cpu_class_by_name(const char *name);
+void s390_cpu_list_entry(gpointer data, gpointer user_data);
 
 /*
  * bits 0-7   : CMOS generation
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 3c89f8a..0fccc72 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -24,6 +24,7 @@ 
  */
 
 #include "cpu.h"
+#include "cpu-models.h"
 #include "qemu-common.h"
 #include "qemu/timer.h"
 #include "hw/hw.h"
@@ -38,7 +39,20 @@ 
 void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
 #ifdef CONFIG_KVM
-    (*cpu_fprintf)(f, "s390 %16s\n", "host");
+    CPUListState s = {
+        .file = f,
+        .cpu_fprintf = cpu_fprintf,
+    };
+    GSList *list;
+
+    if (kvm_enabled()) {
+        list = object_class_get_list(TYPE_S390_CPU, false);
+        list = g_slist_sort(list, s390_cpu_class_asc_order_compare);
+        g_slist_foreach(list, s390_cpu_list_entry, &s);
+        g_slist_free(list);
+    } else {
+        (*cpu_fprintf)(f, "s390 host\n");
+    }
 #endif
 }