On Fri, Jan 08, 2016 at 12:25:12PM +0530, Bharata B Rao wrote: > Don't do CPU realization from cpu_generic_init(). With this > cpu_generic_init() will be used to just create CPU threads and they > should be realized separately from realizefn call. > > Convert the existing callers to do explicit realization. > > Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com>
Reviewed-by: Eduardo Habkost <ehabk...@redhat.com> Reviewed by comparing the patch with the results of the following Coccinelle patch: @@ typedef CPUState; identifier cc, cpu, err; @@ CPUState *cpu_generic_init(...) { ... - if (err != NULL) { - goto out; - } - - object_property_set_bool(OBJECT(cpu), true, "realized", &err); -out: if (err != NULL) { ... } ... } @@ type XXXCPU; identifier initfunc, cpu_model, TYPE_XXX_CPU, XXX_CPU; @@ XXXCPU *initfunc(const char *cpu_model) { - return XXX_CPU(cpu_generic_init(TYPE_XXX_CPU, cpu_model)); + CPUState *cpu = cpu_generic_init(TYPE_XXX_CPU, cpu_model); + Error *err = NULL; + + if (!cpu) { + return NULL; + } + + object_property_set_bool(OBJECT(cpu), true, "realized", &err); + if (err != NULL) { + error_report_err(err); + object_unref(OBJECT(cpu)); + return NULL; + } else { + return XXX_CPU(cpu); + } } -- Eduardo