From patchwork Thu Sep 10 01:04:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 33248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 773B4B7080 for ; Thu, 10 Sep 2009 11:25:47 +1000 (EST) Received: from localhost ([127.0.0.1]:38313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlYPw-0003Iq-JC for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 21:25:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlY66-0004WB-FW for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlY5z-0004R1-V6 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:13 -0400 Received: from [199.232.76.173] (port=48260 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlY5z-0004Qc-HU for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18210) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlY5y-0002mN-T8 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:07 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A156KM031545 for ; Wed, 9 Sep 2009 21:05:06 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8A14oof020882; Wed, 9 Sep 2009 21:05:05 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 03:04:33 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 12/26] vmstate: port cpu_comon X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- exec.c | 39 +++++++++++++++++++++++++-------------- 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/exec.c b/exec.c index c5bc13a..6a62a8a 100644 --- a/exec.c +++ b/exec.c @@ -513,28 +513,25 @@ void cpu_exec_init_all(unsigned long tb_size) #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) -#define CPU_COMMON_SAVE_VERSION 1 - -static void cpu_common_save(QEMUFile *f, void *opaque) +static void cpu_common_pre_save(const void *opaque) { - CPUState *env = opaque; + CPUState *env = (void *)opaque; cpu_synchronize_state(env); - - qemu_put_be32s(f, &env->halted); - qemu_put_be32s(f, &env->interrupt_request); } -static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) +static int cpu_common_pre_load(void *opaque) { CPUState *env = opaque; cpu_synchronize_state(env); - if (version_id != CPU_COMMON_SAVE_VERSION) - return -EINVAL; + return 0; +} + +static int cpu_common_post_load(void *opaque) +{ + CPUState *env = opaque; - qemu_get_be32s(f, &env->halted); - qemu_get_be32s(f, &env->interrupt_request); /* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the version_id is increased. */ env->interrupt_request &= ~0x01; @@ -542,6 +539,21 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) return 0; } + +static const VMStateDescription vmstate_cpu_common = { + .name = "cpu_common", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .pre_save = cpu_common_pre_save, + .pre_load = cpu_common_pre_load, + .post_load = cpu_common_post_load, + .fields = (VMStateField []) { + VMSTATE_UINT32(halted, CPUState), + VMSTATE_UINT32(interrupt_request, CPUState), + VMSTATE_END_OF_LIST() + } +}; #endif CPUState *qemu_get_cpu(int cpu) @@ -581,8 +593,7 @@ void cpu_exec_init(CPUState *env) cpu_list_unlock(); #endif #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) - register_savevm("cpu_common", cpu_index, CPU_COMMON_SAVE_VERSION, - cpu_common_save, cpu_common_load, env); + vmstate_register(cpu_index, &vmstate_cpu_common, env); register_savevm("cpu", cpu_index, CPU_SAVE_VERSION, cpu_save, cpu_load, env); #endif