From patchwork Sat Feb 2 15:04:11 2013 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: 217668 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 361162C008E for ; Sun, 3 Feb 2013 02:04:52 +1100 (EST) Received: from localhost ([::1]:41550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1ee9-0007bv-O0 for incoming@patchwork.ozlabs.org; Sat, 02 Feb 2013 10:04:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1edu-0007bo-DX for qemu-devel@nongnu.org; Sat, 02 Feb 2013 10:04:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1edt-0005XN-5N for qemu-devel@nongnu.org; Sat, 02 Feb 2013 10:04:34 -0500 Received: from cantor2.suse.de ([195.135.220.15]:42097 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1eds-0005XG-SG for qemu-devel@nongnu.org; Sat, 02 Feb 2013 10:04:33 -0500 Received: from relay2.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 0A00FA5077; Sat, 2 Feb 2013 16:04:32 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sat, 2 Feb 2013 16:04:11 +0100 Message-Id: <1359817456-25561-2-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359817456-25561-1-git-send-email-afaerber@suse.de> References: <1359817456-25561-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , quintela@redhat.com Subject: [Qemu-devel] [PATCH RFC qom-cpu-next 1/6] cpu: Register VMStateDescription through CPUState 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 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ärber --- exec.c | 13 +++++++++++-- include/qom/cpu.h | 3 +++ 2 Dateien geändert, 14 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-) diff --git a/exec.c b/exec.c index b85508b..5eee174 100644 --- a/exec.c +++ b/exec.c @@ -219,7 +219,7 @@ void cpu_exec_init_all(void) #endif } -#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) static int cpu_common_post_load(void *opaque, int version_id) { @@ -266,6 +266,9 @@ CPUState *qemu_get_cpu(int index) void cpu_exec_init(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); +#if !defined(CONFIG_USER_ONLY) && !defined(CPU_SAVE_VERSION) + CPUClass *cc = CPU_GET_CLASS(cpu); +#endif CPUArchState **penv; int cpu_index; @@ -290,10 +293,16 @@ void cpu_exec_init(CPUArchState *env) #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif -#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env); +#if defined(CPU_SAVE_VERSION) register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION, cpu_save, cpu_load, env); +#else + if (cc->vmsd != NULL) { + vmstate_register(NULL, cpu_index, cc->vmsd, cpu); + } +#endif #endif } diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 46f2247..b870752 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -43,6 +43,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. */ @@ -54,6 +55,8 @@ typedef struct CPUClass { ObjectClass *(*class_by_name)(const char *cpu_model); void (*reset)(CPUState *cpu); + + const struct VMStateDescription *vmsd; } CPUClass; struct KVMState;