9119d9
From 6b3269813159a2651bddee7113ba08eab948c7ff Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <6b3269813159a2651bddee7113ba08eab948c7ff@dist-git>
9119d9
From: Jiri Denemark <jdenemar@redhat.com>
9119d9
Date: Sat, 6 Sep 2014 01:16:20 +0200
9119d9
Subject: [PATCH] qemu: Propagate QEMU errors during incoming migrations
9119d9
9119d9
When QEMU fails during incoming migration after we successfully started
9119d9
it (i.e., during Perform or Finish phase), we report a rather unhelpful
9119d9
message
9119d9
9119d9
    Unable to read from monitor: Connection reset by peer
9119d9
9119d9
We already have a code that takes error messages from QEMU's error
9119d9
output but we disable it once QEMU successfully starts. This patch
9119d9
postpones this until the end of Finish phase during incoming migration
9119d9
so that we can report a much better error message:
9119d9
9119d9
    internal error: early end of file from monitor: possible problem:
9119d9
    Unknown savevm section or instance '0000:00:05.0/virtio-balloon' 0
9119d9
    load of migration failed
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1090093
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
(cherry picked from commit 03890605dc981f46ac72d17e4ac7db0da1b88e97)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_migration.c |  2 ++
9119d9
 src/qemu/qemu_monitor.c   | 12 +++++++++---
9119d9
 src/qemu/qemu_process.c   |  6 ++++--
9119d9
 3 files changed, 15 insertions(+), 5 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
9119d9
index a7aeca5..2726512 100644
9119d9
--- a/src/qemu/qemu_migration.c
9119d9
+++ b/src/qemu/qemu_migration.c
9119d9
@@ -4689,6 +4689,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
9119d9
  cleanup:
9119d9
     virPortAllocatorRelease(driver->migrationPorts, port);
9119d9
     if (vm) {
9119d9
+        if (priv->mon)
9119d9
+            qemuMonitorSetDomainLog(priv->mon, -1);
9119d9
         VIR_FREE(priv->origname);
9119d9
         virObjectUnlock(vm);
9119d9
     }
9119d9
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
9119d9
index 2edc19b..78f2a20 100644
9119d9
--- a/src/qemu/qemu_monitor.c
9119d9
+++ b/src/qemu/qemu_monitor.c
9119d9
@@ -631,8 +631,11 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque)
9119d9
         error = true;
9119d9
     } else {
9119d9
         if (events & VIR_EVENT_HANDLE_WRITABLE) {
9119d9
-            if (qemuMonitorIOWrite(mon) < 0)
9119d9
+            if (qemuMonitorIOWrite(mon) < 0) {
9119d9
                 error = true;
9119d9
+                if (errno == ECONNRESET)
9119d9
+                    hangup = true;
9119d9
+            }
9119d9
             events &= ~VIR_EVENT_HANDLE_WRITABLE;
9119d9
         }
9119d9
 
9119d9
@@ -642,6 +645,8 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque)
9119d9
             events &= ~VIR_EVENT_HANDLE_READABLE;
9119d9
             if (got < 0) {
9119d9
                 error = true;
9119d9
+                if (errno == ECONNRESET)
9119d9
+                    hangup = true;
9119d9
             } else if (got == 0) {
9119d9
                 eof = true;
9119d9
             } else {
9119d9
@@ -683,8 +688,9 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque)
9119d9
         if (hangup) {
9119d9
             /* Check if an error message from qemu is available and if so, use
9119d9
              * it to overwrite the actual message. It's done only in early
9119d9
-             * startup phases where the message from qemu is certainly more
9119d9
-             * interesting than a "connection reset by peer" message.
9119d9
+             * startup phases or during incoming migration when the message
9119d9
+             * from qemu is certainly more interesting than a
9119d9
+             * "connection reset by peer" message.
9119d9
              */
9119d9
             char *qemuMessage;
9119d9
 
9119d9
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
9119d9
index f68dfbe..9395af1 100644
9119d9
--- a/src/qemu/qemu_process.c
9119d9
+++ b/src/qemu/qemu_process.c
9119d9
@@ -4377,8 +4377,10 @@ int qemuProcessStart(virConnectPtr conn,
9119d9
             goto cleanup;
9119d9
     }
9119d9
 
9119d9
-    /* unset reporting errors from qemu log */
9119d9
-    qemuMonitorSetDomainLog(priv->mon, -1);
9119d9
+    /* Keep watching qemu log for errors during incoming migration, otherwise
9119d9
+     * unset reporting errors from qemu log. */
9119d9
+    if (!migrateFrom)
9119d9
+        qemuMonitorSetDomainLog(priv->mon, -1);
9119d9
 
9119d9
     virCommandFree(cmd);
9119d9
     VIR_FORCE_CLOSE(logfile);
9119d9
-- 
9119d9
2.1.0
9119d9