aboutsummaryrefslogtreecommitdiff
path: root/hw/hw.h
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-08-20 19:42:27 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-08-27 20:30:21 -0500
commitf752a6aae72703e1dc42b1d717bcea7c113b4853 (patch)
tree49d64e433871d537b7ddb2c849fba1931da74b2d /hw/hw.h
parentdde0463b4e5e78ab636a298ae28b9a0ba77bc595 (diff)
downloadqemu-f752a6aae72703e1dc42b1d717bcea7c113b4853.zip
qemu-f752a6aae72703e1dc42b1d717bcea7c113b4853.tar.gz
qemu-f752a6aae72703e1dc42b1d717bcea7c113b4853.tar.bz2
Add VMState support for arrays
This patch adds support for saving arrays inside the struct Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/hw.h')
-rw-r--r--hw/hw.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/hw/hw.h b/hw/hw.h
index 9a1ba18..a8534fa 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -282,12 +282,14 @@ struct VMStateInfo {
enum VMStateFlags {
VMS_SINGLE = 0x001,
VMS_POINTER = 0x002,
+ VMS_ARRAY = 0x004,
};
typedef struct {
const char *name;
size_t offset;
size_t size;
+ int num;
const VMStateInfo *info;
enum VMStateFlags flags;
int version_id;
@@ -314,6 +316,8 @@ extern const VMStateInfo vmstate_info_uint64;
extern const VMStateInfo vmstate_info_timer;
+#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
+
#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) { \
.name = (stringify(_field)), \
.version_id = (_version), \
@@ -334,7 +338,19 @@ extern const VMStateInfo vmstate_info_timer;
+ type_check(_type,typeof_field(_state, _field)) \
}
+#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
+ .name = (stringify(_field)), \
+ .version_id = (_version), \
+ .num = (_num), \
+ .info = &(_info), \
+ .size = sizeof(_type), \
+ .flags = VMS_ARRAY, \
+ .offset = offsetof(_state, _field) \
+ + type_check_array(_type,typeof_field(_state, _field),_num) \
+}
+
/* _f : field name
+ _n : num of elements
_s : struct state name
_v : version
*/
@@ -381,6 +397,18 @@ extern const VMStateInfo vmstate_info_timer;
#define VMSTATE_TIMER(_f, _s) \
VMSTATE_TIMER_V(_f, _s, 0)
+#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
+ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
+
+#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
+ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
+
+#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
+ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
+
+#define VMSTATE_INT32_ARRAY(_f, _s, _n) \
+ VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
+
#define VMSTATE_END_OF_LIST() \
{}