<div dir="ltr">Hi,<div><br></div><div>It seems that I found a bug in the qemuMigrationWaitForCompletion(). It will do a sleep of 50 ms, even when qemuMigrationUpdateJobStatus() detects that a migration has completed. </div><div><br></div><div><br></div><div>Here is the original implementation of the while loop. </div><div><br></div><div><br></div><div><div>   while (jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {</div><div>        /* Poll every 50ms for progress & to allow cancellation */</div><div>        struct timespec ts = { .tv_sec = 0, .tv_nsec = 50 * 1000 * 1000ull };</div><div><br></div><div>        if (qemuMigrationUpdateJobStatus(driver, vm, job, asyncJob) == -1)</div><div>            break;</div><div><br></div><div>        /* cancel migration if disk I/O error is emitted while migrating */</div><div>        if (abort_on_error &&</div><div>            virDomainObjGetState(vm, &pauseReason) == VIR_DOMAIN_PAUSED &&</div><div>            pauseReason == VIR_DOMAIN_PAUSED_IOERROR) {</div><div>            virReportError(VIR_ERR_OPERATION_FAILED,</div><div>                           _("%s: %s"), job, _("failed due to I/O error"));</div><div>            break;</div><div>        }</div><div><br></div></div>







<div><div>        if (dconn && virConnectIsAlive(dconn) <= 0) {</div><div>            virReportError(VIR_ERR_OPERATION_FAILED, "%s",</div><div>                           _("Lost connection to destination host"));</div><div>            break;</div><div>        }</div><div><br></div><div><div>        virObjectUnlock(vm);</div><div><br></div><div>        nanosleep(&ts, NULL);</div><div><br></div><div>        virObjectLock(vm);</div></div><div>    }</div></div><div><br></div><div><br></div><div>Even when qemuMigrationUpdateJobStatus() detects a migration has completed, the nanosleep() will be called again. When the while condition is checked, then the program breaks from the while loop. This introduces an unnecessary sleep of 50 ms which can be avoided by doing a sleep first. The code should likely be structured as following. </div><div><br></div><div><div>   while (jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {</div><div>        /* Poll every 50ms for progress & to allow cancellation */</div><div>        struct timespec ts = { .tv_sec = 0, .tv_nsec = 50 * 1000 * 1000ull };</div><div> </div><div>        // do sleep here.</div><div>        virObjectUnlock(vm);</div><div><br></div><div>        nanosleep(&ts, NULL);</div><div><br></div><div>        virObjectLock(vm);</div><div><br></div><div>        if (qemuMigrationUpdateJobStatus(driver, vm, job, asyncJob) == -1)</div><div>            break;</div><div><br></div><div>        /* cancel migration if disk I/O error is emitted while migrating */</div><div>        if (abort_on_error &&</div><div>            virDomainObjGetState(vm, &pauseReason) == VIR_DOMAIN_PAUSED &&</div><div>            pauseReason == VIR_DOMAIN_PAUSED_IOERROR) {</div><div>            virReportError(VIR_ERR_OPERATION_FAILED,</div><div>                           _("%s: %s"), job, _("failed due to I/O error"));</div><div>            break;</div><div>        }</div></div><div><br></div><div><div>        if (dconn && virConnectIsAlive(dconn) <= 0) {</div><div>            virReportError(VIR_ERR_OPERATION_FAILED, "%s",</div><div>                           _("Lost connection to destination host"));</div><div>            break;</div><div>        }</div><div><br></div><div>    }</div></div><div><br></div><div><br></div><div>I have filed a bug report at redhat bugzilla, with a bug id 1210502. The link is below.</div><div><a href="https://bugzilla.redhat.com/show_bug.cgi?id=1210502">https://bugzilla.redhat.com/show_bug.cgi?id=1210502</a><br></div><div><br></div><div>I also prepared a patch for fixing it. It is attached. </div><div><br></div><div>Any comments?</div><div><br></div></div>