yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-savevm-Improve-error-message-for-blocked-migration.patch

9ae3a8
From 88b94264928e180cad4067a55cb328fe594985b9 Mon Sep 17 00:00:00 2001
9ae3a8
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
9ae3a8
Date: Fri, 26 Jan 2018 18:53:14 +0100
9ae3a8
Subject: [PATCH 3/4] savevm: Improve error message for blocked migration
9ae3a8
9ae3a8
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
9ae3a8
Message-id: <20180126185315.2342-2-dgilbert@redhat.com>
9ae3a8
Patchwork-id: 78730
9ae3a8
O-Subject: [RHEL7.5 qemu-kvm PATCH 1/2] savevm: Improve error message for blocked migration
9ae3a8
Bugzilla: 1536883
9ae3a8
RH-Acked-by: Peter Xu <peterx@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
If an internal snapshot can't be saved because migration is blocked
9ae3a8
(most commonly probably because of AHCI), we had a really bad error
9ae3a8
message:
9ae3a8
9ae3a8
$ echo -e "savevm foo\nquit" | qemu -M q35 /tmp/test.qcow2 -monitor stdio
9ae3a8
QEMU 2.2.50 monitor - type 'help' for more information
9ae3a8
(qemu) savevm foo
9ae3a8
Error -22 while writing VM
9ae3a8
(qemu) quit
9ae3a8
9ae3a8
This patch converts qemu_savevm_state() to the Error infrastructure so
9ae3a8
that a useful error pointing to the problematic device is produced now:
9ae3a8
9ae3a8
$ echo -e "savevm foo\nquit" | qemu -M q35 /tmp/test.qcow2 -monitor stdio
9ae3a8
QEMU 2.2.50 monitor - type 'help' for more information
9ae3a8
(qemu) savevm foo
9ae3a8
State blocked by non-migratable device '0000:00:1f.2/ich9_ahci'
9ae3a8
(qemu) quit
9ae3a8
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Message-id: 1423574702-23072-1-git-send-email-kwolf@redhat.com
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 5d80448c3fc566e505adfa2b566ec8074442c8e1)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 savevm.c | 11 +++++++----
9ae3a8
 1 file changed, 7 insertions(+), 4 deletions(-)
9ae3a8
9ae3a8
diff --git a/savevm.c b/savevm.c
9ae3a8
index 731d5c0..d34004e 100644
9ae3a8
--- a/savevm.c
9ae3a8
+++ b/savevm.c
9ae3a8
@@ -2199,7 +2199,7 @@ void qemu_savevm_state_cancel(void)
9ae3a8
     }
9ae3a8
 }
9ae3a8
 
9ae3a8
-static int qemu_savevm_state(QEMUFile *f)
9ae3a8
+static int qemu_savevm_state(QEMUFile *f, Error **errp)
9ae3a8
 {
9ae3a8
     int ret;
9ae3a8
     MigrationParams params = {
9ae3a8
@@ -2207,7 +2207,7 @@ static int qemu_savevm_state(QEMUFile *f)
9ae3a8
         .shared = 0
9ae3a8
     };
9ae3a8
 
9ae3a8
-    if (qemu_savevm_state_blocked(NULL)) {
9ae3a8
+    if (qemu_savevm_state_blocked(errp)) {
9ae3a8
         return -EINVAL;
9ae3a8
     }
9ae3a8
 
9ae3a8
@@ -2228,6 +2228,7 @@ static int qemu_savevm_state(QEMUFile *f)
9ae3a8
     }
9ae3a8
     if (ret != 0) {
9ae3a8
         qemu_savevm_state_cancel();
9ae3a8
+        error_setg_errno(errp, -ret, "Error while writing VM state");
9ae3a8
     }
9ae3a8
     return ret;
9ae3a8
 }
9ae3a8
@@ -2603,6 +2604,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
9ae3a8
     qemu_timeval tv;
9ae3a8
     struct tm tm;
9ae3a8
     const char *name = qdict_get_try_str(qdict, "name");
9ae3a8
+    Error *local_err = NULL;
9ae3a8
 
9ae3a8
     /* Verify if there is a device that doesn't support snapshots and is writable */
9ae3a8
     bs = NULL;
9ae3a8
@@ -2661,11 +2663,12 @@ void do_savevm(Monitor *mon, const QDict *qdict)
9ae3a8
         monitor_printf(mon, "Could not open VM state file\n");
9ae3a8
         goto the_end;
9ae3a8
     }
9ae3a8
-    ret = qemu_savevm_state(f);
9ae3a8
+    ret = qemu_savevm_state(f, &local_err);
9ae3a8
     vm_state_size = qemu_ftell(f);
9ae3a8
     qemu_fclose(f);
9ae3a8
     if (ret < 0) {
9ae3a8
-        monitor_printf(mon, "Error %d while writing VM\n", ret);
9ae3a8
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
9ae3a8
+        error_free(local_err);
9ae3a8
         goto the_end;
9ae3a8
     }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8