6ae9ed
From 9e01d644cf472248e05cb6ac98271b1af6722f28 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <9e01d644cf472248e05cb6ac98271b1af6722f28@dist-git>
6ae9ed
From: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
Date: Mon, 12 Sep 2016 10:24:21 +0200
6ae9ed
Subject: [PATCH] qemu: Don't use query-migrate on destination
6ae9ed
6ae9ed
When migration fails, we need to poke QEMU monitor to check for a reason
6ae9ed
of the failure. We did this using query-migrate QMP command, which is
6ae9ed
not supposed to return any meaningful result on the destination side.
6ae9ed
Thus if the monitor was still functional when we detected the migration
6ae9ed
failure, parsing the answer from query-migrate always failed with the
6ae9ed
following error message:
6ae9ed
6ae9ed
    "info migration reply was missing return status"
6ae9ed
6ae9ed
This irrelevant message was then used as the reason for the migration
6ae9ed
failure replacing any message we might have had.
6ae9ed
6ae9ed
Let's use harmless query-status for poking the monitor to make sure we
6ae9ed
only get an error if the monitor connection is broken.
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1374613
6ae9ed
6ae9ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
(cherry picked from commit 56258a388fbb1d44ef6d6e59c7a0795f1fae53d0)
6ae9ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
---
6ae9ed
 src/qemu/qemu_domain.c    | 20 ++++++++++++++++++++
6ae9ed
 src/qemu/qemu_domain.h    |  4 ++++
6ae9ed
 src/qemu/qemu_migration.c |  6 +-----
6ae9ed
 src/qemu/qemu_monitor.c   |  8 ++++++++
6ae9ed
 src/qemu/qemu_monitor.h   |  1 +
6ae9ed
 5 files changed, 34 insertions(+), 5 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6ae9ed
index 8eb6e51..989baa5 100644
6ae9ed
--- a/src/qemu/qemu_domain.c
6ae9ed
+++ b/src/qemu/qemu_domain.c
6ae9ed
@@ -6057,3 +6057,23 @@ qemuDomainVcpuPersistOrder(virDomainDefPtr def)
6ae9ed
         }
6ae9ed
     }
6ae9ed
 }
6ae9ed
+
6ae9ed
+
6ae9ed
+int
6ae9ed
+qemuDomainCheckMonitor(virQEMUDriverPtr driver,
6ae9ed
+                       virDomainObjPtr vm,
6ae9ed
+                       qemuDomainAsyncJob asyncJob)
6ae9ed
+{
6ae9ed
+    qemuDomainObjPrivatePtr priv = vm->privateData;
6ae9ed
+    int ret;
6ae9ed
+
6ae9ed
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
6ae9ed
+        return -1;
6ae9ed
+
6ae9ed
+    ret = qemuMonitorCheck(priv->mon);
6ae9ed
+
6ae9ed
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
6ae9ed
+        return -1;
6ae9ed
+
6ae9ed
+    return ret;
6ae9ed
+}
6ae9ed
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
6ae9ed
index cc7bd51..f94bfc9 100644
6ae9ed
--- a/src/qemu/qemu_domain.h
6ae9ed
+++ b/src/qemu/qemu_domain.h
6ae9ed
@@ -730,4 +730,8 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
6ae9ed
 void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
6ae9ed
     ATTRIBUTE_NONNULL(1);
6ae9ed
 
6ae9ed
+int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
6ae9ed
+                           virDomainObjPtr vm,
6ae9ed
+                           qemuDomainAsyncJob asyncJob);
6ae9ed
+
6ae9ed
 #endif /* __QEMU_DOMAIN_H__ */
6ae9ed
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
6ae9ed
index 537bfeb..7426bfd 100644
6ae9ed
--- a/src/qemu/qemu_migration.c
6ae9ed
+++ b/src/qemu/qemu_migration.c
6ae9ed
@@ -6212,14 +6212,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
6ae9ed
     }
6ae9ed
 
6ae9ed
     if (retcode != 0) {
6ae9ed
-        qemuDomainJobInfo info;
6ae9ed
-
6ae9ed
         /* Check for a possible error on the monitor in case Finish was called
6ae9ed
          * earlier than monitor EOF handler got a chance to process the error
6ae9ed
          */
6ae9ed
-        qemuMigrationFetchJobStatus(driver, vm,
6ae9ed
-                                    QEMU_ASYNC_JOB_MIGRATION_IN,
6ae9ed
-                                    &info;;
6ae9ed
+        qemuDomainCheckMonitor(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
6ae9ed
         goto endjob;
6ae9ed
     }
6ae9ed
 
6ae9ed
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
6ae9ed
index 1f633fc..699dd7d 100644
6ae9ed
--- a/src/qemu/qemu_monitor.c
6ae9ed
+++ b/src/qemu/qemu_monitor.c
6ae9ed
@@ -1612,6 +1612,14 @@ qemuMonitorStopCPUs(qemuMonitorPtr mon)
6ae9ed
 
6ae9ed
 
6ae9ed
 int
6ae9ed
+qemuMonitorCheck(qemuMonitorPtr mon)
6ae9ed
+{
6ae9ed
+    bool running;
6ae9ed
+    return qemuMonitorGetStatus(mon, &running, NULL);
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
+int
6ae9ed
 qemuMonitorGetStatus(qemuMonitorPtr mon,
6ae9ed
                      bool *running,
6ae9ed
                      virDomainPausedReason *reason)
6ae9ed
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
6ae9ed
index d07e60c..09c404a 100644
6ae9ed
--- a/src/qemu/qemu_monitor.h
6ae9ed
+++ b/src/qemu/qemu_monitor.h
6ae9ed
@@ -382,6 +382,7 @@ typedef enum {
6ae9ed
 VIR_ENUM_DECL(qemuMonitorVMStatus)
6ae9ed
 int qemuMonitorVMStatusToPausedReason(const char *status);
6ae9ed
 
6ae9ed
+int qemuMonitorCheck(qemuMonitorPtr mon);
6ae9ed
 int qemuMonitorGetStatus(qemuMonitorPtr mon,
6ae9ed
                          bool *running,
6ae9ed
                          virDomainPausedReason *reason)
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed