Patchwork [04/13] savevm: add error parameter to qemu_savevm_state_iterate()

login
register
mail settings
Submitter Pavel Hrdina
Date Jan. 9, 2013, 3:17 p.m.
Message ID <83f1955a29f8a6219c96527154651ce065087759.1357741229.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/210725/
State New
Headers show

Comments

Pavel Hrdina - Jan. 9, 2013, 3:17 p.m.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 include/sysemu/sysemu.h |  2 +-
 migration.c             |  2 +-
 savevm.c                | 19 ++++++++++++-------
 3 files changed, 14 insertions(+), 9 deletions(-)

Patch

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index e50f990..afc1fe6 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -76,7 +76,7 @@  bool qemu_savevm_state_blocked(Error **errp);
 int qemu_savevm_state_begin(QEMUFile *f,
                             const MigrationParams *params,
                             Error **errp);
-int qemu_savevm_state_iterate(QEMUFile *f);
+int qemu_savevm_state_iterate(QEMUFile *f, Error **errp);
 int qemu_savevm_state_complete(QEMUFile *f);
 void qemu_savevm_state_cancel(QEMUFile *f);
 uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
diff --git a/migration.c b/migration.c
index cb38867..0f2d0fd 100644
--- a/migration.c
+++ b/migration.c
@@ -691,7 +691,7 @@  static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
     pending_size = qemu_savevm_state_pending(s->file, max_size);
     DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
     if (pending_size >= max_size) {
-        ret = qemu_savevm_state_iterate(s->file);
+        ret = qemu_savevm_state_iterate(s->file, NULL);
         if (ret < 0) {
             migrate_fd_error(s);
         }
diff --git a/savevm.c b/savevm.c
index e2ecb0b..4da2136 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1619,7 +1619,7 @@  int qemu_savevm_state_begin(QEMUFile *f,
  *   0 : We haven't finished, caller have to go again
  *   1 : We have finished, we can go to complete phase
  */
-int qemu_savevm_state_iterate(QEMUFile *f)
+int qemu_savevm_state_iterate(QEMUFile *f, Error **errp)
 {
     SaveStateEntry *se;
     int ret = 1;
@@ -1652,13 +1652,18 @@  int qemu_savevm_state_iterate(QEMUFile *f)
             break;
         }
     }
-    if (ret != 0) {
-        return ret;
+
+    if (ret == 0) {
+        ret = qemu_file_get_error(f);
+        if (ret != 0) {
+            qemu_savevm_state_cancel(f);
+        }
     }
-    ret = qemu_file_get_error(f);
-    if (ret != 0) {
-        qemu_savevm_state_cancel(f);
+
+    if (ret < 0) {
+        error_setg_errno(errp, errno, "Failed to iterate vmstate save.");
     }
+
     return ret;
 }
 
@@ -1766,7 +1771,7 @@  static int qemu_savevm_state(QEMUFile *f)
         goto out;
 
     do {
-        ret = qemu_savevm_state_iterate(f);
+        ret = qemu_savevm_state_iterate(f, NULL);
         if (ret < 0)
             goto out;
     } while (ret == 0);