[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 6/7] i386: Don't use default_cpu_version inside x86_cpu_defini
From: |
Eduardo Habkost |
Subject: |
[PATCH v2 6/7] i386: Don't use default_cpu_version inside x86_cpu_definition_entry() |
Date: |
Tue, 13 Oct 2020 19:04:56 -0400 |
We will change query-cpu-definitions to have a new `machine`
parameter. Move the code that reads default_cpu_version to
qmp_query_cpu_definitions() to make that easier to implement.
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 | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index bf4b4a4812..0807d12ffa 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4990,11 +4990,16 @@ void x86_cpu_list(void)
}
#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;
@@ -5010,25 +5015,27 @@ 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 (cc->model && default_cpu_version != CPU_VERSION_LEGACY) {
+ if (cc->model && args->default_version != CPU_VERSION_LEGACY) {
info->alias_of = x86_cpu_model_resolve_alias(cc->model,
- default_cpu_version);
+ 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;
+ X86CPUDefinitionArgs args = { .cpu_list = NULL };
GSList *list = get_sorted_cpu_model_list();
- g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list);
+
+ args.default_version = default_cpu_version;
+ g_slist_foreach(list, x86_cpu_definition_entry, &args);
g_slist_free(list);
- return cpu_list;
+ return args.cpu_list;
}
#endif
--
2.28.0
- [PATCH v2 0/7] i386: Add `machine` parameter to query-cpu-definitions, Eduardo Habkost, 2020/10/13
- [PATCH v2 1/7] machine: machine_find_class() function, Eduardo Habkost, 2020/10/13
- [PATCH v2 2/7] i386: Add X86CPUModel.alias_of field, Eduardo Habkost, 2020/10/13
- [PATCH v2 3/7] i386: Replace x86_cpu_class_get_alias_of() with x86_cpu_model_resolve_alias(), Eduardo Habkost, 2020/10/13
- [PATCH v2 4/7] i386: Add default_version parameter to CPU version functions, Eduardo Habkost, 2020/10/13
- [PATCH v2 5/7] i386: Wrap QMP code in !CONFIG_USER_ONLY, Eduardo Habkost, 2020/10/13
- [PATCH v2 6/7] i386: Don't use default_cpu_version inside x86_cpu_definition_entry(),
Eduardo Habkost <=
- [PATCH v2 7/7] cpu: Add `machine` parameter to query-cpu-definitions, Eduardo Habkost, 2020/10/13