diff options
author | Juan Quintela <quintela@redhat.com> | 2016-01-11 12:40:22 +0000 |
---|---|---|
committer | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2016-01-16 12:01:23 +0000 |
commit | b47d3af7559b6fe17a2a86a1f0bf69f386873753 (patch) | |
tree | 6adc1f3a61e3457ff0c229ba9f1e7df32646c9e2 | |
parent | 551747491d6677e4cc6cac8750462887a09bc722 (diff) |
vmstate: Introduce VMSTATE_VARRAY_MULTPLY
This allows to send a partial array where the size is another
structure field multiplied by a constant.
Signed-off-by: Juan Quintela <quintela@redhat.com>
[PMM: updated to current master]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
-rw-r--r-- | include/migration/vmstate.h | 11 | ||||
-rw-r--r-- | migration/vmstate.c | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 9b516c1bfe..a4b81bb5f6 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -102,6 +102,7 @@ enum VMStateFlags { VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ VMS_MUST_EXIST = 0x1000, /* Field must exist in input */ VMS_ALLOC = 0x2000, /* Alloc a buffer on the destination */ + VMS_MULTIPLY_ELEMENTS = 0x4000, /* multiply varray size by field->num */ }; typedef struct { @@ -246,6 +247,16 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_2darray(_state, _field, _type, _n1, _n2), \ } +#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/migration/vmstate.c b/migration/vmstate.c index f70fe59a3c..a7ad7f2216 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -28,6 +28,10 @@ static int vmstate_n_elems(void *opaque, VMStateField *field) n_elems = *(uint8_t *)(opaque+field->num_offset); } + if (field->flags & VMS_MULTIPLY_ELEMENTS) { + n_elems *= field->num; + } + return n_elems; } |