[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/12] i386: display known CPUID features linewrapped
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL 04/12] i386: display known CPUID features linewrapped, in alphabetical order |
Date: |
Mon, 25 Jun 2018 19:25:16 -0300 |
From: Daniel P. Berrangé <address@hidden>
When using '-cpu help' the list of CPUID features is grouped according
to the internal low level CPUID grouping. The data printed results in
very long lines too.
This combines to make it hard for users to read the output and identify
if QEMU knows about the feature they wish to use.
This change gets rid of the grouping of features and treats all flags as
single list. The list is sorted into alphabetical order and the printing
with line wrapping at the 77th column.
Signed-off-by: Daniel P. Berrangé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
target/i386/cpu.c | 41 +++++++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 19ac1e6569..9da4920421 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3331,17 +3331,21 @@ static void
x86_cpu_class_check_missing_features(X86CPUClass *xcc,
/* Print all cpuid feature names in featureset
*/
-static void listflags(FILE *f, fprintf_function print, const char **featureset)
+static void listflags(FILE *f, fprintf_function print, GList *features)
{
- int bit;
- bool first = true;
-
- for (bit = 0; bit < 32; bit++) {
- if (featureset[bit]) {
- print(f, "%s%s", first ? "" : " ", featureset[bit]);
- first = false;
+ size_t len = 0;
+ GList *tmp;
+
+ for (tmp = features; tmp; tmp = tmp->next) {
+ const char *name = tmp->data;
+ if ((len + strlen(name) + 1) >= 75) {
+ print(f, "\n");
+ len = 0;
}
+ print(f, "%s%s", len == 0 ? " " : " ", name);
+ len += strlen(name) + 1;
}
+ print(f, "\n");
}
/* Sort alphabetically by type name, respecting X86CPUClass::ordering. */
@@ -3392,26 +3396,35 @@ static void x86_cpu_list_entry(gpointer data, gpointer
user_data)
/* list available CPU models and flags */
void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
- int i;
+ int i, j;
CPUListState s = {
.file = f,
.cpu_fprintf = cpu_fprintf,
};
GSList *list;
+ GList *names = NULL;
(*cpu_fprintf)(f, "Available CPUs:\n");
list = get_sorted_cpu_model_list();
g_slist_foreach(list, x86_cpu_list_entry, &s);
g_slist_free(list);
- (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
+ names = NULL;
for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
FeatureWordInfo *fw = &feature_word_info[i];
-
- (*cpu_fprintf)(f, " ");
- listflags(f, cpu_fprintf, fw->feat_names);
- (*cpu_fprintf)(f, "\n");
+ for (j = 0; j < 32; j++) {
+ if (fw->feat_names[j]) {
+ names = g_list_append(names, (gpointer)fw->feat_names[j]);
+ }
+ }
}
+
+ names = g_list_sort(names, (GCompareFunc)strcmp);
+
+ (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
+ listflags(f, cpu_fprintf, names);
+ (*cpu_fprintf)(f, "\n");
+ g_list_free(names);
}
static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
--
2.18.0.rc1.1.g3f1ff2140
- [Qemu-devel] [PULL 00/12] x86 queue, 2018-06-25, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 01/12] i386: Add support for CPUID_8000_001E for AMD, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 02/12] i386: improve alignment of CPU model listing, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 03/12] i386: improve sorting of CPU model names, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 04/12] i386: display known CPUID features linewrapped, in alphabetical order,
Eduardo Habkost <=
- [Qemu-devel] [PULL 05/12] i386: Remove osxsave CPUID flag name, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 06/12] i386: Remove ospke CPUID flag name, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 07/12] i386: define the AMD 'amd-ssbd' CPUID feature bit, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 08/12] i386: Define AMD's no SSB mitigation needed., Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 09/12] i386: Allow TOPOEXT to be enabled on older kernels, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 10/12] i386: Fix up the Node id for CPUID_8000_001E, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 11/12] i386: Enable TOPOEXT feature on AMD EPYC CPU, Eduardo Habkost, 2018/06/25
- [Qemu-devel] [PULL 12/12] i386: Remove generic SMT thread check, Eduardo Habkost, 2018/06/25
- Re: [Qemu-devel] [PULL 00/12] x86 queue, 2018-06-25, Peter Maydell, 2018/06/26