Skip to contentSkip to conversation

migration: Pass Error ** argument to {save, load}_vmstate

PATCH In review Juan Quintela 3 participants 3 messages May 11, 2017 – May 12, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 migration: Pass Error ** argument to {save, load}_vmstate

This way we use the "normal" way of printing errors for hmp commands.

---

Add err_report_err() in replay-snapshot.c to really print the error messages (dave suggestion)

---
 hmp.c                    |  9 +++++++--
 include/sysemu/sysemu.h  |  4 ++--
 migration/savevm.c       | 51 ++++++++++++++++++++++++------------------------
 replay/replay-snapshot.c |  8 ++++++--
 vl.c                     |  4 +++-
 5 files changed, 43 insertions(+), 33 deletions(-)
hmp.c +7 -2
index 524e589..b9dd933 100644
@@ -1274,17 +1274,22 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();
     const char *name = qdict_get_str(qdict, "name");
+    Error *err = NULL;
 
     vm_stop(RUN_STATE_RESTORE_VM);
 
-    if (load_vmstate(name) == 0 && saved_vm_running) {
+    if (load_vmstate(name, &err) == 0 && saved_vm_running) {
         vm_start();
     }
+    hmp_handle_error(mon, &err);
 }
 
 void hmp_savevm(Monitor *mon, const QDict *qdict)
 {
-    save_vmstate(qdict_get_try_str(qdict, "name"));
+    Error *err = NULL;
+
+    save_vmstate(qdict_get_try_str(qdict, "name"), &err);
+    hmp_handle_error(mon, &err);
 }
 
 void hmp_delvm(Monitor *mon, const QDict *qdict)
include/sysemu/sysemu.h +2 -2
index 9240fdb..16f740f 100644
@@ -75,8 +75,8 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-int save_vmstate(const char *name);
-int load_vmstate(const char *name);
+int save_vmstate(const char *name, Error **errp);
+int load_vmstate(const char *name, Error **errp);
 
 void qemu_announce_self(void);
 
migration/savevm.c +25 -26

145 lines not on this page · raw message

replay/replay-snapshot.c +6 -2
index 8cced46..c75cd38 100644
@@ -62,14 +62,18 @@ void replay_vmstate_register(void)
 
 void replay_vmstate_init(void)
 {
+    Error *err = NULL;
+
     if (replay_snapshot) {
         if (replay_mode == REPLAY_MODE_RECORD) {
-            if (save_vmstate(replay_snapshot) != 0) {
+            if (save_vmstate(replay_snapshot, &err) != 0) {
+                error_report_err(err);
                 error_report("Could not create snapshot for icount record");
                 exit(1);
             }
         } else if (replay_mode == REPLAY_MODE_PLAY) {
-            if (load_vmstate(replay_snapshot) != 0) {
+            if (load_vmstate(replay_snapshot, &err) != 0) {
+                error_report_err(err);
                 error_report("Could not load snapshot for icount replay");
                 exit(1);
             }
vl.c +3 -1
index 58023fc..2520b97 100644
@@ -4686,7 +4686,9 @@ int main(int argc, char **argv, char **envp)
     if (replay_mode != REPLAY_MODE_NONE) {
         replay_vmstate_init();
     } else if (loadvm) {
-        if (load_vmstate(loadvm) < 0) {
+        Error *local_err = NULL;
+        if (load_vmstate(loadvm, &local_err) < 0) {
+            error_report_err(local_err);
             autostart = 0;
         }
     }
Signature · 1 line
2.9.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 12 lines · Juan Quintela

This way we use the "normal" way of printing errors for hmp commands.

---

Add err_report_err() in replay-snapshot.c to really print the error messages (dave suggestion)

Quoted 8 lines
---
 hmp.c                    |  9 +++++++--
 include/sysemu/sysemu.h  |  4 ++--
 migration/savevm.c       | 51 ++++++++++++++++++++++++------------------------
 replay/replay-snapshot.c |  8 ++++++--
 vl.c                     |  4 +++-
 5 files changed, 43 insertions(+), 33 deletions(-)