[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/28] vmstate: introduce VMSTATE_VARRAY_MULTIPLY
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 14/28] vmstate: introduce VMSTATE_VARRAY_MULTIPLY |
Date: |
Wed, 26 Oct 2011 22:16:28 +0200 |
This allows to sent a partial array where the size is another
structure field multiplied by a constant.
Signed-off-by: Juan Quintela <address@hidden>
---
hw/hw.h | 35 +++++++++++++++++++++++------------
savevm.c | 6 ++++++
2 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/hw/hw.h b/hw/hw.h
index 798732f..ab17bb6 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -288,18 +288,19 @@ struct VMStateInfo {
};
enum VMStateFlags {
- VMS_SINGLE = 0x001,
- VMS_POINTER = 0x002,
- VMS_ARRAY = 0x004,
- VMS_STRUCT = 0x008,
- VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/
- VMS_BUFFER = 0x020, /* static sized buffer */
- VMS_ARRAY_OF_POINTER = 0x040,
- VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
- VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */
- VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */
- VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/
- VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/
+ VMS_SINGLE = 0x0001,
+ VMS_POINTER = 0x0002,
+ VMS_ARRAY = 0x0004,
+ VMS_STRUCT = 0x0008,
+ VMS_VARRAY_INT32 = 0x0010, /* Array with size in int32_t field*/
+ VMS_BUFFER = 0x0020, /* static sized buffer */
+ VMS_ARRAY_OF_POINTER = 0x0040,
+ VMS_VARRAY_UINT16 = 0x0080, /* Array with size in uint16_t field */
+ VMS_VBUFFER = 0x0100, /* Buffer with size in int32_t field */
+ VMS_MULTIPLY = 0x0200, /* multiply "size" field by field_size */
+ VMS_VARRAY_UINT8 = 0x0400, /* Array with size in uint8_t field*/
+ VMS_VARRAY_UINT32 = 0x0800, /* Array with size in uint32_t field*/
+ VMS_MULTIPLY_ELEMENTS = 0x1000, /* multiply "size" field by field_size */
};
typedef struct {
@@ -424,6 +425,16 @@ extern const VMStateDescription vmstate_cpu;
.offset = vmstate_offset_array(_state, _field, _type, _num), \
}
+#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info,
_type) { \
+ .name = (stringify(_field)), \
+ .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+ .num = (_multiply), \
+ .info = &(_info), \
+ .size = sizeof(_type), \
+ .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \
+ .offset = offsetof(_state, _field), \
+}
+
#define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
.name = (stringify(_field)), \
.field_exists = (_test), \
diff --git a/savevm.c b/savevm.c
index 2e191ad..8ef46a1 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1460,6 +1460,9 @@ int vmstate_load_state(QEMUFile *f, const
VMStateDescription *vmsd,
} else if (field->flags & VMS_VARRAY_UINT8) {
n_elems = *(uint8_t *)(opaque+field->num_offset);
}
+ if (field->flags & VMS_MULTIPLY_ELEMENTS) {
+ n_elems *= field->num;
+ }
if (field->flags & VMS_POINTER) {
base_addr = *(void **)base_addr + field->start;
}
@@ -1524,6 +1527,9 @@ void vmstate_save_state(QEMUFile *f, const
VMStateDescription *vmsd,
} else if (field->flags & VMS_VARRAY_UINT8) {
n_elems = *(uint8_t *)(opaque+field->num_offset);
}
+ if (field->flags & VMS_MULTIPLY_ELEMENTS) {
+ n_elems *= field->num;
+ }
if (field->flags & VMS_POINTER) {
base_addr = *(void **)base_addr + field->start;
}
--
1.7.6.4
- [Qemu-devel] [PATCH 04/28] vmstate: unicore32 don't support cpu migration, (continued)
- [Qemu-devel] [PATCH 04/28] vmstate: unicore32 don't support cpu migration, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 05/28] vmstate: use new cpu style for x86, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 06/28] vmstate: use new style for lm32 cpus, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 07/28] vmstate: make microblaze cpus not migrateable, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 08/28] vmstate: port cris cpu to vmstate, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 09/28] vmstate: machine.c is only compiled for !CONFIG_USER_ONLY, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 10/28] vmstate: introduce float32 arrays, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 11/28] vmstate: introduce float64 arrays, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 12/28] vmstate: Introduce VMSTATE_STRUCT_VARRAY_INT32_TEST, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 13/28] vmstate: port ppc cpu, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 14/28] vmstate: introduce VMSTATE_VARRAY_MULTIPLY,
Juan Quintela <=
- [Qemu-devel] [PATCH 15/28] vmstate: define vmstate_info_uinttls, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 16/28] vmstate: port sparc cpu, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 18/28] mips_fulong2e: cpu vmstate already registered in cpu_exec_init, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 19/28] mips: make mvp an embedded struct instead of pointer, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 20/28] mips: make tlb an embedded struct instead of a pointer, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 21/28] mips: bump migration version to 4, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 22/28] vmstate: port mips cpu, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 23/28] arm: save always 32 fpu registers, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 24/28] vmstate: port arm cpu, Juan Quintela, 2011/10/26
- [Qemu-devel] [PATCH 25/28] vmstate: all cpus converted, Juan Quintela, 2011/10/26