diff options
author | Juan Quintela <quintela@redhat.com> | 2009-09-29 22:49:07 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-05 09:32:43 -0500 |
commit | f11f6a5fff3d23e4ef3b3ef6fec53c5caf0378d5 (patch) | |
tree | c79cdc502e11c282803c4b895a7d215fbd176104 /savevm.c | |
parent | 3c8ce630c5daaab3508a4ac0370de6bfd57ce7c5 (diff) | |
download | qemu-f11f6a5fff3d23e4ef3b3ef6fec53c5caf0378d5.zip qemu-f11f6a5fff3d23e4ef3b3ef6fec53c5caf0378d5.tar.gz qemu-f11f6a5fff3d23e4ef3b3ef6fec53c5caf0378d5.tar.bz2 |
vmstate: Add suppot for field_exist() test
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 | 40 |
1 files changed, 23 insertions, 17 deletions
@@ -1055,7 +1055,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, return ret; } while(field->name) { - if (field->version_id <= version_id) { + if ((field->field_exists && + field->field_exists(opaque, version_id)) || + (!field->field_exists && + field->version_id <= version_id)) { void *base_addr = opaque + field->offset; int ret, i, n_elems = 1; @@ -1101,24 +1104,27 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, vmsd->pre_save(opaque); } while(field->name) { - void *base_addr = opaque + field->offset; - int i, n_elems = 1; + if (!field->field_exists || + field->field_exists(opaque, vmsd->version_id)) { + void *base_addr = opaque + field->offset; + int i, n_elems = 1; - if (field->flags & VMS_ARRAY) { - n_elems = field->num; - } else if (field->flags & VMS_VARRAY) { - n_elems = *(size_t *)(opaque+field->num_offset); - } - if (field->flags & VMS_POINTER) { - base_addr = *(void **)base_addr; - } - for (i = 0; i < n_elems; i++) { - void *addr = base_addr + field->size * i; + if (field->flags & VMS_ARRAY) { + n_elems = field->num; + } else if (field->flags & VMS_VARRAY) { + n_elems = *(size_t *)(opaque+field->num_offset); + } + if (field->flags & VMS_POINTER) { + base_addr = *(void **)base_addr; + } + for (i = 0; i < n_elems; i++) { + void *addr = base_addr + field->size * i; - if (field->flags & VMS_STRUCT) { - vmstate_save_state(f, field->vmsd, addr); - } else { - field->info->put(f, addr, field->size); + if (field->flags & VMS_STRUCT) { + vmstate_save_state(f, field->vmsd, addr); + } else { + field->info->put(f, addr, field->size); + } } } field++; |