[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 06/22] cpu: introduce CPUClass.resume() method
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH 06/22] cpu: introduce CPUClass.resume() method |
Date: |
Mon, 8 Apr 2013 17:13:11 -0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Apr 05, 2013 at 04:36:58PM +0200, Igor Mammedov wrote:
> ... and call it if defined from CPUClass.realize() if CPU was hotplugged
>
> by default leave .resume() unset (i.e. NULL) and override it for softmmu
> in qemu_init_vcpu() if it's still unset.
>
> Signed-off-by: Igor Mammedov <address@hidden>
[...]
> diff --git a/cpus.c b/cpus.c
> index 9b9a32f..6b793c5 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -973,6 +973,13 @@ void pause_all_vcpus(void)
[...]
> @@ -1042,7 +1047,11 @@ void qemu_init_vcpu(void *_env)
> {
> CPUArchState *env = _env;
> CPUState *cpu = ENV_GET_CPU(env);
> + CPUClass *klass = CPU_GET_CLASS(cpu);
>
> + if (klass->resume == NULL) {
> + klass->resume = resume_vcpu;
> + }
So you are initializing a field of CPUClass struct inside a CPU object
initialization function. And that's a function that is not even
converted to QOM yet, and buried inside a non-trivial function call tree
(hence easy to be called at the wrong time if one day we reorder the
initialization steps).
Can't we do this on class_init(), where it belongs? If we need different
implementations for softmmu/user, we can add a stub for *-user. I think
even an explicit #ifdef inside resume_vcpu() would be preferable to
this.
> cpu->nr_cores = smp_cores;
> cpu->nr_threads = smp_threads;
> cpu->stopped = true;
[...]
--
Eduardo
- Re: [Qemu-devel] [PATCH 03/22] target-i386: split out CPU creation and features parsing into cpu_x86_create(), (continued)
[Qemu-devel] [PATCH 06/22] cpu: introduce CPUClass.resume() method, Igor Mammedov, 2013/04/05
[Qemu-devel] [PATCH 13/22] acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest, Igor Mammedov, 2013/04/05
[Qemu-devel] [PATCH 10/22] rtc: update rtc_cmos on CPU hot-plug, Igor Mammedov, 2013/04/05
[Qemu-devel] [PATCH 11/22] cpu: introduce get_firmware_id() method and override it for target-i386, Igor Mammedov, 2013/04/05