c1c534
From 92867e9b9ff1d9a163c6c166e710ba7c444be520 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <92867e9b9ff1d9a163c6c166e710ba7c444be520@dist-git>
c1c534
From: Jiri Denemark <jdenemar@redhat.com>
c1c534
Date: Thu, 11 Jan 2018 20:47:50 +0100
c1c534
Subject: [PATCH] qemu: Fix type of a completed job
c1c534
c1c534
Libvirt 3.7.0 and earlier libvirt reported a migration job as completed
c1c534
immediately after QEMU finished sending migration data at which point
c1c534
migration was not really complete yet. Commit v3.7.0-29-g3f2d6d829e
c1c534
fixed this, but caused a regression in reporting statistics for
c1c534
completed jobs which started reporting the job as still running. This
c1c534
happened because the completed job statistics including the job status
c1c534
are copied from the running job before we finally mark it as completed.
c1c534
c1c534
Let's make sure QEMU_DOMAIN_JOB_STATUS_COMPLETED is always set in the
c1c534
completed job info even when the job has not finished yet.
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1523036
c1c534
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
c1c534
(cherry picked from commit e8784e7868d44a2ce796b376cf78f0f6c61c114a)
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_migration.c | 9 ++++++---
c1c534
 1 file changed, 6 insertions(+), 3 deletions(-)
c1c534
c1c534
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
c1c534
index af744661f4..b814cc6608 100644
c1c534
--- a/src/qemu/qemu_migration.c
c1c534
+++ b/src/qemu/qemu_migration.c
c1c534
@@ -1623,8 +1623,10 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
c1c534
     qemuDomainJobInfoUpdateTime(jobInfo);
c1c534
     qemuDomainJobInfoUpdateDowntime(jobInfo);
c1c534
     VIR_FREE(priv->job.completed);
c1c534
-    if (VIR_ALLOC(priv->job.completed) == 0)
c1c534
+    if (VIR_ALLOC(priv->job.completed) == 0) {
c1c534
         *priv->job.completed = *jobInfo;
c1c534
+        priv->job.completed->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
c1c534
+    }
c1c534
 
c1c534
     if (asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT &&
c1c534
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
c1c534
@@ -5457,8 +5459,9 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
c1c534
     }
c1c534
 
c1c534
     if (dom) {
c1c534
-        priv->job.completed = jobInfo;
c1c534
-        jobInfo = NULL;
c1c534
+        VIR_STEAL_PTR(priv->job.completed, jobInfo);
c1c534
+        priv->job.completed->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
c1c534
+
c1c534
         if (qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
c1c534
                                     QEMU_MIGRATION_COOKIE_STATS) < 0)
c1c534
             VIR_WARN("Unable to encode migration cookie");
c1c534
-- 
c1c534
2.15.1
c1c534