提交 33599e2a 编写于 作者: J Juan Quintela 提交者: Anthony Liguori

vmstate: Add support for multiplying size for a constant

When the size that we want to transmit is in another field, but in an
unit different that bytes
Signed-off-by: NJuan Quintela <quintela@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 bfb811ad
...@@ -295,6 +295,7 @@ enum VMStateFlags { ...@@ -295,6 +295,7 @@ enum VMStateFlags {
VMS_ARRAY_OF_POINTER = 0x040, VMS_ARRAY_OF_POINTER = 0x040,
VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */
VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */
}; };
typedef struct { typedef struct {
...@@ -485,6 +486,18 @@ extern const VMStateInfo vmstate_info_unused_buffer; ...@@ -485,6 +486,18 @@ extern const VMStateInfo vmstate_info_unused_buffer;
.offset = vmstate_offset_buffer(_state, _field) + _start, \ .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) { \ #define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
.name = (stringify(_field)), \ .name = (stringify(_field)), \
.version_id = (_version), \ .version_id = (_version), \
......
...@@ -1147,6 +1147,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, ...@@ -1147,6 +1147,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
if (field->flags & VMS_VBUFFER) { if (field->flags & VMS_VBUFFER) {
size = *(int32_t *)(opaque+field->size_offset); size = *(int32_t *)(opaque+field->size_offset);
if (field->flags & VMS_MULTIPLY) {
size *= field->size;
}
} }
if (field->flags & VMS_ARRAY) { if (field->flags & VMS_ARRAY) {
n_elems = field->num; n_elems = field->num;
...@@ -1200,6 +1203,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, ...@@ -1200,6 +1203,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
if (field->flags & VMS_VBUFFER) { if (field->flags & VMS_VBUFFER) {
size = *(int32_t *)(opaque+field->size_offset); size = *(int32_t *)(opaque+field->size_offset);
if (field->flags & VMS_MULTIPLY) {
size *= field->size;
}
} }
if (field->flags & VMS_ARRAY) { if (field->flags & VMS_ARRAY) {
n_elems = field->num; n_elems = field->num;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册