Patchwork [10/26] vmstate: Add pre_load() hook

login
register
mail settings
Submitter Juan Quintela
Date Sept. 10, 2009, 1:04 a.m.
Message ID <4d3837bad6fe792004dcd479da90ae34a368fc98.1252543872.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/33246/
State Superseded
Headers show

Comments

Juan Quintela - Sept. 10, 2009, 1:04 a.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/hw.h  |    1 +
 savevm.c |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/hw.h b/hw/hw.h
index c85ce50..8e75a04 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -306,6 +306,7 @@  struct VMStateDescription {
     int minimum_version_id;
     int minimum_version_id_old;
     LoadStateHandler *load_state_old;
+    int (*pre_load)(void *opaque);
     int (*post_load)(void *opaque);
     VMStateField *fields;
 };
diff --git a/savevm.c b/savevm.c
index 38f9946..8ae8d16 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1028,6 +1028,11 @@  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
     if  (version_id < vmsd->minimum_version_id) {
         return vmsd->load_state_old(f, opaque, version_id);
     }
+    if (vmsd->pre_load) {
+        int ret = vmsd->pre_load(opaque);
+        if (ret)
+            return ret;
+    }
     while(field->name) {
         if (field->version_id <= version_id) {
             void *base_addr = opaque + field->offset;