From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 08/23] Add VMState support for pointers
Date: Thu, 20 Aug 2009 19:42:26 +0200 [thread overview]
Message-ID: <9220bd2bc8fa9cbefe7130cee6fe88a95da38a39.1250788880.git.quintela@redhat.com> (raw)
In-Reply-To: <cover.1250788880.git.quintela@redhat.com>
In-Reply-To: <cover.1250788880.git.quintela@redhat.com>
This patch adds support for saving pointers to values
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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
next prev parent reply other threads:[~2009-08-20 17:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 17:42 [Qemu-devel] [PATCH 00/23] New VMState table based load/save infrastructure Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 01/23] move useful type definitons to osdep.h Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 02/23] split do_loadvm() into do_loadvm() and load_vmstate() Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 03/23] move do_loadvm() to monitor.c Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 04/23] make load_vmstate() return errors Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 05/23] Use return value from load_state() call back Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 06/23] Add vmstate_load() and vmstate_save() functions Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 07/23] New VMstate save/load infrastructure Juan Quintela
2009-09-09 6:38 ` Michael S. Tsirkin
2009-08-20 17:42 ` Juan Quintela [this message]
2009-08-20 17:42 ` [Qemu-devel] [PATCH 09/23] Add VMState support for arrays Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 10/23] Port apic to new VMState design Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 11/23] Add VMState support for structs Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 12/23] Add VMState support for arrays of structs Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 13/23] Port i8254 to new VMState design Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 14/23] Add VMState support for int32_t check value Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 15/23] Add VMState support for variable sized arrays Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 16/23] Port PCI Bus to VMState design Juan Quintela
2009-08-21 8:32 ` Gerd Hoffmann
2009-08-21 9:04 ` [Qemu-devel] " Juan Quintela
2009-08-21 9:23 ` Gerd Hoffmann
2009-08-20 17:42 ` [Qemu-devel] [PATCH 17/23] Add VMState support for static sized buffers (uint_8) Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 18/23] Port PS2 devices to VMState design Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 19/23] Add VMState support for int32_t check value Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 20/23] Add version_id to PCIDevice Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 21/23] Port PCIDevice state to VMState Juan Quintela
2009-08-21 8:52 ` Gerd Hoffmann
2009-08-21 9:01 ` [Qemu-devel] " Juan Quintela
2009-08-21 9:14 ` Gerd Hoffmann
2009-08-21 9:30 ` Juan Quintela
2009-08-21 10:07 ` Gerd Hoffmann
2009-08-20 17:42 ` [Qemu-devel] [PATCH 22/23] Add VMState support to run a function after load Juan Quintela
2009-08-20 17:42 ` [Qemu-devel] [PATCH 23/23] Port ACPI to VMState Juan Quintela
2009-08-21 8:58 ` [Qemu-devel] [PATCH 00/23] New VMState table based load/save infrastructure Gerd Hoffmann
2009-08-21 9:12 ` [Qemu-devel] " Juan Quintela
2009-08-21 9:28 ` Gerd Hoffmann
2009-08-21 9:31 ` Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9220bd2bc8fa9cbefe7130cee6fe88a95da38a39.1250788880.git.quintela@redhat.com \
--to=quintela@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).