diff mbox

[5/6] savevm: Allow set_params and save_live_state to error

Message ID 20101006205928.32127.85159.stgit@s20.home (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Williamson Oct. 6, 2010, 8:59 p.m. UTC
None
diff mbox

Patch

diff --git a/block-migration.c b/block-migration.c
index 0bfdb73..5fb3b72 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -628,13 +628,15 @@  static int block_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static void block_set_params(int blk_enable, int shared_base, void *opaque)
+static int block_set_params(int blk_enable, int shared_base, void *opaque)
 {
     block_mig_state.blk_enable = blk_enable;
     block_mig_state.shared_base = shared_base;
 
     /* shared base means that blk_enable = 1 */
     block_mig_state.blk_enable |= shared_base;
+
+    return 0;
 }
 
 void blk_mig_init(void)
diff --git a/hw/hw.h b/hw/hw.h
index 91a60ca..95f2d52 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -239,7 +239,7 @@  static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
 int64_t qemu_ftell(QEMUFile *f);
 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
 
-typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque);
+typedef int SaveSetParamsHandler(int blk_enable, int shared, void * opaque);
 typedef int SaveStateHandler(QEMUFile *f, void *opaque);
 typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage,
                                  void *opaque);
diff --git a/savevm.c b/savevm.c
index 89c5fac..ad3ab86 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1414,12 +1414,16 @@  int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
                             int shared)
 {
     SaveStateEntry *se;
+    int ret;
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
         if(se->set_params == NULL) {
             continue;
 	}
-	se->set_params(blk_enable, shared, se->opaque);
+	ret = se->set_params(blk_enable, shared, se->opaque);
+        if (ret < 0) {
+            return ret;
+        }
     }
     
     qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
@@ -1443,7 +1447,10 @@  int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
         qemu_put_be32(f, se->instance_id);
         qemu_put_be32(f, se->version_id);
 
-        se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque);
+        ret = se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque);
+        if (ret < 0) {
+            return ret;
+        }
     }
 
     if (qemu_file_has_error(f)) {
@@ -1474,6 +1481,8 @@  int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
                and reduces the probability that a faster changing state is
                synchronized over and over again. */
             break;
+        } else if (ret < 0) {
+            return ret;
         }
     }
 
@@ -1503,7 +1512,10 @@  int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
         qemu_put_byte(f, QEMU_VM_SECTION_END);
         qemu_put_be32(f, se->section_id);
 
-        se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
+        r = se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
+        if (r < 0) {
+            return r;
+        }
     }
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {