Blame SOURCES/kvm-i386-display-known-CPUID-features-linewrapped-in-alp.patch

016a62
From e7f11d39d1ef78f47ed6d45ecd278d51c502f131 Mon Sep 17 00:00:00 2001
016a62
From: Paolo Bonzini <pbonzini@redhat.com>
016a62
Date: Fri, 22 Nov 2019 11:53:37 +0000
016a62
Subject: [PATCH 04/16] i386: display known CPUID features linewrapped, in
016a62
 alphabetical order
016a62
MIME-Version: 1.0
016a62
Content-Type: text/plain; charset=UTF-8
016a62
Content-Transfer-Encoding: 8bit
016a62
016a62
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
016a62
Message-id: <20191122115348.25000-5-pbonzini@redhat.com>
016a62
Patchwork-id: 92605
016a62
O-Subject: [RHEL8.2/rhel qemu-kvm PATCH 04/15] i386: display known CPUID features linewrapped, in alphabetical order
016a62
Bugzilla: 1689270
016a62
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
016a62
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
016a62
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
016a62
016a62
From: Daniel P. Berrangé <berrange@redhat.com>
016a62
016a62
When using '-cpu help' the list of CPUID features is grouped according
016a62
to the internal low level CPUID grouping. The data printed results in
016a62
very long lines too.
016a62
016a62
This combines to make it hard for users to read the output and identify
016a62
if QEMU knows about the feature they wish to use.
016a62
016a62
This change gets rid of the grouping of features and treats all flags as
016a62
single list. The list is sorted into alphabetical order and the printing
016a62
with line wrapping at the 77th column.
016a62
016a62
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
016a62
Message-Id: <20180606165527.17365-4-berrange@redhat.com>
016a62
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
016a62
(cherry picked from commit cc643b1e7898414b56f551bbd42d4ed8c2ae127a)
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 target/i386/cpu.c | 41 +++++++++++++++++++++++++++--------------
016a62
 1 file changed, 27 insertions(+), 14 deletions(-)
016a62
016a62
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
016a62
index 52f1f33..d0c48c2 100644
016a62
--- a/target/i386/cpu.c
016a62
+++ b/target/i386/cpu.c
016a62
@@ -3651,17 +3651,21 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
016a62
 
016a62
 /* Print all cpuid feature names in featureset
016a62
  */
016a62
-static void listflags(FILE *f, fprintf_function print, const char **featureset)
016a62
+static void listflags(FILE *f, fprintf_function print, GList *features)
016a62
 {
016a62
-    int bit;
016a62
-    bool first = true;
016a62
-
016a62
-    for (bit = 0; bit < 32; bit++) {
016a62
-        if (featureset[bit]) {
016a62
-            print(f, "%s%s", first ? "" : " ", featureset[bit]);
016a62
-            first = false;
016a62
+    size_t len = 0;
016a62
+    GList *tmp;
016a62
+
016a62
+    for (tmp = features; tmp; tmp = tmp->next) {
016a62
+        const char *name = tmp->data;
016a62
+        if ((len + strlen(name) + 1) >= 75) {
016a62
+            print(f, "\n");
016a62
+            len = 0;
016a62
         }
016a62
+        print(f, "%s%s", len == 0 ? "  " : " ", name);
016a62
+        len += strlen(name) + 1;
016a62
     }
016a62
+    print(f, "\n");
016a62
 }
016a62
 
016a62
 /* Sort alphabetically by type name, respecting X86CPUClass::ordering. */
016a62
@@ -3708,26 +3712,35 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data)
016a62
 /* list available CPU models and flags */
016a62
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
016a62
 {
016a62
-    int i;
016a62
+    int i, j;
016a62
     CPUListState s = {
016a62
         .file = f,
016a62
         .cpu_fprintf = cpu_fprintf,
016a62
     };
016a62
     GSList *list;
016a62
+    GList *names = NULL;
016a62
 
016a62
     (*cpu_fprintf)(f, "Available CPUs:\n");
016a62
     list = get_sorted_cpu_model_list();
016a62
     g_slist_foreach(list, x86_cpu_list_entry, &s);
016a62
     g_slist_free(list);
016a62
 
016a62
-    (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
016a62
+    names = NULL;
016a62
     for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
016a62
         FeatureWordInfo *fw = &feature_word_info[i];
016a62
-
016a62
-        (*cpu_fprintf)(f, "  ");
016a62
-        listflags(f, cpu_fprintf, fw->feat_names);
016a62
-        (*cpu_fprintf)(f, "\n");
016a62
+        for (j = 0; j < 32; j++) {
016a62
+            if (fw->feat_names[j]) {
016a62
+                names = g_list_append(names, (gpointer)fw->feat_names[j]);
016a62
+            }
016a62
+        }
016a62
     }
016a62
+
016a62
+    names = g_list_sort(names, (GCompareFunc)strcmp);
016a62
+
016a62
+    (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n");
016a62
+    listflags(f, cpu_fprintf, names);
016a62
+    (*cpu_fprintf)(f, "\n");
016a62
+    g_list_free(names);
016a62
 }
016a62
 
016a62
 static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
016a62
-- 
016a62
1.8.3.1
016a62