From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX0A7-00086Y-QQ for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX0A1-0000D5-Kc for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:23:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX0A1-0000Cu-DJ for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:23:49 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s373NmX1002695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Apr 2014 23:23:48 -0400 From: Juan Quintela Date: Mon, 7 Apr 2014 05:21:38 +0200 Message-Id: <1396840915-10384-81-git-send-email-quintela@redhat.com> In-Reply-To: <1396840915-10384-1-git-send-email-quintela@redhat.com> References: <1396840915-10384-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org It is used for fields that don't exist on the State. They are generated on the fly for migration. Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 14 ++++++++++++++ target-alpha/machine.c | 16 +++------------- target-arm/machine.c | 18 ++---------------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index d695244..12020d9 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -201,6 +201,20 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_value(_state, _field, _type), \ } +/* + * This is used for fields synthetized from the state, but that don't + * exist as such. That is the reaso of offset 0. They get the whole + * struct. + */ + +#define VMSTATE_SYNTHETIC(_name, _info, _size) { \ + .name = (_name), \ + .size = (_size), \ + .info = &(_info), \ + .flags = VMS_SINGLE, \ + .offset = 0, \ +} + #define VMSTATE_POINTER(_field, _state, _test, _info, _type) { \ .name = (stringify(_field)), \ .info = &(_info), \ diff --git a/target-alpha/machine.c b/target-alpha/machine.c index 5e69b1e..a5db209 100644 --- a/target-alpha/machine.c +++ b/target-alpha/machine.c @@ -23,20 +23,10 @@ static const VMStateInfo vmstate_fpcr = { static VMStateField vmstate_env_fields[] = { VMSTATE_UINTTL_ARRAY(ir, CPUAlphaState, 31), VMSTATE_UINTTL_ARRAY(fir, CPUAlphaState, 31), + /* Save the architecture value of the fpcr, not the internally - expanded version. Since this architecture value does not - exist in memory to be stored, this requires a but of hoop - jumping. We want OFFSET=0 so that we effectively pass ENV - to the helper functions, and we need to fill in the name by - hand since there's no field of that name. */ - { - .name = "fpcr", - .version_id = 0, - .size = sizeof(uint64_t), - .info = &vmstate_fpcr, - .flags = VMS_SINGLE, - .offset = 0 - }, + expanded version. */ + VMSTATE_SYNTHETIC("fpcr", vmstate_fpcr, sizeof(uint64_t)), VMSTATE_UINTTL(pc, CPUAlphaState), VMSTATE_UINTTL(unique, CPUAlphaState), VMSTATE_UINTTL(lock_addr, CPUAlphaState), diff --git a/target-arm/machine.c b/target-arm/machine.c index 3f2c485..fd01e99 100644 --- a/target-arm/machine.c +++ b/target-arm/machine.c @@ -47,14 +47,7 @@ static const VMStateDescription vmstate_vfp = { */ VMSTATE_UINT32(env.vfp.xregs[0], ARMCPU), VMSTATE_UINT32_SUB_ARRAY(env.vfp.xregs, ARMCPU, 2, 14), - { - .name = "fpscr", - .version_id = 0, - .size = sizeof(uint32_t), - .info = &vmstate_fpscr, - .flags = VMS_SINGLE, - .offset = 0, - }, + VMSTATE_SYNTHETIC("fpscr", vmstate_fpscr, sizeof(uint32)), VMSTATE_END_OF_LIST() } }; @@ -224,14 +217,7 @@ const VMStateDescription vmstate_arm_cpu = { .post_load = cpu_post_load, .fields = (VMStateField[]) { VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16), - { - .name = "cpsr", - .version_id = 0, - .size = sizeof(uint32_t), - .info = &vmstate_cpsr, - .flags = VMS_SINGLE, - .offset = 0, - }, + VMSTATE_SYNTHETIC("cpsr", vmstate_cpsr, sizeof(uint32_t)), VMSTATE_UINT32(env.spsr, ARMCPU), VMSTATE_UINT32_ARRAY(env.banked_spsr, ARMCPU, 6), VMSTATE_UINT32_ARRAY(env.banked_r13, ARMCPU, 6), -- 1.9.0