[PATCH 3/3] qemu: Call migrate-incoming with exit-on-error=false

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The exit-on-error=false argument of migrate-incoming tells the QEMU
process to keep running when incoming migration fails, which helps us in
two ways:

1. When migration enters Finish phase to cleanup the process, the domain
   might not even exist on the destination (because it has already been
   cleaned up by EOF monitor callback) and we would get rather unhelpful
   "operation failed: domain is no longer running" error message.

2. We can get the error that caused incoming migration to fail directly
   from QEMU via query-migrate QMP command.

https://issues.redhat.com/browse/RHEL-7041

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c    | 9 ++++++++-
 src/qemu/qemu_monitor.c      | 8 +++++---
 src/qemu/qemu_monitor.h      | 3 ++-
 src/qemu/qemu_monitor_json.c | 4 +++-
 src/qemu/qemu_monitor_json.h | 3 ++-
 5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f9f40a2b03..50e350b0c4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2378,11 +2378,18 @@ qemuMigrationDstRun(virDomainObj *vm,
                     const char *uri,
                     virDomainAsyncJob asyncJob)
 {
+    virTristateBool exitOnError = VIR_TRISTATE_BOOL_ABSENT;
     qemuDomainObjPrivate *priv = vm->privateData;
     int rv;
 
     VIR_DEBUG("Setting up incoming migration with URI %s", uri);
 
+    /* Ask QEMU not to exit on failure during incoming migration (if supported)
+     * so that we can properly check and report error during Finish phase.
+     */
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_INCOMING_EXIT_ON_ERROR))
+        exitOnError = VIR_TRISTATE_BOOL_NO;
+
     if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
         return -1;
 
@@ -2390,7 +2397,7 @@ qemuMigrationDstRun(virDomainObj *vm,
     if (rv < 0)
         goto exit_monitor;
 
-    rv = qemuMonitorMigrateIncoming(priv->mon, uri);
+    rv = qemuMonitorMigrateIncoming(priv->mon, uri, exitOnError);
 
  exit_monitor:
     qemuDomainObjExitMonitor(vm);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c198ddb625..ec2f166785 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3811,13 +3811,15 @@ qemuMonitorGetMemoryDeviceInfo(qemuMonitor *mon,
 
 int
 qemuMonitorMigrateIncoming(qemuMonitor *mon,
-                           const char *uri)
+                           const char *uri,
+                           virTristateBool exitOnError)
 {
-    VIR_DEBUG("uri=%s", uri);
+    VIR_DEBUG("uri=%s, exitOnError=%s",
+              uri, virTristateBoolTypeToString(exitOnError));
 
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONMigrateIncoming(mon, uri);
+    return qemuMonitorJSONMigrateIncoming(mon, uri, exitOnError);
 }
 
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index ac3a7b6db3..c74892c4dc 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1294,7 +1294,8 @@ int qemuMonitorGetMemoryDeviceInfo(qemuMonitor *mon,
     ATTRIBUTE_NONNULL(2);
 
 int qemuMonitorMigrateIncoming(qemuMonitor *mon,
-                               const char *uri);
+                               const char *uri,
+                               virTristateBool exitOnError);
 
 int qemuMonitorMigrateStartPostCopy(qemuMonitor *mon);
 
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6500e01d3f..9f417d27c6 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7269,13 +7269,15 @@ qemuMonitorJSONFindLinkPath(qemuMonitor *mon,
 
 int
 qemuMonitorJSONMigrateIncoming(qemuMonitor *mon,
-                               const char *uri)
+                               const char *uri,
+                               virTristateBool exitOnError)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("migrate-incoming",
                                            "s:uri", uri,
+                                           "T:exit-on-error", exitOnError,
                                            NULL)))
         return -1;
 
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 0214e9e9ff..2f5a021f56 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -607,7 +607,8 @@ qemuMonitorJSONFindLinkPath(qemuMonitor *mon,
 
 int
 qemuMonitorJSONMigrateIncoming(qemuMonitor *mon,
-                               const char *uri)
+                               const char *uri,
+                               virTristateBool exitOnError)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
 int
-- 
2.47.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux