[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/12] vmstate: Add support for multiplying size for
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 09/12] vmstate: Add support for multiplying size for a constant |
Date: |
Wed, 2 Dec 2009 12:36:43 +0100 |
When the size that we want to transmit is in another field, but in an
unit different that bytes
Signed-off-by: Juan Quintela <address@hidden>
---
hw/hw.h | 13 +++++++++++++
savevm.c | 6 ++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/hw/hw.h b/hw/hw.h
index 41e13cc..5f34991 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -295,6 +295,7 @@ enum VMStateFlags {
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 */
};
typedef struct {
@@ -485,6 +486,18 @@ extern const VMStateInfo vmstate_info_unused_buffer;
.offset = vmstate_offset_buffer(_state, _field) + _start, \
}
+#define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start,
_field_size, _multiply) { \
+ .name = (stringify(_field)), \
+ .version_id = (_version), \
+ .field_exists = (_test), \
+ .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
+ .size = (_multiply), \
+ .info = &vmstate_info_buffer, \
+ .flags = VMS_VBUFFER|VMS_MULTIPLY, \
+ .offset = offsetof(_state, _field), \
+ .start = (_start), \
+}
+
#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size)
{ \
.name = (stringify(_field)), \
.version_id = (_version), \
diff --git a/savevm.c b/savevm.c
index 2715f8f..c7da4a6 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1147,6 +1147,9 @@ int vmstate_load_state(QEMUFile *f, const
VMStateDescription *vmsd,
if (field->flags & VMS_VBUFFER) {
size = *(int32_t *)(opaque+field->size_offset);
+ if (field->flags & VMS_MULTIPLY) {
+ size *= field->size;
+ }
}
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
@@ -1200,6 +1203,9 @@ void vmstate_save_state(QEMUFile *f, const
VMStateDescription *vmsd,
if (field->flags & VMS_VBUFFER) {
size = *(int32_t *)(opaque+field->size_offset);
+ if (field->flags & VMS_MULTIPLY) {
+ size *= field->size;
+ }
}
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
--
1.6.5.2
- [Qemu-devel] [PATCH 00/12] vmstate cleanups and fixes, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 01/12] vmstate: Avoid seeking, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 02/12] vmstate: Fix info field of VMSTATE_MACADDR, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 03/12] vmstate: fix missing ARRAY_OF_POINTERS support on save state, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 04/12] vmstate: Add support for VBUFFERS, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 05/12] vmstate: Introduce VMSTATE_STRUCT_TEST, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 06/12] vmstate: Introduce VMSTATE_STRUCT_POINTER_TEST, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 07/12] vmstate: Introduce UINT16_TEST support, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 11/12] qdev: enable vmstate_unregister() support, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 10/12] pci: vmstate_register() already assign consecutive numbers starting at 0, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 09/12] vmstate: Add support for multiplying size for a constant,
Juan Quintela <=
- [Qemu-devel] [PATCH 08/12] vmstate: remove usused VMSTATE_STRUCT_ARRAY_SIZE_UINT8, Juan Quintela, 2009/12/02
- [Qemu-devel] [PATCH 12/12] savevm: Port to qdev.vmsd all devices that have qdev, Juan Quintela, 2009/12/02