[PATCH 3/4] qemu: fix race between disk mirror fail and cancel

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

 



If a VM migration is aborted, a disk mirror may be failed by QEMU before
libvirt has a chance to cancel it. The disk->mirrorState remains at
_ABORT in this case, and this breaks subsequent mirrorings of that disk.

We should instead check the mirrorState directly and transition to _NONE
if it is already aborted. Do the check *after* aborting the block job in
QEMU to avoid a race.

Signed-off-by: Michael Chapman <mike@xxxxxxxxxxxxxxxxx>
---
 src/qemu/qemu_migration.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 21432c0..39ca37c 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1852,6 +1852,10 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
         } else {
             VIR_WARN("Unable to enter monitor. No block job cancelled");
         }
+
+        /* If disk mirror is already aborted, clear the mirror state now */
+        if (disk->mirrorState == VIR_DOMAIN_DISK_MIRROR_STATE_ABORT)
+            disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
     }
     if (err)
         virSetError(err);
@@ -1920,6 +1924,10 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
             ret = -1;
             goto cleanup;
         }
+
+        /* If disk mirror is already aborted, clear the mirror state now */
+        if (disk->mirrorState == VIR_DOMAIN_DISK_MIRROR_STATE_ABORT)
+            disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
     }
 
  cleanup:
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]