Skip to contentSkip to conversation

savevm: Improve error message for unmigratable devices

PATCH In review Kevin Wolf 2 participants 3 messages Apr 18, 2013

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 savevm: Improve error message for unmigratable devices

Trying to take an internal snapshot when an unmigratable device is in use resuled in an 'Error -22 while writing VM' message. This patch changes it to print the same error message as migration would print:
'State blocked by non-migratable device xyz'

---
 savevm.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
savevm.c +10 -7
index 53515cb..1d00998 100644
@@ -1905,7 +1905,7 @@ void qemu_savevm_state_cancel(void)
     }
 }
 
-static int qemu_savevm_state(QEMUFile *f)
+static void qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
     MigrationParams params = {
@@ -1913,8 +1913,8 @@ static int qemu_savevm_state(QEMUFile *f)
         .shared = 0
     };
 
-    if (qemu_savevm_state_blocked(NULL)) {
-        return -EINVAL;
+    if (qemu_savevm_state_blocked(errp)) {
+        return;
     }
 
     qemu_mutex_unlock_iothread();
@@ -1934,8 +1934,8 @@ static int qemu_savevm_state(QEMUFile *f)
     }
     if (ret != 0) {
         qemu_savevm_state_cancel();
+        error_setg(errp, "Error %d while writing VM\n", ret);
     }
-    return ret;
 }
 
 static int qemu_save_device_state(QEMUFile *f)
@@ -2256,6 +2256,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
     qemu_timeval tv;
     struct tm tm;
     const char *name = qdict_get_try_str(qdict, "name");
+    Error *local_err = NULL;
 
     /* Verify if there is a device that doesn't support snapshots and is writable */
     bs = NULL;
@@ -2314,11 +2315,13 @@ void do_savevm(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "Could not open VM state file\n");
         goto the_end;
     }
-    ret = qemu_savevm_state(f);
+
+    qemu_savevm_state(f, &local_err);
     vm_state_size = qemu_ftell(f);
     qemu_fclose(f);
-    if (ret < 0) {
-        monitor_printf(mon, "Error %d while writing VM\n", ret);
+    if (error_is_set(&local_err)) {
+        qerror_report_err(local_err);
+        error_free(local_err);
         goto the_end;
     }
 
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 7 lines · Kevin Wolf

Trying to take an internal snapshot when an unmigratable device is in use resuled in an 'Error -22 while writing VM' message. This patch changes it to print the same error message as migration would print:
'State blocked by non-migratable device xyz'

---

Hi Kevin,

this patch is not needed because I'm fixing the same in my patch series http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg03287.html in this patch http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg03298.html .

Pavel

author
#2 lore raw

Am 18.04.2013 um 12:43 hat Pavel Hrdina geschrieben:

Quoted 9 lines · Kevin Wolf
Quoted 7 lines

Trying to take an internal snapshot when an unmigratable device is in use resuled in an 'Error -22 while writing VM' message. This patch changes it to print the same error message as migration would print:
'State blocked by non-migratable device xyz'

---

Quoted 7 lines

Hi Kevin,

this patch is not needed because I'm fixing the same in my patch series
http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg03287.html
in this patch
http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg03298.html

Okay, I wasn't CCed on that series, so I wasn't fully aware of what it's touching or not. I'll comment on your series.

Kevin