diff mbox series

[v2,4/7] i386: Add default_version parameter to CPU version functions

Message ID 20201013230457.150630-5-ehabkost@redhat.com
State New
Headers show
Series i386: Add `machine` parameter to query-cpu-definitions | expand

Commit Message

Eduardo Habkost Oct. 13, 2020, 11:04 p.m. UTC
Currently, the functions that resolve CPU model versions
(x86_cpu_model_resolve_version(), x86_cpu_model_resolve_alias())
need a machine to be initialized first.  Get rid of this
requirement by making those functions get an explicit
default_version argument.

No behavior changes are introduced by this patch, as all callers
are being changed to use default_cpu_version as argument.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/cpu.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 2c8dd3fa32..c78b2abfb8 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4158,11 +4158,12 @@  static X86CPUVersion x86_cpu_model_last_version(const X86CPUModel *model)
 }
 
 /* Return the actual version being used for a specific CPU model */
-static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
+static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model,
+                                                   X86CPUVersion default_version)
 {
     X86CPUVersion v = model->version;
     if (v == CPU_VERSION_AUTO) {
-        v = default_cpu_version;
+        v = default_version;
     }
     if (v == CPU_VERSION_LATEST) {
         return x86_cpu_model_last_version(model);
@@ -4171,14 +4172,15 @@  static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
 }
 
 /* Resolve CPU model alias to actual CPU model name */
-static char *x86_cpu_model_resolve_alias(const X86CPUModel *model)
+static char *x86_cpu_model_resolve_alias(const X86CPUModel *model,
+                                         X86CPUVersion default_version)
 {
     X86CPUVersion version;
 
     if (!model->is_alias) {
         return NULL;
     }
-    version = x86_cpu_model_resolve_version(model);
+    version = x86_cpu_model_resolve_version(model, default_version);
     if (version <= 0) {
         return NULL;
     }
@@ -5004,7 +5006,8 @@  static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
      * doesn't break compatibility with previous QEMU versions.
      */
     if (cc->model && default_cpu_version != CPU_VERSION_LEGACY) {
-        info->alias_of = x86_cpu_model_resolve_alias(cc->model);
+        info->alias_of = x86_cpu_model_resolve_alias(cc->model,
+                                                     default_cpu_version);
         info->has_alias_of = !!info->alias_of;
     }
 
@@ -5075,7 +5078,8 @@  static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props)
 static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model)
 {
     const X86CPUVersionDefinition *vdef;
-    X86CPUVersion version = x86_cpu_model_resolve_version(model);
+    X86CPUVersion version = x86_cpu_model_resolve_version(model,
+                                                          default_cpu_version);
 
     if (version == CPU_VERSION_LEGACY) {
         return;