7a3408
From cedb46fe3e884bd23b7ba504fac78e60265a8ea3 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <cedb46fe3e884bd23b7ba504fac78e60265a8ea3@dist-git>
7a3408
From: Jiri Denemark <jdenemar@redhat.com>
7a3408
Date: Fri, 29 May 2015 08:37:59 +0200
7a3408
Subject: [PATCH] qemu: Update migration state according to MIGRATION event
7a3408
7a3408
We don't need to call query-migrate every 50ms when we get the current
7a3408
migration state via MIGRATION event.
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
(cherry picked from commit 6d2edb6a42d0d41971fcf53c16cdc785d36c3ecc)
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1212077
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_migration.c | 14 ++++++++++++--
7a3408
 src/qemu/qemu_process.c   | 31 +++++++++++++++++++++++++++++++
7a3408
 2 files changed, 43 insertions(+), 2 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
7a3408
index a57a177..9a50923 100644
7a3408
--- a/src/qemu/qemu_migration.c
7a3408
+++ b/src/qemu/qemu_migration.c
7a3408
@@ -2552,7 +2552,11 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
7a3408
     qemuDomainObjPrivatePtr priv = vm->privateData;
7a3408
     qemuDomainJobInfoPtr jobInfo = priv->job.current;
7a3408
 
7a3408
-    if (qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
7a3408
+    bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
7a3408
+
7a3408
+    if (events)
7a3408
+        qemuMigrationUpdateJobType(jobInfo);
7a3408
+    else if (qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
7a3408
         return -1;
7a3408
 
7a3408
     switch (jobInfo->type) {
7a3408
@@ -2571,9 +2575,15 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
7a3408
                        qemuMigrationJobName(vm), _("canceled by client"));
7a3408
         return -1;
7a3408
 
7a3408
+    case VIR_DOMAIN_JOB_COMPLETED:
7a3408
+        /* Fetch statistics of a completed migration */
7a3408
+        if (events &&
7a3408
+            qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
7a3408
+            return -1;
7a3408
+        break;
7a3408
+
7a3408
     case VIR_DOMAIN_JOB_BOUNDED:
7a3408
     case VIR_DOMAIN_JOB_UNBOUNDED:
7a3408
-    case VIR_DOMAIN_JOB_COMPLETED:
7a3408
     case VIR_DOMAIN_JOB_LAST:
7a3408
         break;
7a3408
     }
7a3408
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
7a3408
index 1d223d3..577f309 100644
7a3408
--- a/src/qemu/qemu_process.c
7a3408
+++ b/src/qemu/qemu_process.c
7a3408
@@ -1508,6 +1508,36 @@ qemuProcessHandleSpiceMigrated(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
7a3408
 }
7a3408
 
7a3408
 
7a3408
+static int
7a3408
+qemuProcessHandleMigrationStatus(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
7a3408
+                                 virDomainObjPtr vm,
7a3408
+                                 int status,
7a3408
+                                 void *opaque ATTRIBUTE_UNUSED)
7a3408
+{
7a3408
+    qemuDomainObjPrivatePtr priv;
7a3408
+
7a3408
+    virObjectLock(vm);
7a3408
+
7a3408
+    VIR_DEBUG("Migration of domain %p %s changed state to %s",
7a3408
+              vm, vm->def->name,
7a3408
+              qemuMonitorMigrationStatusTypeToString(status));
7a3408
+
7a3408
+    priv = vm->privateData;
7a3408
+    if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT &&
7a3408
+        priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_IN) {
7a3408
+        VIR_DEBUG("got MIGRATION event without a migration job");
7a3408
+        goto cleanup;
7a3408
+    }
7a3408
+
7a3408
+    priv->job.current->status.status = status;
7a3408
+    virDomainObjBroadcast(vm);
7a3408
+
7a3408
+ cleanup:
7a3408
+    virObjectUnlock(vm);
7a3408
+    return 0;
7a3408
+}
7a3408
+
7a3408
+
7a3408
 static qemuMonitorCallbacks monitorCallbacks = {
7a3408
     .eofNotify = qemuProcessHandleMonitorEOF,
7a3408
     .errorNotify = qemuProcessHandleMonitorError,
7a3408
@@ -1532,6 +1562,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
7a3408
     .domainNicRxFilterChanged = qemuProcessHandleNicRxFilterChanged,
7a3408
     .domainSerialChange = qemuProcessHandleSerialChanged,
7a3408
     .domainSpiceMigrated = qemuProcessHandleSpiceMigrated,
7a3408
+    .domainMigrationStatus = qemuProcessHandleMigrationStatus,
7a3408
 };
7a3408
 
7a3408
 static int
7a3408
-- 
7a3408
2.4.5
7a3408