]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: migration: fix race on cancelling drive mirror
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Fri, 7 Apr 2017 11:06:25 +0000 (14:06 +0300)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 27 Apr 2017 12:38:29 +0000 (14:38 +0200)
0feebab2 adds calling qemuBlockNodeNamesDetect for completed job
on updating block jobs. This affects cancelling drive mirror logic as
this function drops vm lock. Now we have to recheck all disks
before the disk with the completed block job before going
to wait for block job events.

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

index 9ea600c481f4f545e70a1ee4c81bd4bf25dd69fc..eae6698aeeadd541b7665a384755585c0d878ec5 100644 (file)
@@ -655,9 +655,11 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
 {
     size_t i;
     size_t active = 0;
+    size_t completed = 0;
     int status;
     bool failed = false;
 
+ retry:
     for (i = 0; i < vm->def->ndisks; i++) {
         virDomainDiskDefPtr disk = vm->def->disks[i];
         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
@@ -684,6 +686,19 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
         default:
             active++;
         }
+
+        if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
+            completed++;
+    }
+
+    /* Updating completed block job drops the lock thus we have to recheck
+     * block jobs for disks that reside before the disk(s) with completed
+     * block job.
+     */
+    if (completed > 0) {
+        completed = 0;
+        active = 0;
+        goto retry;
     }
 
     if (failed) {