[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 1/7] qemu: Store completed stats at the very end of migration



Statistics for a completed migration only make sense if the migration
was successful. Let's don't store them in priv->job.completed until we
are sure it was a success.

Signed-off-by: Jiri Denemark <jdenemar redhat com>
---

Notes:
    Version 2:
    - no change

 src/qemu/qemu_migration.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 704e182..97e98bb 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5716,6 +5716,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
     unsigned long long timeReceived = 0;
     virObjectEventPtr event;
     int rc;
+    qemuDomainJobInfoPtr jobInfo = NULL;
 
     VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
@@ -5859,8 +5860,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
     }
 
     if (mig->jobInfo) {
-        qemuDomainJobInfoPtr jobInfo = mig->jobInfo;
-        priv->job.completed = jobInfo;
+        jobInfo = mig->jobInfo;
         mig->jobInfo = NULL;
 
         if (jobInfo->sent && timeReceived) {
@@ -5868,8 +5868,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
             jobInfo->received = timeReceived;
             jobInfo->timeDeltaSet = true;
         }
-        qemuDomainJobInfoUpdateTime(priv->job.completed);
-        qemuDomainJobInfoUpdateDowntime(priv->job.completed);
+        qemuDomainJobInfoUpdateTime(jobInfo);
+        qemuDomainJobInfoUpdateDowntime(jobInfo);
     }
 
     dom = virGetDomain(dconn, vm->def->name, vm->def->uuid);
@@ -5908,16 +5908,20 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
         qemuDomainEventQueue(driver, event);
     }
 
-    if (dom &&
-        qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
-                                QEMU_MIGRATION_COOKIE_STATS) < 0)
-        VIR_WARN("Unable to encode migration cookie");
+    if (dom) {
+        priv->job.completed = jobInfo;
+        jobInfo = NULL;
+        if (qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
+                                    QEMU_MIGRATION_COOKIE_STATS) < 0)
+            VIR_WARN("Unable to encode migration cookie");
+    }
 
     qemuMigrationJobFinish(driver, vm);
     if (!virDomainObjIsActive(vm))
         qemuDomainRemoveInactive(driver, vm);
 
  cleanup:
+    VIR_FREE(jobInfo);
     virPortAllocatorRelease(driver->migrationPorts, port);
     if (priv->mon)
         qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL);
-- 
2.7.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]