[libvirt] [PATCH 4/7] qemu: Fix a race when computing migration downtime

Jiri Denemark jdenemar at redhat.com
Tue Feb 23 15:41:43 UTC 2016

Computing a total downtime during a migration requires us to store a
time stamp when guest CPUs get stopped. The value (and all other
statistics) is then transferred to the destination to compute the
downtime. Because the stopped time stamp is stored by a STOP event
handler while the statistics which will be sent over to the destination
are copied synchronously within qemuMigrationWaitForCompletion.

Depending on the timing of STOP and MIGRATION events, we may end up
copying (and transferring) statistics without the stopped time stamp
set. Let's make sure we always use the correct time stamp.


Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
 src/qemu/qemu_migration.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 4f305fd..1cfeb51 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4508,6 +4508,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
         priv->job.current->type = VIR_DOMAIN_JOB_FAILED;
         goto cleanup;
+    if (priv->job.completed)
+        priv->job.completed->stopped = priv->job.current->stopped;
     ret = 0;

More information about the libvir-list mailing list