[PATCH v2 3/7] i386: Replace x86_cpu_class_get_alias_of() with x86_cpu_model_resolve_alias()

Eduardo Habkost posted 7 patches 5 years, 3 months ago
Maintainers: Christian Borntraeger <borntraeger@de.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Eduardo Habkost <ehabkost@redhat.com>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, David Hildenbrand <david@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>, Halil Pasic <pasic@linux.ibm.com>, Eric Blake <eblake@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Markus Armbruster <armbru@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Cleber Rosa <crosa@redhat.com>
[PATCH v2 3/7] i386: Replace x86_cpu_class_get_alias_of() with x86_cpu_model_resolve_alias()
Posted by Eduardo Habkost 5 years, 3 months ago
New function is very similar to the old function, but it just
takes a X86CPUModel as argument, and its name makes its purpose
clearer.

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

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 43e633ddd3..2c8dd3fa32 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4170,6 +4170,21 @@ static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model)
     return v;
 }
 
+/* Resolve CPU model alias to actual CPU model name */
+static char *x86_cpu_model_resolve_alias(const X86CPUModel *model)
+{
+    X86CPUVersion version;
+
+    if (!model->is_alias) {
+        return NULL;
+    }
+    version = x86_cpu_model_resolve_version(model);
+    if (version <= 0) {
+        return NULL;
+    }
+    return x86_cpu_versioned_model_name(model->cpudef, version);
+}
+
 void x86_cpu_change_kvm_default(const char *prop, const char *value)
 {
     PropValue *pv;
@@ -4913,20 +4928,6 @@ static char *x86_cpu_class_get_model_id(X86CPUClass *xc)
     return r;
 }
 
-static char *x86_cpu_class_get_alias_of(X86CPUClass *cc)
-{
-    X86CPUVersion version;
-
-    if (!cc->model || !cc->model->is_alias) {
-        return NULL;
-    }
-    version = x86_cpu_model_resolve_version(cc->model);
-    if (version <= 0) {
-        return NULL;
-    }
-    return x86_cpu_versioned_model_name(cc->model->cpudef, version);
-}
-
 static void x86_cpu_list_entry(gpointer data, gpointer user_data)
 {
     ObjectClass *oc = data;
@@ -5002,8 +5003,8 @@ 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);
+    if (cc->model && default_cpu_version != CPU_VERSION_LEGACY) {
+        info->alias_of = x86_cpu_model_resolve_alias(cc->model);
         info->has_alias_of = !!info->alias_of;
     }
 
-- 
2.28.0