@@ -911,7 +911,7 @@ static X86CPU *pc_new_cpu(const char *cpu_model)
X86CPU *cpu;
CPUX86State *env;
- cpu = cpu_x86_init(cpu_model);
+ cpu = cpu_x86_create(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find x86 CPU definition\n");
exit(1);
@@ -49,7 +49,7 @@ static void xen_init_pv(ram_addr_t ram_size,
cpu_model = "qemu32";
#endif
}
- cpu = cpu_x86_init(cpu_model);
+ cpu = cpu_x86_create(cpu_model);
qdev_init_nofail(DEVICE(cpu));
env = &cpu->env;
env->halted = 1;
@@ -1503,6 +1503,24 @@ out:
return 0;
}
+X86CPU *cpu_x86_create(const char *cpu_model)
+{
+ X86CPU *cpu;
+ CPUX86State *env;
+
+ cpu = X86_CPU(object_new(TYPE_X86_CPU));
+ env = &cpu->env;
+ env->cpu_model_str = cpu_model;
+
+ if (cpu_x86_register(cpu, cpu_model) < 0) {
+ object_delete(OBJECT(cpu));
+ return NULL;
+ }
+
+ x86_cpu_realize(OBJECT(cpu), NULL);
+ return cpu;
+}
+
#if !defined(CONFIG_USER_ONLY)
/* interpret radix and convert from string to arbitrary scalar,
* otherwise flag failure
@@ -809,7 +809,6 @@ typedef struct CPUX86State {
#include "cpu-qom.h"
-X86CPU *cpu_x86_init(const char *cpu_model);
int cpu_x86_exec(CPUX86State *s);
void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf);
void x86_cpudef_setup(void);
@@ -925,6 +924,7 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo,
void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx);
+X86CPU *cpu_x86_create(const char *cpu_model);
int cpu_x86_register(X86CPU *cpu, const char *cpu_model);
void cpu_clear_apic_feature(CPUX86State *env);
void host_cpuid(uint32_t function, uint32_t count,
@@ -985,7 +985,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
static inline CPUX86State *cpu_init(const char *cpu_model)
{
- X86CPU *cpu = cpu_x86_init(cpu_model);
+ X86CPU *cpu = cpu_x86_create(cpu_model);
if (cpu == NULL) {
return NULL;
}
@@ -1147,30 +1147,6 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,
return 1;
}
-X86CPU *cpu_x86_init(const char *cpu_model)
-{
- X86CPU *cpu;
- CPUX86State *env;
- Error *error = NULL;
-
- cpu = X86_CPU(object_new(TYPE_X86_CPU));
- env = &cpu->env;
- env->cpu_model_str = cpu_model;
-
- if (cpu_x86_register(cpu, cpu_model) < 0) {
- object_delete(OBJECT(cpu));
- return NULL;
- }
-
- x86_cpu_realize(OBJECT(cpu), &error);
- if (error_is_set(&error)) {
- error_free(error);
- object_delete(OBJECT(cpu));
- return NULL;
- }
- return cpu;
-}
-
#if !defined(CONFIG_USER_ONLY)
void do_cpu_init(X86CPU *cpu)
{
Eventually all of the init code will become just a simple object_new() call, but right now we need to reorder and split some of the steps invoved in the CPU model string parsing, and it will be easier to do that inside cpu.c, by now. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- hw/pc.c | 2 +- hw/xen_machine_pv.c | 2 +- target-i386/cpu.c | 18 ++++++++++++++++++ target-i386/cpu.h | 4 ++-- target-i386/helper.c | 24 ------------------------ 5 files changed, 22 insertions(+), 28 deletions(-)