From: Juan Quintela Date: Thu, 10 Sep 2009 01:04:32 +0000 (+0200) Subject: vmstate: Add pre/post_save() hooks X-Git-Tag: v0.12.0-rc0~1153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fb0791d30bea0f2ca071ab571e71dfa1cc49085;p=thirdparty%2Fqemu.git vmstate: Add pre/post_save() hooks Signed-off-by: Juan Quintela Signed-off-by: Anthony Liguori --- diff --git a/hw/hw.h b/hw/hw.h index 8e75a040a91..d64a0e82214 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -308,6 +308,8 @@ struct VMStateDescription { LoadStateHandler *load_state_old; int (*pre_load)(void *opaque); int (*post_load)(void *opaque); + void (*pre_save)(const void *opaque); + void (*post_save)(const void *opaque); VMStateField *fields; }; diff --git a/savevm.c b/savevm.c index 8ae8d1627d6..c4bee378b91 100644 --- a/savevm.c +++ b/savevm.c @@ -1073,6 +1073,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, { VMStateField *field = vmsd->fields; + if (vmsd->pre_save) { + vmsd->pre_save(opaque); + } while(field->name) { const void *base_addr = opaque + field->offset; int i, n_elems = 1; @@ -1096,6 +1099,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, } field++; } + if (vmsd->post_save) { + vmsd->post_save(opaque); + } } static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)