Move cpu_exec_init() call from instance_init to realize. This allows any failures from cpu_exec_init() to be handled appropriately.
Also add cpu_exec_exit() call from unrealize. Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com> --- target-ppc/translate_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 9f4f172..fccee82 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -8928,6 +8928,11 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) return; } + cpu_exec_init(&cpu->env, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt + (cs->cpu_index % smp_threads); #endif @@ -9141,6 +9146,8 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp) opc_handler_t **table; int i, j; + cpu_exec_exit(CPU(dev)); + for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) { if (env->opcodes[i] == &invalid_handler) { continue; @@ -9679,8 +9686,6 @@ static void ppc_cpu_initfn(Object *obj) CPUPPCState *env = &cpu->env; cs->env_ptr = env; - cpu_exec_init(env, NULL); - cpu->cpu_dt_id = cs->cpu_index; env->msr_mask = pcc->msr_mask; env->mmu_model = pcc->mmu_model; -- 2.1.0