From: Jiri Denemark Date: Thu, 1 Oct 2015 19:54:38 +0000 (+0200) Subject: qemu: Copy completed migration stats only on success X-Git-Tag: v1.2.21-rc1~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b106c8b910ec49f1018146dd82b0f93833a66600;p=thirdparty%2Flibvirt.git qemu: Copy completed migration stats only on success 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 --- diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c771db688a..ff9491cdd2 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -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); }