Only COMPLETED state drops the lock in legacy mode when updating block job state originally, but all finished (COMPLETED/FAILED/CANCELLED/CONCLUDED) block job states may drop the lock since modern block job event handlers were imported.
In the process of 'qemuMigrationSrcNBDCopyCancel', when updating job state of a disk into FAILED/CANCELLED/CONCLUDED, finished jobs for disks that reside before this disk would be checked until next time when 'qemuMigrationSrcNBDCopyCancelled' is called. In this condition, if block jobs have all finished, the condition variable vm->cond would never be signaled and 'qemuMigrationSrcNBDCopyCancel' would hung at 'qemuDomainObjWait'. Expanding the conditions for re-examination could resolve most cases. Signed-off-by: Guangjian Wang <[email protected]> --- src/qemu/qemu_migration.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5d4d8b5a32..09bbbd70c3 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -864,12 +864,12 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObj *vm, { size_t i; size_t active = 0; - size_t completed = 0; + size_t finished = 0; bool failed = false; do { active = 0; - completed = 0; + finished = 0; for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk = vm->def->disks[i]; @@ -899,17 +899,17 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObj *vm, active++; } - if (job->state == VIR_DOMAIN_BLOCK_JOB_COMPLETED) - completed++; + if (!diskPriv->migrating) + finished++; virObjectUnref(job); } - /* Updating completed block job drops the lock thus we have to recheck - * block jobs for disks that reside before the disk(s) with completed + /* Updating finished block job drops the lock thus we have to recheck + * block jobs for disks that reside before the disk(s) with finished * block job. */ - } while (completed > 0); + } while (finished > 0); if (failed) { if (active) { -- 2.53.0
