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