[libvirt] [PATCH] qemu: Fix type of a completed job

Jiri Denemark posted 1 patch 6 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/b49505536b6c715c5bf7a40c627798fb815121c9.1515707335.git.jdenemar@redhat.com
src/qemu/qemu_migration.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
[libvirt] [PATCH] qemu: Fix type of a completed job
Posted by Jiri Denemark 6 years, 3 months ago
Libvirt 3.7.0 and earlier libvirt reported a migration job as completed
immediately after QEMU finished sending migration data at which point
migration was not really complete yet. Commit v3.7.0-29-g3f2d6d829e
fixed this, but caused a regression in reporting statistics for
completed jobs which started reporting the job as still running. This
happened because the completed job statistics including the job status
are copied from the running job before we finally mark it as completed.

Let's make sure QEMU_DOMAIN_JOB_STATUS_COMPLETED is always set in the
completed job info even when the job has not finished yet.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c1ceb164d1..a56bc596ff 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1646,8 +1646,10 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
     qemuDomainJobInfoUpdateTime(jobInfo);
     qemuDomainJobInfoUpdateDowntime(jobInfo);
     VIR_FREE(priv->job.completed);
-    if (VIR_ALLOC(priv->job.completed) == 0)
+    if (VIR_ALLOC(priv->job.completed) == 0) {
         *priv->job.completed = *jobInfo;
+        priv->job.completed->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
+    }
 
     if (asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT &&
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
@@ -5479,8 +5481,9 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
     }
 
     if (dom) {
-        priv->job.completed = jobInfo;
-        jobInfo = NULL;
+        VIR_STEAL_PTR(priv->job.completed, jobInfo);
+        priv->job.completed->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
+
         if (qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
                                     QEMU_MIGRATION_COOKIE_STATS) < 0)
             VIR_WARN("Unable to encode migration cookie");
-- 
2.15.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Fix type of a completed job
Posted by Pavel Hrdina 6 years, 3 months ago
On Thu, Jan 11, 2018 at 10:48:55PM +0100, Jiri Denemark wrote:
> Libvirt 3.7.0 and earlier libvirt reported a migration job as completed
> immediately after QEMU finished sending migration data at which point
> migration was not really complete yet. Commit v3.7.0-29-g3f2d6d829e
> fixed this, but caused a regression in reporting statistics for
> completed jobs which started reporting the job as still running. This
> happened because the completed job statistics including the job status
> are copied from the running job before we finally mark it as completed.
> 
> Let's make sure QEMU_DOMAIN_JOB_STATUS_COMPLETED is always set in the
> completed job info even when the job has not finished yet.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1523036
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list