From patchwork Wed Oct 26 20:16:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 121974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B528C1007D2 for ; Thu, 27 Oct 2011 07:20:26 +1100 (EST) Received: from localhost ([::1]:38286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ9xW-0006FO-74 for incoming@patchwork.ozlabs.org; Wed, 26 Oct 2011 16:20:22 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ9xO-0006FD-Uu for qemu-devel@nongnu.org; Wed, 26 Oct 2011 16:20:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJ9xN-00083V-KC for qemu-devel@nongnu.org; Wed, 26 Oct 2011 16:20:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ9xN-00083P-BB for qemu-devel@nongnu.org; Wed, 26 Oct 2011 16:20:13 -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 p9QKJufH004043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Oct 2011 16:19:56 -0400 Received: from neno.neno (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9QKHulR018327; Wed, 26 Oct 2011 16:19:38 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2011 22:16:17 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Huacai Chen , Peter Maydell , Alexander Graf , Blue Swirl , Max Filippov , Michael Walle , Paul Brook , "Edgar E. Iglesias" , Aurelien Jarno , Richard Henderson Subject: [Qemu-devel] [PATCH 03/28] vmstate: make all architectures export a way to migrate cpu's 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 This makes several changes: - exports VMStateDescription vmstate_cpu non-static. - makes sure that every cpu has a vmstate_cpu or cpu_save/load defined - for the architecture that had nothing, it just register the cpu as unmigratable. - Depending on CPU_SAVE_VERSION we register old/new migration style - Add copyrights to the new files Signed-off-by: Juan Quintela --- exec.c | 2 ++ hw/hw.h | 2 ++ target-alpha/machine.c | 12 +----------- target-i386/machine.c | 2 +- target-lm32/machine.c | 2 +- target-m68k/machine.c | 21 +++++++++++++++++++++ target-s390x/machine.c | 14 ++++++-------- target-sh4/machine.c | 21 +++++++++++++++++++++ target-xtensa/machine.c | 14 ++++++-------- 9 files changed, 61 insertions(+), 29 deletions(-) diff --git a/exec.c b/exec.c index 165cfe8..09f3f01 100644 --- a/exec.c +++ b/exec.c @@ -663,6 +663,8 @@ void cpu_exec_init(CPUState *env) #if defined(CPU_SAVE_VERSION) register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION, cpu_save, cpu_load, env); +#else + vmstate_register(NULL, cpu_index, &vmstate_cpu, env); #endif #endif } diff --git a/hw/hw.h b/hw/hw.h index ed20f5a..0f0200a 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -359,6 +359,8 @@ extern const VMStateInfo vmstate_info_ptimer; extern const VMStateInfo vmstate_info_buffer; extern const VMStateInfo vmstate_info_unused_buffer; +extern const VMStateDescription vmstate_cpu; + #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) diff --git a/target-alpha/machine.c b/target-alpha/machine.c index 76d70d9..8d32d7c 100644 --- a/target-alpha/machine.c +++ b/target-alpha/machine.c @@ -68,20 +68,10 @@ static VMStateField vmstate_cpu_fields[] = { VMSTATE_END_OF_LIST() }; -static const VMStateDescription vmstate_cpu = { +const VMStateDescription vmstate_cpu = { .name = "cpu", .version_id = 1, .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = vmstate_cpu_fields, }; - -void cpu_save(QEMUFile *f, void *opaque) -{ - vmstate_save_state(f, &vmstate_cpu, opaque); -} - -int cpu_load(QEMUFile *f, void *opaque, int version_id) -{ - return vmstate_load_state(f, &vmstate_cpu, opaque, version_id); -} diff --git a/target-i386/machine.c b/target-i386/machine.c index 25fa97d..54f5643 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -310,7 +310,7 @@ static const VMStateDescription vmstate_fpop_ip_dp = { } }; -static const VMStateDescription vmstate_cpu = { +const VMStateDescription vmstate_cpu = { .name = "cpu", .version_id = CPU_SAVE_VERSION, .minimum_version_id = 3, diff --git a/target-lm32/machine.c b/target-lm32/machine.c index 70ca52a..9014a9f 100644 --- a/target-lm32/machine.c +++ b/target-lm32/machine.c @@ -1,7 +1,7 @@ #include "hw/hw.h" #include "hw/boards.h" -static const VMStateDescription vmstate_cpu = { +const VMStateDescription vmstate_cpu = { .name = "cpu", .version_id = CPU_SAVE_VERSION, .minimum_version_id = 1, diff --git a/target-m68k/machine.c b/target-m68k/machine.c index e69de29..f2e095f 100644 --- a/target-m68k/machine.c +++ b/target-m68k/machine.c @@ -0,0 +1,21 @@ +/* + * Migration support for m68k cpus + * + * Copyright (C) 2011 Red Hat, Inc. + * + * Author(s): + * Juan Quintela + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "hw/hw.h" + +/* To make this architecture migratable, we need to define cpu state + here. Other things need to be done elsewhere */ + +const VMStateDescription vmstate_cpu = { + .name = "cpu", + .unmigratable = 1, +}; diff --git a/target-s390x/machine.c b/target-s390x/machine.c index 3e79be6..5a7b219 100644 --- a/target-s390x/machine.c +++ b/target-s390x/machine.c @@ -18,13 +18,11 @@ */ #include "hw/hw.h" -#include "hw/boards.h" -void cpu_save(QEMUFile *f, void *opaque) -{ -} +/* To make this architecture migratable, we need to define cpu state + here. Other things need to be done elsewhere */ -int cpu_load(QEMUFile *f, void *opaque, int version_id) -{ - return 0; -} +const VMStateDescription vmstate_cpu = { + .name = "cpu", + .unmigratable = 1, +}; diff --git a/target-sh4/machine.c b/target-sh4/machine.c index e69de29..d0a0d48 100644 --- a/target-sh4/machine.c +++ b/target-sh4/machine.c @@ -0,0 +1,21 @@ +/* + * Migration support for sh4 cpus + * + * Copyright (C) 2011 Red Hat, Inc. + * + * Author(s): + * Juan Quintela + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "hw/hw.h" + +/* To make this architecture migratable, we need to define cpu state + here. Other things need to be done elsewhere */ + +const VMStateDescription vmstate_cpu = { + .name = "cpu", + .unmigratable = 1, +}; diff --git a/target-xtensa/machine.c b/target-xtensa/machine.c index ddeffb2..3f98330 100644 --- a/target-xtensa/machine.c +++ b/target-xtensa/machine.c @@ -26,13 +26,11 @@ */ #include "hw/hw.h" -#include "hw/boards.h" -void cpu_save(QEMUFile *f, void *opaque) -{ -} +/* To make this architecture migratable, we need to define cpu state + here. Other things need to be done elsewhere */ -int cpu_load(QEMUFile *f, void *opaque, int version_id) -{ - return 0; -} +const VMStateDescription vmstate_cpu = { + .name = "cpu", + .unmigratable = 1, +};