From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeBhK-0006GG-2R for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeBhF-0006DU-2D for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:13 -0400 Received: from [199.232.76.173] (port=39146 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeBhE-0006DM-Mt for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28853) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MeBhE-0006xG-1Z for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:08 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7KHj6fI025291 for ; Thu, 20 Aug 2009 13:45:06 -0400 From: Juan Quintela Date: Thu, 20 Aug 2009 19:42:26 +0200 Message-Id: <9220bd2bc8fa9cbefe7130cee6fe88a95da38a39.1250788880.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 08/23] Add VMState support for pointers List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This patch adds support for saving pointers to values Signed-off-by: Juan Quintela --- hw/hw.h | 19 +++++++++++++++++++ savevm.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index c58b416..a315f83 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -280,6 +280,7 @@ struct VMStateInfo { enum VMStateFlags { VMS_SINGLE = 0x001, + VMS_POINTER = 0x002, }; typedef struct { @@ -310,6 +311,8 @@ extern const VMStateInfo vmstate_info_uint16; extern const VMStateInfo vmstate_info_uint32; extern const VMStateInfo vmstate_info_uint64; +extern const VMStateInfo vmstate_info_timer; + #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ @@ -320,6 +323,16 @@ extern const VMStateInfo vmstate_info_uint64; + type_check(_type,typeof_field(_state, _field)) \ } +#define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_SINGLE|VMS_POINTER, \ + .offset = offsetof(_state, _field) \ + + type_check(_type,typeof_field(_state, _field)) \ +} + /* _f : field name _s : struct state name _v : version @@ -361,6 +374,12 @@ extern const VMStateInfo vmstate_info_uint64; #define VMSTATE_UINT64(_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) +#define VMSTATE_TIMER_V(_f, _s, _v) \ + VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) + +#define VMSTATE_TIMER(_f, _s) \ + VMSTATE_TIMER_V(_f, _s, 0) + #define VMSTATE_END_OF_LIST() \ {} diff --git a/savevm.c b/savevm.c index 400d1c0..617b443 100644 --- a/savevm.c +++ b/savevm.c @@ -778,6 +778,27 @@ const VMStateInfo vmstate_info_uint64 = { .put = put_uint64, }; +/* timers */ + +static int get_timer(QEMUFile *f, void *pv, size_t size) +{ + QEMUTimer *v = pv; + qemu_get_timer(f, v); + return 0; +} + +static void put_timer(QEMUFile *f, const void *pv, size_t size) +{ + QEMUTimer *v = (void *)pv; + qemu_put_timer(f, v); +} + +const VMStateInfo vmstate_info_timer = { + .name = "timer", + .get = get_timer, + .put = put_timer, +}; + typedef struct SaveStateEntry { char idstr[256]; int instance_id; @@ -925,6 +946,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *addr = opaque + field->offset; int ret; + if (field->flags & VMS_POINTER) { + addr = *(void **)addr; + } ret = field->info->get(f, addr, field->size); if (ret < 0) { return ret; @@ -942,6 +966,10 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, while(field->name) { const void *addr = opaque + field->offset; + + if (field->flags & VMS_POINTER) { + addr = *(void **)addr; + } field->info->put(f, addr, field->size); field++; } -- 1.6.2.5