qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 14/25] vmstate: introduce VMSTATE_VARRAY_MULTIPLY


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 14/25] vmstate: introduce VMSTATE_VARRAY_MULTIPLY
Date: Tue, 25 Oct 2011 16:00:48 +0200

Thiss 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  |   11 +++++++++++
 savevm.c |    6 ++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index 798732f..727d563 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -300,6 +300,7 @@ enum VMStateFlags {
     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_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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]