From 39e329e341da375b8d66444ffe93c79d7a883350 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Thu, 20 Oct 2016 13:26:02 +0200 Subject: exec: split cpu_exec_init() Put in cpu_exec_initfn() what initializes the CPU, and leave in cpu_exec_init() what adds it to the environment. As cpu_exec_initfn() is called by all XX_cpu_initfn(), call it directly in cpu_common_initfn(). cpu_exec_init() is now a realize function, it will be renamed to cpu_exec_realizefn() and moved to the XX_cpu_realizefn() function in a following patch. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- exec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 6d7f600c0c..902dac597b 100644 --- a/exec.c +++ b/exec.c @@ -610,11 +610,8 @@ void cpu_exec_exit(CPUState *cpu) } } -void cpu_exec_init(CPUState *cpu, Error **errp) +void cpu_exec_initfn(CPUState *cpu) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as = NULL; cpu->num_ases = 0; @@ -635,6 +632,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory; object_ref(OBJECT(cpu->memory)); #endif +} + +void cpu_exec_init(CPUState *cpu, Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); cpu_list_add(cpu); -- cgit v1.2.3 From ce5b1bbf624b977a55ff7f85bb3871682d03baff Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Thu, 20 Oct 2016 13:26:03 +0200 Subject: exec: move cpu_exec_init() calls to realize functions Modify all CPUs to call it from XXX_cpu_realizefn() function. Remove all the cannot_destroy_with_object_finalize_yet as unsafe references have been moved to cpu_exec_realizefn(). (tested with QOM command provided by commit 4c315c27) for arm: Setting of cpu->mp_affinity is moved from arm_cpu_initfn() to arm_cpu_realizefn() as setting of cpu_index is now done in cpu_exec_realizefn(). To avoid to overwrite an user defined value, we set it to an invalid value by default, and update it in realize function only if the value is still invalid. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Reviewed-by: Eduardo Habkost Reviewed-by: Andrew Jones Signed-off-by: Eduardo Habkost --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 902dac597b..9c97a0a4a2 100644 --- a/exec.c +++ b/exec.c @@ -634,7 +634,7 @@ void cpu_exec_initfn(CPUState *cpu) #endif } -void cpu_exec_init(CPUState *cpu, Error **errp) +void cpu_exec_realizefn(CPUState *cpu, Error **errp) { CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); -- cgit v1.2.3 From 7bbc124e7e8fb544288ccd1f5185643a7d0554b8 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Thu, 20 Oct 2016 13:26:04 +0200 Subject: exec: call cpu_exec_exit() from a CPU unrealize common function As cpu_exec_exit() mirrors the cpu_exec_realizefn(), rename it as cpu_exec_unrealizefn(). Create and register a cpu_common_unrealizefn() function for the CPU device class and call cpu_exec_unrealizefn() from this function. Remove cpu_exec_exit() from cpu_common_finalize() (which mirrors init, not realize), and as x86_cpu_unrealizefn() and ppc_cpu_unrealizefn() overwrite the device class unrealize function, add a call to a parent_unrealize pointer. Signed-off-by: Laurent Vivier Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 9c97a0a4a2..9a736da955 100644 --- a/exec.c +++ b/exec.c @@ -596,7 +596,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) } #endif -void cpu_exec_exit(CPUState *cpu) +void cpu_exec_unrealizefn(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); -- cgit v1.2.3