From 5121119d9107f86df8ffbe5e328202f8f30732ac Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 11 Apr 2013 16:51:40 +0200 Subject: [PATCH] target-i386: Split out CPU creation and features parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Move CPU creation and features parsing into a separate cpu_x86_create() function, so that board would be able to set board-specific CPU properties before CPU is realized. Keep cpu_x86_init() for compatibility with the code that uses cpu_init() and doesn't need to modify CPU properties. Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Signed-off-by: Andreas Färber (cherry picked from commit 7f833247df4b68719413b5dccc5f84944f442cb3) --- target-i386/cpu.h | 1 + target-i386/helper.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 90ef1ff1e2..126364a0b8 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -861,6 +861,7 @@ typedef struct CPUX86State { #include "cpu-qom.h" X86CPU *cpu_x86_init(const char *cpu_model); +X86CPU *cpu_x86_create(const char *cpu_model, Error **errp); int cpu_x86_exec(CPUX86State *s); void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf); void x86_cpudef_setup(void); diff --git a/target-i386/helper.c b/target-i386/helper.c index 5a98226c80..5bf784f2c9 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1240,11 +1240,10 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, return 1; } -X86CPU *cpu_x86_init(const char *cpu_model) +X86CPU *cpu_x86_create(const char *cpu_model, Error **errp) { X86CPU *cpu; CPUX86State *env; - Error *error = NULL; cpu = X86_CPU(object_new(TYPE_X86_CPU)); env = &cpu->env; @@ -1254,8 +1253,21 @@ X86CPU *cpu_x86_init(const char *cpu_model) object_delete(OBJECT(cpu)); return NULL; } + return cpu; +} + +X86CPU *cpu_x86_init(const char *cpu_model) +{ + X86CPU *cpu; + Error *error = NULL; + + cpu = cpu_x86_create(cpu_model, &error); + if (error) { + goto out; + } object_property_set_bool(OBJECT(cpu), true, "realized", &error); +out: if (error) { error_free(error); object_delete(OBJECT(cpu)); -- 2.39.5