diff options
author | Juan Quintela <quintela@redhat.com> | 2009-12-02 12:36:38 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 10:04:54 -0600 |
commit | e61a1e0a1147018d26f894c17f56f08117c0ba7b (patch) | |
tree | 52aa322e7c1db506e1717b0ffde3f5b793cc3e28 /savevm.c | |
parent | 8595387e3e08cae5ae1caef5633b551f09ba4211 (diff) |
vmstate: Add support for VBUFFERS
Support for buffer that are pointed by a pointer (i.e. not embedded)
where the size that we want to use is a field in the state.
We also need a new place to store where to start in the middle of the
buffer, as now it is a pointer, not the offset of the 1st field.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r-- | savevm.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -1143,7 +1143,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, field->version_id <= version_id)) { void *base_addr = opaque + field->offset; int ret, i, n_elems = 1; + int size = field->size; + if (field->flags & VMS_VBUFFER) { + size = *(int32_t *)(opaque+field->size_offset); + } if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { @@ -1152,10 +1156,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = *(uint16_t *)(opaque+field->num_offset); } if (field->flags & VMS_POINTER) { - base_addr = *(void **)base_addr; + base_addr = *(void **)base_addr + field->start; } for (i = 0; i < n_elems; i++) { - void *addr = base_addr + field->size * i; + void *addr = base_addr + size * i; if (field->flags & VMS_ARRAY_OF_POINTER) { addr = *(void **)addr; @@ -1163,7 +1167,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, if (field->flags & VMS_STRUCT) { ret = vmstate_load_state(f, field->vmsd, addr, field->vmsd->version_id); } else { - ret = field->info->get(f, addr, field->size); + ret = field->info->get(f, addr, size); } if (ret < 0) { @@ -1192,7 +1196,11 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, field->field_exists(opaque, vmsd->version_id)) { void *base_addr = opaque + field->offset; int i, n_elems = 1; + int size = field->size; + if (field->flags & VMS_VBUFFER) { + size = *(int32_t *)(opaque+field->size_offset); + } if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { @@ -1201,10 +1209,10 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = *(uint16_t *)(opaque+field->num_offset); } if (field->flags & VMS_POINTER) { - base_addr = *(void **)base_addr; + base_addr = *(void **)base_addr + field->start; } for (i = 0; i < n_elems; i++) { - void *addr = base_addr + field->size * i; + void *addr = base_addr + size * i; if (field->flags & VMS_ARRAY_OF_POINTER) { addr = *(void **)addr; @@ -1212,7 +1220,7 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, if (field->flags & VMS_STRUCT) { vmstate_save_state(f, field->vmsd, addr); } else { - field->info->put(f, addr, field->size); + field->info->put(f, addr, size); } } } |