From patchwork Wed Mar 27 19:51:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 231819 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AA9B12C0077 for ; Thu, 28 Mar 2013 06:52:31 +1100 (EST) Received: from localhost ([::1]:52299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKwOZ-0001Rx-O5 for incoming@patchwork.ozlabs.org; Wed, 27 Mar 2013 15:52:27 -0400 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 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2RJpVGH016120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Mar 2013 15:51:31 -0400 Received: from thinkpad.mammed.com (vpn-237-41.phx2.redhat.com [10.3.237.41]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2RJpURo011840; Wed, 27 Mar 2013 15:51:30 -0400 From: Igor Mammedov To: pbonzini@redhat.com 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: afaerber@suse.de, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 07/14] cpu: introduce CPUClass.resume() method X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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)); + } } }