From nobody Mon Feb 9 01:30:54 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 152996583700198.47240877897013; Mon, 25 Jun 2018 15:30:37 -0700 (PDT) Received: from localhost ([::1]:49523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXa0G-0005Fq-CM for importer@patchew.org; Mon, 25 Jun 2018 18:30:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXZvV-0001jM-9f for qemu-devel@nongnu.org; Mon, 25 Jun 2018 18:25:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXZvT-00037u-MZ for qemu-devel@nongnu.org; Mon, 25 Jun 2018 18:25:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXZvT-000372-7a for qemu-devel@nongnu.org; Mon, 25 Jun 2018 18:25:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B568C049D5F; Mon, 25 Jun 2018 22:25:34 +0000 (UTC) Received: from localhost (ovpn-116-16.gru2.redhat.com [10.97.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 075258CF81; Mon, 25 Jun 2018 22:25:33 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Mon, 25 Jun 2018 19:25:16 -0300 Message-Id: <20180625222524.382-5-ehabkost@redhat.com> In-Reply-To: <20180625222524.382-1-ehabkost@redhat.com> References: <20180625222524.382-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 25 Jun 2018 22:25:34 +0000 (UTC) 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: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/12] 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 , 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" From: Daniel P. Berrang=C3=A9 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 Message-Id: <20180606165527.17365-4-berrange@redhat.com> Signed-off-by: Eduardo Habkost --- 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(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. */ @@ -3392,26 +3396,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.18.0.rc1.1.g3f1ff2140