diff options
author | Juan Quintela <quintela@redhat.com> | 2009-08-20 19:42:27 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 20:30:21 -0500 |
commit | f752a6aae72703e1dc42b1d717bcea7c113b4853 (patch) | |
tree | 49d64e433871d537b7ddb2c849fba1931da74b2d /savevm.c | |
parent | dde0463b4e5e78ab636a298ae28b9a0ba77bc595 (diff) |
Add VMState support for arrays
This patch adds support for saving arrays inside the struct
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 | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -972,15 +972,21 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, } while(field->name) { if (field->version_id <= version_id) { - void *addr = opaque + field->offset; - int ret; + void *base_addr = opaque + field->offset; + int ret, i, n_elems = 1; + if (field->flags & VMS_ARRAY) { + n_elems = field->num; + } if (field->flags & VMS_POINTER) { - addr = *(void **)addr; + base_addr = *(void **)base_addr; } - ret = field->info->get(f, addr, field->size); - if (ret < 0) { - return ret; + for (i = 0; i < n_elems; i++) { + void *addr = base_addr + field->size * i; + ret = field->info->get(f, addr, field->size); + if (ret < 0) { + return ret; + } } } field++; @@ -994,12 +1000,19 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, VMStateField *field = vmsd->fields; while(field->name) { - const void *addr = opaque + field->offset; + const void *base_addr = opaque + field->offset; + int i, n_elems = 1; + if (field->flags & VMS_ARRAY) { + n_elems = field->num; + } if (field->flags & VMS_POINTER) { - addr = *(void **)addr; + base_addr = *(void **)base_addr; + } + for (i = 0; i < n_elems; i++) { + const void *addr = base_addr + field->size * i; + field->info->put(f, addr, field->size); } - field->info->put(f, addr, field->size); field++; } } |