From patchwork Wed Jan 14 07:27:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Guihua X-Patchwork-Id: 428814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 855B61400DE for ; Wed, 14 Jan 2015 18:32:58 +1100 (AEDT) Received: from localhost ([::1]:42958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBIRk-0006fE-Nq for incoming@patchwork.ozlabs.org; Wed, 14 Jan 2015 02:32:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBIO5-0000Oi-14 for qemu-devel@nongnu.org; Wed, 14 Jan 2015 02:29:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBINz-0005RP-Il for qemu-devel@nongnu.org; Wed, 14 Jan 2015 02:29:08 -0500 Received: from [59.151.112.132] (port=25046 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBINy-0005OI-W4 for qemu-devel@nongnu.org; Wed, 14 Jan 2015 02:29:03 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56034703" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 Jan 2015 15:25:24 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t0E7SFN6018267; Wed, 14 Jan 2015 15:28:16 +0800 Received: from G08FNSTD140041.g08.fujitsu.local (10.167.226.252) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 14 Jan 2015 15:28:56 +0800 From: Zhu Guihua To: Date: Wed, 14 Jan 2015 15:27:25 +0800 Message-ID: X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.252] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Zhu Guihua , tangchen@cn.fujitsu.com, guz.fnst@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, anshul.makkar@profitbricks.com, chen.fan.fnst@cn.fujitsu.com, imammedo@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v3 2/7] qom/cpu: move register_vmstate to common CPUClass.realizefn 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 From: Gu Zheng Move cpu vmstate register from cpu_exec_init into cpu_common_realizefn, and use cc->get_arch_id as the instance id that suggested by Igor to fix the migration issue. Signed-off-by: Gu Zheng Signed-off-by: Zhu Guihua --- exec.c | 32 +++++++++++++++++++------------- include/qom/cpu.h | 2 ++ qom/cpu.c | 2 ++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/exec.c b/exec.c index 081818e..c9ffda6 100644 --- a/exec.c +++ b/exec.c @@ -513,10 +513,28 @@ void tcg_cpu_address_space_init(CPUState *cpu, AddressSpace *as) } #endif +void cpu_vmstate_register(CPUState *cpu) +{ + CPUClass *cc = CPU_GET_CLASS(cpu); + int cpu_index = cc->get_arch_id(cpu); + + if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { + vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu); + } +#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) + register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION, + cpu_save, cpu_load, cpu->env_ptr); + assert(cc->vmsd == NULL); + assert(qdev_get_vmsd(DEVICE(cpu)) == NULL); +#endif + if (cc->vmsd != NULL) { + vmstate_register(NULL, cpu_index, cc->vmsd, cpu); + } +} + void cpu_exec_init(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); - CPUClass *cc = CPU_GET_CLASS(cpu); CPUState *some_cpu; int cpu_index; @@ -539,18 +557,6 @@ void cpu_exec_init(CPUArchState *env) #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif - if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { - vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu); - } -#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) - register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION, - cpu_save, cpu_load, env); - assert(cc->vmsd == NULL); - assert(qdev_get_vmsd(DEVICE(cpu)) == NULL); -#endif - if (cc->vmsd != NULL) { - vmstate_register(NULL, cpu_index, cc->vmsd, cpu); - } } #if defined(TARGET_HAS_ICE) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 2098f1c..936afcd 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -562,6 +562,8 @@ void cpu_interrupt(CPUState *cpu, int mask); #endif /* USER_ONLY */ +void cpu_vmstate_register(CPUState *cpu); + #ifdef CONFIG_SOFTMMU static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr, bool is_write, bool is_exec, diff --git a/qom/cpu.c b/qom/cpu.c index 9c68fa4..a639822 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -302,6 +302,8 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); + cpu_vmstate_register(cpu); + if (dev->hotplugged) { cpu_synchronize_post_init(cpu); cpu_resume(cpu);