]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Copy completed migration stats only on success
authorJiri Denemark <jdenemar@redhat.com>
Thu, 1 Oct 2015 19:54:38 +0000 (21:54 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 6 Oct 2015 14:15:21 +0000 (16:15 +0200)
The destination host gets detailed statistics about the current
migration form the source host via migration cookie and copies them to
the domain object so that they can be queried using
virDomainGetJobStats. However, we should only copy statistics to the
domain object when migration finished successfully.

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

index c771db688a5ab40a0f7712f628258d11e43af98a..ff9491cdd2dd35f659dc778581c07a543af1d357 100644 (file)
@@ -5671,6 +5671,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
 
         dom = virGetDomain(dconn, vm->def->name, vm->def->uuid);
     } else if (retcode == 0) {
+        unsigned long long timeReceived = 0;
+
+        ignore_value(virTimeMillisNow(&timeReceived));
+
         if (!virDomainObjIsActive(vm)) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("guest unexpectedly quit"));
@@ -5678,16 +5682,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
             goto endjob;
         }
 
-        if (mig->jobInfo) {
-            qemuDomainJobInfoPtr jobInfo = mig->jobInfo;
-            priv->job.completed = jobInfo;
-            mig->jobInfo = NULL;
-            if (jobInfo->sent && virTimeMillisNow(&jobInfo->received) == 0) {
-                jobInfo->timeDelta = jobInfo->received - jobInfo->sent;
-                jobInfo->timeDeltaSet = true;
-            }
-        }
-
         if (qemuMigrationVPAssociatePortProfiles(vm->def) < 0)
             goto endjob;
 
@@ -5745,7 +5739,16 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
             }
         }
 
-        if (priv->job.completed) {
+        if (mig->jobInfo) {
+            qemuDomainJobInfoPtr jobInfo = mig->jobInfo;
+            priv->job.completed = jobInfo;
+            mig->jobInfo = NULL;
+
+            if (jobInfo->sent && timeReceived) {
+                jobInfo->timeDelta = timeReceived - jobInfo->sent;
+                jobInfo->received = timeReceived;
+                jobInfo->timeDeltaSet = true;
+            }
             qemuDomainJobInfoUpdateTime(priv->job.completed);
             qemuDomainJobInfoUpdateDowntime(priv->job.completed);
         }