vmstate: Add pre/post_save() hooks

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Juan Quintela 2009-09-10 03:04:32 +02:00 committed by Anthony Liguori
parent fd4d52deab
commit 8fb0791d30
2 changed files with 8 additions and 0 deletions

View File

@ -308,6 +308,8 @@ struct VMStateDescription {
LoadStateHandler *load_state_old; LoadStateHandler *load_state_old;
int (*pre_load)(void *opaque); int (*pre_load)(void *opaque);
int (*post_load)(void *opaque); int (*post_load)(void *opaque);
void (*pre_save)(const void *opaque);
void (*post_save)(const void *opaque);
VMStateField *fields; VMStateField *fields;
}; };

View File

@ -1073,6 +1073,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
{ {
VMStateField *field = vmsd->fields; VMStateField *field = vmsd->fields;
if (vmsd->pre_save) {
vmsd->pre_save(opaque);
}
while(field->name) { while(field->name) {
const void *base_addr = opaque + field->offset; const void *base_addr = opaque + field->offset;
int i, n_elems = 1; int i, n_elems = 1;
@ -1096,6 +1099,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
} }
field++; field++;
} }
if (vmsd->post_save) {
vmsd->post_save(opaque);
}
} }
static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id) static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)