From patchwork Fri Apr 5 14:36:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 234155 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 5F7B32C00B0 for ; Sat, 6 Apr 2013 01:41:05 +1100 (EST) Received: from localhost ([::1]:51748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO7p9-0003pg-IO for incoming@patchwork.ozlabs.org; Fri, 05 Apr 2013 10:41:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO7mp-0001x6-Vz for qemu-devel@nongnu.org; Fri, 05 Apr 2013 10:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UO7mk-0003lB-F1 for qemu-devel@nongnu.org; Fri, 05 Apr 2013 10:38:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO7mk-0003jo-6l for qemu-devel@nongnu.org; Fri, 05 Apr 2013 10:38:34 -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 r35EbndJ008292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Apr 2013 10:37:49 -0400 Received: from thinkpad.mammed.com (vpn-238-59.phx2.redhat.com [10.3.238.59]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r35EbKxA031798; Fri, 5 Apr 2013 10:37:46 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 5 Apr 2013 16:36:58 +0200 Message-Id: <1365172636-28628-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1365172636-28628-1-git-send-email-imammedo@redhat.com> References: <1365172636-28628-1-git-send-email-imammedo@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: aliguori@us.ibm.com, ehabkost@redhat.com, claudio.fontana@huawei.com, aderumier@odiso.com, lcapitulino@redhat.com, jfrei@linux.vnet.ibm.com, yang.z.zhang@intel.com, pbonzini@redhat.com, afaerber@suse.de, lig.fnst@cn.fujitsu.com, rth@twiddle.net Subject: [Qemu-devel] [PATCH 06/22] 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 Reviewed-by: liguang --- 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)); + } } }