From nobody Tue Feb 10 23:01:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528304314939559.5611708859509; Wed, 6 Jun 2018 09:58:34 -0700 (PDT) Received: from localhost ([::1]:53605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbla-0006dp-9w for importer@patchew.org; Wed, 06 Jun 2018 12:58:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbig-0004by-BE for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQbif-0003yg-2Q for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34936 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQbie-0003xU-Ru for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E53B81ACA85; Wed, 6 Jun 2018 16:55:32 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81C7F2024CCB; Wed, 6 Jun 2018 16:55:31 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 6 Jun 2018 17:55:27 +0100 Message-Id: <20180606165527.17365-4-berrange@redhat.com> In-Reply-To: <20180606165527.17365-1-berrange@redhat.com> References: <20180606165527.17365-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 06 Jun 2018 16:55:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 06 Jun 2018 16:55:32 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/3] i386: display known CPUID features linewrapped, in alphabetical order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 cb074082b3..8043e41be8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3157,17 +3157,21 @@ static void x86_cpu_class_check_missing_features(X8= 6CPUClass *xcc, =20 /* Print all cpuid feature names in featureset */ -static void listflags(FILE *f, fprintf_function print, const char **featur= eset) +static void listflags(FILE *f, fprintf_function print, GList *features) { - int bit; - bool first =3D true; - - for (bit =3D 0; bit < 32; bit++) { - if (featureset[bit]) { - print(f, "%s%s", first ? "" : " ", featureset[bit]); - first =3D false; + size_t len =3D 0; + GList *tmp; + + for (tmp =3D features; tmp; tmp =3D tmp->next) { + const char *name =3D tmp->data; + if ((len + strlen(name) + 1) >=3D 75) { + print(f, "\n"); + len =3D 0; } + print(f, "%s%s", len =3D=3D 0 ? " " : " ", name); + len +=3D strlen(name) + 1; } + print(f, "\n"); } =20 /* Sort alphabetically by type name, respecting X86CPUClass::ordering. */ @@ -3218,26 +3222,35 @@ static void x86_cpu_list_entry(gpointer data, gpoin= ter 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 =3D { .file =3D f, .cpu_fprintf =3D cpu_fprintf, }; GSList *list; + GList *names =3D NULL; =20 (*cpu_fprintf)(f, "Available CPUs:\n"); list =3D get_sorted_cpu_model_list(); g_slist_foreach(list, x86_cpu_list_entry, &s); g_slist_free(list); =20 - (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n"); + names =3D NULL; for (i =3D 0; i < ARRAY_SIZE(feature_word_info); i++) { FeatureWordInfo *fw =3D &feature_word_info[i]; - - (*cpu_fprintf)(f, " "); - listflags(f, cpu_fprintf, fw->feat_names); - (*cpu_fprintf)(f, "\n"); + for (j =3D 0; j < 32; j++) { + if (fw->feat_names[j]) { + names =3D g_list_append(names, (gpointer)fw->feat_names[j]= ); + } + } } + + names =3D 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); } =20 static void x86_cpu_definition_entry(gpointer data, gpointer user_data) --=20 2.17.0