From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKwNi-0000gV-GN for qemu-devel@nongnu.org; Wed, 27 Mar 2013 15:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKwNg-0004E5-SW for qemu-devel@nongnu.org; Wed, 27 Mar 2013 15:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKwNg-0004Dv-I8 for qemu-devel@nongnu.org; Wed, 27 Mar 2013 15:51:32 -0400 From: Igor Mammedov Date: Wed, 27 Mar 2013 20:51:27 +0100 Message-Id: <1364413887-27376-1-git-send-email-imammedo@redhat.com> In-Reply-To: <51530E2F.2040707@redhat.com> References: <51530E2F.2040707@redhat.com> Subject: [Qemu-devel] [PATCH 07/14] cpu: introduce CPUClass.resume() method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pbonzini@redhat.com Cc: afaerber@suse.de, qemu-devel@nongnu.org ... 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 --- cpus.c | 15 ++++++++++++--- include/qom/cpu.h | 2 ++ qom/cpu.c | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) 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) } } +static void resume_vcpu(CPUState *cpu) +{ + cpu->stop = false; + cpu->stopped = false; + qemu_cpu_kick(cpu); +} + void resume_all_vcpus(void) { CPUArchState *penv = first_cpu; @@ -980,9 +987,7 @@ void resume_all_vcpus(void) qemu_clock_enable(vm_clock, true); while (penv) { CPUState *pcpu = ENV_GET_CPU(penv); - pcpu->stop = false; - pcpu->stopped = false; - qemu_cpu_kick(pcpu); + resume_vcpu(pcpu); penv = penv->next_cpu; } } @@ -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; + } cpu->nr_cores = smp_cores; cpu->nr_threads = smp_threads; cpu->stopped = true; diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 3664a1b..6d6eb7a 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -45,6 +45,7 @@ typedef struct CPUState CPUState; * instantiatable CPU type. * @reset: Callback to reset the #CPUState to its initial state. * @do_interrupt: Callback for interrupt handling. + * @resume: Callback for putting CPU in runable state * @vmsd: State description for migration. * * Represents a CPU family or model. @@ -58,6 +59,7 @@ typedef struct CPUClass { void (*reset)(CPUState *cpu); void (*do_interrupt)(CPUState *cpu); + void (*resume)(CPUState *cpu); const struct VMStateDescription *vmsd; } CPUClass; diff --git a/qom/cpu.c b/qom/cpu.c index 0c76712..c062e00 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -58,8 +58,13 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model) static void cpu_common_realizefn(DeviceState *dev, Error **errp) { + CPUClass *klass = CPU_GET_CLASS(dev); + if (dev->hotplugged) { cpu_synchronize_post_init(CPU(dev)); + if (klass->resume != NULL) { + klass->resume(CPU(dev)); + } } } -- 1.8.1.4