Patchwork [05/13] savevm: add error parameter to qemu_savevm_state_complete()

login
register
mail settings
Submitter Pavel Hrdina
Date Jan. 9, 2013, 3:17 p.m.
Message ID <7426fd07b837c1c567e1928f8f13a2ee492821d9.1357741229.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/210731/
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                | 12 +++++++++---
 3 files changed, 11 insertions(+), 5 deletions(-)

Patch

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index afc1fe6..d02d13f 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -77,7 +77,7 @@  int qemu_savevm_state_begin(QEMUFile *f,
                             const MigrationParams *params,
                             Error **errp);
 int qemu_savevm_state_iterate(QEMUFile *f, Error **errp);
-int qemu_savevm_state_complete(QEMUFile *f);
+int qemu_savevm_state_complete(QEMUFile *f, Error **errp);
 void qemu_savevm_state_cancel(QEMUFile *f);
 uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
 int qemu_loadvm_state(QEMUFile *f);
diff --git a/migration.c b/migration.c
index 0f2d0fd..181d4a4 100644
--- a/migration.c
+++ b/migration.c
@@ -708,7 +708,7 @@  static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
             vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
         }
 
-        if (qemu_savevm_state_complete(s->file) < 0) {
+        if (qemu_savevm_state_complete(s->file, NULL) < 0) {
             migrate_fd_error(s);
         } else {
             migrate_fd_completed(s);
diff --git a/savevm.c b/savevm.c
index 4da2136..14f61e9 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1667,7 +1667,7 @@  int qemu_savevm_state_iterate(QEMUFile *f, Error **errp)
     return ret;
 }
 
-int qemu_savevm_state_complete(QEMUFile *f)
+int qemu_savevm_state_complete(QEMUFile *f, Error **errp)
 {
     SaveStateEntry *se;
     int ret;
@@ -1691,6 +1691,7 @@  int qemu_savevm_state_complete(QEMUFile *f)
         ret = se->ops->save_live_complete(f, se->opaque);
         trace_savevm_section_end(se->section_id);
         if (ret < 0) {
+            error_setg(errp, "Failed to complete vmstate save.");
             return ret;
         }
     }
@@ -1720,7 +1721,12 @@  int qemu_savevm_state_complete(QEMUFile *f)
 
     qemu_put_byte(f, QEMU_VM_EOF);
 
-    return qemu_file_get_error(f);
+    ret = qemu_file_get_error(f);
+    if (ret < 0) {
+        error_setg_errno(errp, errno, "Failed to complete vmstate save.");
+    }
+
+    return ret;
 }
 
 uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
@@ -1776,7 +1782,7 @@  static int qemu_savevm_state(QEMUFile *f)
             goto out;
     } while (ret == 0);
 
-    ret = qemu_savevm_state_complete(f);
+    ret = qemu_savevm_state_complete(f, NULL);
 
 out:
     if (ret == 0) {