Received: from eggs.gnu.org ([208.118.235.92]:60103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFLpp-00017U-PG for qemu-devel@nongnu.org; Tue, 12 Mar 2013 05:49:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFLpm-0008Hx-02 for qemu-devel@nongnu.org; Tue, 12 Mar 2013 05:49:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60998 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFLpl-0008HW-N7 for qemu-devel@nongnu.org; Tue, 12 Mar 2013 05:49:25 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 12 Mar 2013 10:49:09 +0100 Message-Id: <1363081758-12913-9-git-send-email-afaerber@suse.de> In-Reply-To: <1363081758-12913-1-git-send-email-afaerber@suse.de> References: <1363081758-12913-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 08/17] cpu: Register VMStateDescription through CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Juan Quintela In comparison to DeviceClass::vmsd, CPU VMState is split in two, "cpu_common" and "cpu", and uses cpu_index as instance_id instead of -1. Therefore add a CPU-specific CPUClass::vmsd field. Unlike the legacy CPUArchState registration, rather register CPUState. Signed-off-by: Juan Quintela Signed-off-by: Andreas F=C3=A4rber Reviewed-by: Eduardo Habkost --- exec.c | 11 +++++++++-- include/qom/cpu.h | 3 +++ 2 Dateien ge=C3=A4ndert, 12 Zeilen hinzugef=C3=BCgt(+), 2 Zeilen entfern= t(-) diff --git a/exec.c b/exec.c index 0a96ddb..254ae62 100644 --- a/exec.c +++ b/exec.c @@ -219,7 +219,7 @@ void cpu_exec_init_all(void) #endif } =20 -#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) =20 static int cpu_common_post_load(void *opaque, int version_id) { @@ -245,6 +245,8 @@ static const VMStateDescription vmstate_cpu_common =3D= { VMSTATE_END_OF_LIST() } }; +#else +#define vmstate_cpu_common vmstate_dummy #endif =20 CPUState *qemu_get_cpu(int index) @@ -266,6 +268,7 @@ CPUState *qemu_get_cpu(int index) void cpu_exec_init(CPUArchState *env) { CPUState *cpu =3D ENV_GET_CPU(env); + CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchState **penv; int cpu_index; =20 @@ -290,11 +293,15 @@ void cpu_exec_init(CPUArchState *env) #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif -#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env); +#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 =3D=3D NULL); #endif + if (cc->vmsd !=3D NULL) { + vmstate_register(NULL, cpu_index, cc->vmsd, cpu); + } } =20 #if defined(TARGET_HAS_ICE) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index ab2657c..5b1b0d7 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -44,6 +44,7 @@ typedef struct CPUState CPUState; * @class_by_name: Callback to map -cpu command line model name to an * instantiatable CPU type. * @reset: Callback to reset the #CPUState to its initial state. + * @vmsd: State description for migration. * * Represents a CPU family or model. */ @@ -55,6 +56,8 @@ typedef struct CPUClass { ObjectClass *(*class_by_name)(const char *cpu_model); =20 void (*reset)(CPUState *cpu); + + const struct VMStateDescription *vmsd; } CPUClass; =20 struct KVMState; --=20 1.7.10.4