From patchwork Wed Aug 1 21:13:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 174602 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 D435B2C009F for ; Thu, 2 Aug 2012 07:14:13 +1000 (EST) Received: from localhost ([::1]:46584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwgF9-0006Xu-A4 for incoming@patchwork.ozlabs.org; Wed, 01 Aug 2012 17:14:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwgF2-0006Xi-Mx for qemu-devel@nongnu.org; Wed, 01 Aug 2012 17:14:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwgF1-0005sJ-CE for qemu-devel@nongnu.org; Wed, 01 Aug 2012 17:14:04 -0400 Received: from cantor2.suse.de ([195.135.220.15]:50818 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwgF1-0005sD-2A for qemu-devel@nongnu.org; Wed, 01 Aug 2012 17:14:03 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 3868689994; Wed, 1 Aug 2012 23:14:02 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 1 Aug 2012 23:13:54 +0200 Message-Id: <1343855634-8779-1-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori Subject: [Qemu-devel] [PATCH for-1.2] cpus: Register reset callback centrally 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 Despite repeated protest commit 65dee38052597b6285eb208125369f01b29ba6c1 (target-i386: move cpu_reset and reset callback to cpu.c) moved registration of a reset callback from hw/pc.c to target-i386/cpu.c while all other CPU reset handlers were still registered from machines. Instead, improve the situation by registering the callback in qemu_init_vcpu(). Now new machines or CPUs no longer need to register their own callbacks, and we can revert the code in target-i386/cpu.c. Signed-off-by: Andreas Färber Cc: Anthony Liguori Cc: Igor Mammedov Reviewed-By: Igor Mammedov --- cpus.c | 8 ++++++++ target-i386/cpu.c | 11 ----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cpus.c b/cpus.c index 756e624..f717a61 100644 --- a/cpus.c +++ b/cpus.c @@ -1020,6 +1020,13 @@ static void qemu_dummy_start_vcpu(CPUArchState *env) } } +static void cpu_machine_reset(void *opaque) +{ + CPUState *cpu = opaque; + + cpu_reset(cpu); +} + void qemu_init_vcpu(void *_env) { CPUArchState *env = _env; @@ -1027,6 +1034,7 @@ void qemu_init_vcpu(void *_env) env->nr_cores = smp_cores; env->nr_threads = smp_threads; env->stopped = 1; + qemu_register_reset(cpu_machine_reset, ENV_GET_CPU(env)); if (kvm_enabled()) { qemu_kvm_start_vcpu(env); } else if (tcg_enabled()) { diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 857b94e..a511de9 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1704,13 +1704,6 @@ bool cpu_is_bsp(X86CPU *cpu) { return cpu_get_apic_base(cpu->env.apic_state) & MSR_IA32_APICBASE_BSP; } - -/* TODO: remove me, when reset over QOM tree is implemented */ -static void x86_cpu_machine_reset_cb(void *opaque) -{ - X86CPU *cpu = opaque; - cpu_reset(CPU(cpu)); -} #endif static void mce_init(X86CPU *cpu) @@ -1733,10 +1726,6 @@ void x86_cpu_realize(Object *obj, Error **errp) { X86CPU *cpu = X86_CPU(obj); -#ifndef CONFIG_USER_ONLY - qemu_register_reset(x86_cpu_machine_reset_cb, cpu); -#endif - mce_init(cpu); qemu_init_vcpu(&cpu->env); cpu_reset(CPU(cpu));