render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 9e01d644cf472248e05cb6ac98271b1af6722f28 Mon Sep 17 00:00:00 2001
Message-Id: <9e01d644cf472248e05cb6ac98271b1af6722f28@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 12 Sep 2016 10:24:21 +0200
Subject: [PATCH] qemu: Don't use query-migrate on destination

When migration fails, we need to poke QEMU monitor to check for a reason
of the failure. We did this using query-migrate QMP command, which is
not supposed to return any meaningful result on the destination side.
Thus if the monitor was still functional when we detected the migration
failure, parsing the answer from query-migrate always failed with the
following error message:

    "info migration reply was missing return status"

This irrelevant message was then used as the reason for the migration
failure replacing any message we might have had.

Let's use harmless query-status for poking the monitor to make sure we
only get an error if the monitor connection is broken.

https://bugzilla.redhat.com/show_bug.cgi?id=1374613

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 56258a388fbb1d44ef6d6e59c7a0795f1fae53d0)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_domain.c    | 20 ++++++++++++++++++++
 src/qemu/qemu_domain.h    |  4 ++++
 src/qemu/qemu_migration.c |  6 +-----
 src/qemu/qemu_monitor.c   |  8 ++++++++
 src/qemu/qemu_monitor.h   |  1 +
 5 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8eb6e51..989baa5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6057,3 +6057,23 @@ qemuDomainVcpuPersistOrder(virDomainDefPtr def)
         }
     }
 }
+
+
+int
+qemuDomainCheckMonitor(virQEMUDriverPtr driver,
+                       virDomainObjPtr vm,
+                       qemuDomainAsyncJob asyncJob)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    int ret;
+
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+        return -1;
+
+    ret = qemuMonitorCheck(priv->mon);
+
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        return -1;
+
+    return ret;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index cc7bd51..f94bfc9 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -730,4 +730,8 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
 void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
     ATTRIBUTE_NONNULL(1);
 
+int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
+                           virDomainObjPtr vm,
+                           qemuDomainAsyncJob asyncJob);
+
 #endif /* __QEMU_DOMAIN_H__ */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 537bfeb..7426bfd 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -6212,14 +6212,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
     }
 
     if (retcode != 0) {
-        qemuDomainJobInfo info;
-
         /* Check for a possible error on the monitor in case Finish was called
          * earlier than monitor EOF handler got a chance to process the error
          */
-        qemuMigrationFetchJobStatus(driver, vm,
-                                    QEMU_ASYNC_JOB_MIGRATION_IN,
-                                    &info);
+        qemuDomainCheckMonitor(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
         goto endjob;
     }
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1f633fc..699dd7d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1612,6 +1612,14 @@ qemuMonitorStopCPUs(qemuMonitorPtr mon)
 
 
 int
+qemuMonitorCheck(qemuMonitorPtr mon)
+{
+    bool running;
+    return qemuMonitorGetStatus(mon, &running, NULL);
+}
+
+
+int
 qemuMonitorGetStatus(qemuMonitorPtr mon,
                      bool *running,
                      virDomainPausedReason *reason)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index d07e60c..09c404a 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -382,6 +382,7 @@ typedef enum {
 VIR_ENUM_DECL(qemuMonitorVMStatus)
 int qemuMonitorVMStatusToPausedReason(const char *status);
 
+int qemuMonitorCheck(qemuMonitorPtr mon);
 int qemuMonitorGetStatus(qemuMonitorPtr mon,
                          bool *running,
                          virDomainPausedReason *reason)
-- 
2.10.0