]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Properly update completed migration stats
authorJiri Denemark <jdenemar@redhat.com>
Thu, 18 Feb 2016 13:44:48 +0000 (14:44 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 8 Mar 2016 15:25:59 +0000 (16:25 +0100)
We should not overwrite all migration statistics on the source with the
numbers sent by the destination since the source may have an updated
view in some cases (such as post-copy migration). It's safer to update
just the timing info we need to get from the destination and be prepared
for the future. And we should only do all this after a successful
migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration.c

index ec96ecbb6b1d5c4aeef2ab707fa1c3307725baf7..34e8f736f41eec193200693734d10c200f6a7251 100644 (file)
@@ -3869,6 +3869,8 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
     virObjectEventPtr event = NULL;
     int rv = -1;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    qemuDomainJobInfoPtr jobInfo = NULL;
 
     VIR_DEBUG("driver=%p, conn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "flags=%x, retcode=%d",
@@ -3886,12 +3888,18 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
                                        QEMU_MIGRATION_COOKIE_STATS)))
         goto cleanup;
 
-    /* Update total times with the values sent by the destination daemon */
-    if (mig->jobInfo) {
-        qemuDomainObjPrivatePtr priv = vm->privateData;
+    if (retcode == 0)
+        jobInfo = priv->job.completed;
+    else
         VIR_FREE(priv->job.completed);
-        priv->job.completed = mig->jobInfo;
-        mig->jobInfo = NULL;
+
+    /* Update times with the values sent by the destination daemon */
+    if (mig->jobInfo && jobInfo) {
+        qemuDomainJobInfoUpdateTime(jobInfo);
+        jobInfo->timeDeltaSet = mig->jobInfo->timeDeltaSet;
+        jobInfo->timeDelta = mig->jobInfo->timeDelta;
+        jobInfo->stats.downtime_set = mig->jobInfo->stats.downtime_set;
+        jobInfo->stats.downtime = mig->jobInfo->stats.downtime;
     }
 
     if (flags & VIR_MIGRATE_OFFLINE)