From e373c001fa4a7e1595cb41d1ce4ecfd91c7b1331 Mon Sep 17 00:00:00 2001 From: Bharata B Rao Date: Wed, 21 Mar 2018 07:50:22 -0400 Subject: [PATCH] cpu: Add Error argument to cpu_exec_init() Add an Error argument to cpu_exec_init() to let users collect the error. This is in preparation to change the CPU enumeration logic in cpu_exec_init(). With the new enumeration logic, cpu_exec_init() can fail if cpu_index values corresponding to max_cpus have already been handed out. Since all current callers of cpu_exec_init() are from instance_init, use error_abort Error argument to abort in case of an error. Backports commit 5a790cc4b942e651fec7edc597c19b637fad5a76 from qemu --- qemu/exec.c | 2 +- qemu/include/exec/exec-all.h | 2 +- qemu/target/arm/cpu.c | 2 +- qemu/target/i386/cpu.c | 2 +- qemu/target/m68k/cpu.c | 2 +- qemu/target/mips/cpu.c | 2 +- qemu/target/sparc/cpu.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qemu/exec.c b/qemu/exec.c index 6c6613ac..aa4c9ebe 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -577,7 +577,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) } #endif -void cpu_exec_init(CPUState *cpu, void *opaque) +void cpu_exec_init(CPUState *cpu, Error **errp, void *opaque) { struct uc_struct *uc = opaque; CPUClass *cc = CPU_GET_CLASS(uc, cpu); diff --git a/qemu/include/exec/exec-all.h b/qemu/include/exec/exec-all.h index 3ff909a4..97ed437f 100644 --- a/qemu/include/exec/exec-all.h +++ b/qemu/include/exec/exec-all.h @@ -63,7 +63,7 @@ static inline void cpu_list_lock(void) } #endif -void cpu_exec_init(CPUState *env, void *opaque); +void cpu_exec_init(CPUState *env, Error **errp, void *opaque); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); diff --git a/qemu/target/arm/cpu.c b/qemu/target/arm/cpu.c index 2fe5e312..86930021 100644 --- a/qemu/target/arm/cpu.c +++ b/qemu/target/arm/cpu.c @@ -434,7 +434,7 @@ static void arm_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque) uint32_t Aff1, Aff0; cs->env_ptr = &cpu->env; - cpu_exec_init(cs, opaque); + cpu_exec_init(cs, &error_abort, opaque); cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free); diff --git a/qemu/target/i386/cpu.c b/qemu/target/i386/cpu.c index 4252c7dc..69d353e6 100644 --- a/qemu/target/i386/cpu.c +++ b/qemu/target/i386/cpu.c @@ -4241,7 +4241,7 @@ static void x86_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque) CPUX86State *env = &cpu->env; cs->env_ptr = env; - cpu_exec_init(cs, opaque); + cpu_exec_init(cs, &error_abort, opaque); object_property_add(uc, obj, "family", "int", x86_cpuid_version_get_family, diff --git a/qemu/target/m68k/cpu.c b/qemu/target/m68k/cpu.c index a8c93530..1b41c329 100644 --- a/qemu/target/m68k/cpu.c +++ b/qemu/target/m68k/cpu.c @@ -228,7 +228,7 @@ static void m68k_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque) CPUM68KState *env = &cpu->env; cs->env_ptr = env; - cpu_exec_init(cs, opaque); + cpu_exec_init(cs, &error_abort, opaque); } static void m68k_cpu_class_init(struct uc_struct *uc, ObjectClass *c, void *data) diff --git a/qemu/target/mips/cpu.c b/qemu/target/mips/cpu.c index b45f7dfa..58400741 100644 --- a/qemu/target/mips/cpu.c +++ b/qemu/target/mips/cpu.c @@ -130,7 +130,7 @@ static void mips_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque) cs->env_ptr = env; env->cpu_model = mcc->cpu_def; - cpu_exec_init(cs, opaque); + cpu_exec_init(cs, &error_abort, opaque); } static char *mips_cpu_type_name(const char *cpu_model) diff --git a/qemu/target/sparc/cpu.c b/qemu/target/sparc/cpu.c index 3b055a9f..61c07a97 100644 --- a/qemu/target/sparc/cpu.c +++ b/qemu/target/sparc/cpu.c @@ -818,7 +818,7 @@ static void sparc_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque) CPUSPARCState *env = &cpu->env; cs->env_ptr = env; - cpu_exec_init(cs, opaque); + cpu_exec_init(cs, &error_abort, opaque); if (scc->cpu_def) { env->def = *scc->cpu_def;