All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jiri Denemark <jdenemar@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [PATCH 6/7] i386: Don't use default_cpu_version() inside query-cpu-definitions
Date: Thu, 24 Oct 2019 23:25:52 -0300	[thread overview]
Message-ID: <20191025022553.25298-7-ehabkost@redhat.com> (raw)
In-Reply-To: <20191025022553.25298-1-ehabkost@redhat.com>

We will change query-cpu-definitions to have a new `machine`
parameter.  Make the machine-specific parts of that code explicit
instead of calling default_cpu_version(), so we can change it to
use the new parameter later.

As the code now has a dependency on MachineClass, wrap it inside
a !CONFIG_USER_ONLY ifdef.  The function was never used by
*-user, anyway.

This patch shouldn't introduce any behavior change.  Results of
query-cpu-definition will be exactly the same.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/cpu.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 5dbd379331..67d1eca4ed 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3877,6 +3877,7 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v,
     visit_type_strList(v, "unavailable-features", &result, errp);
 }
 
+#ifndef CONFIG_USER_ONLY
 /* Check for missing features that may prevent the CPU class from
  * running using the current machine and accelerator.
  */
@@ -3914,6 +3915,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
 
     object_unref(OBJECT(xc));
 }
+#endif
 
 /* Print all cpuid feature names in featureset
  */
@@ -4039,11 +4041,17 @@ void x86_cpu_list(void)
     g_list_free(names);
 }
 
+#ifndef CONFIG_USER_ONLY
+typedef struct X86CPUDefinitionArgs {
+    CpuDefinitionInfoList *cpu_list;
+    X86CPUVersion default_version;
+} X86CPUDefinitionArgs;
+
 static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
 {
     ObjectClass *oc = data;
     X86CPUClass *cc = X86_CPU_CLASS(oc);
-    CpuDefinitionInfoList **cpu_list = user_data;
+    X86CPUDefinitionArgs *args = user_data;
     CpuDefinitionInfoList *entry;
     CpuDefinitionInfo *info;
 
@@ -4059,25 +4067,30 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
      * Old machine types won't report aliases, so that alias translation
      * doesn't break compatibility with previous QEMU versions.
      */
-    if (default_cpu_version() != CPU_VERSION_LEGACY) {
-        info->alias_of = x86_cpu_class_get_alias_of(cc, default_cpu_version());
+    if (args->default_version != CPU_VERSION_LEGACY) {
+        info->alias_of = x86_cpu_class_get_alias_of(cc, args->default_version);
         info->has_alias_of = !!info->alias_of;
     }
 
     entry = g_malloc0(sizeof(*entry));
     entry->value = info;
-    entry->next = *cpu_list;
-    *cpu_list = entry;
+    entry->next = args->cpu_list;
+    args->cpu_list = entry;
 }
 
 CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
 {
-    CpuDefinitionInfoList *cpu_list = NULL;
-    GSList *list = get_sorted_cpu_model_list();
-    g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list);
+    X86CPUDefinitionArgs args = { .cpu_list = NULL };
+    GSList *list;
+    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+
+    args.default_version = default_cpu_version_for_machine(mc);
+    list = get_sorted_cpu_model_list();
+    g_slist_foreach(list, x86_cpu_definition_entry, &args);
     g_slist_free(list);
-    return cpu_list;
+    return args.cpu_list;
 }
+#endif
 
 static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
                                                    bool migratable_only)
-- 
2.21.0



  parent reply	other threads:[~2019-10-25  2:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  2:25 [PATCH 0/7] i386: Add `machine` parameter to query-cpu-definitions Eduardo Habkost
2019-10-25  2:25 ` [PATCH 1/7] i386: Use g_autofree at x86_cpu_list_entry() Eduardo Habkost
2019-10-25  2:25 ` [PATCH 2/7] i386: Add default_version parameter to CPU version functions Eduardo Habkost
2019-10-25  2:25 ` [PATCH 3/7] i386: Don't use default_cpu_version at "-cpu help" Eduardo Habkost
2019-10-25  2:25 ` [PATCH 4/7] machine: machine_find_class() function Eduardo Habkost
2019-10-25  2:25 ` [PATCH 5/7] i386: Remove x86_cpu_set_default_version() function Eduardo Habkost
2019-10-25  2:25 ` Eduardo Habkost [this message]
2019-10-25  2:25 ` [PATCH 7/7] cpu: Add `machine` parameter to query-cpu-definitions Eduardo Habkost
2019-10-25  6:36   ` Markus Armbruster
2019-10-25 13:22     ` Eduardo Habkost
2019-10-25  7:17 ` [PATCH 0/7] i386: " David Hildenbrand
2019-10-25  7:55   ` Christian Borntraeger
2019-10-25  8:02     ` David Hildenbrand
2019-10-25 13:49       ` Eduardo Habkost
2019-10-25 14:03       ` Daniel P. Berrangé
2019-10-25 14:23         ` David Hildenbrand
2019-10-25 15:00           ` Daniel P. Berrangé
2019-10-25 17:19             ` David Hildenbrand
2019-10-25 13:38   ` Eduardo Habkost
2019-10-25 14:10     ` David Hildenbrand
2019-10-25 19:02 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191025022553.25298-7-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.