block: early check for blockers on drive-mirror
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 7 Feb 2018 16:29:20 +0000 (17:29 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 13 Feb 2018 11:27:17 +0000 (12:27 +0100)
Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE,
it is checked a bit late and the result is that the target is
created even if drive-mirror subsequently fails.  Add an early
check to avoid this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c

index bdbdeae7e451cf194abcfc940095cad7524bcdff..7423c5317b98d0f43f350bf0d0e375b29181bf8e 100644 (file)
@@ -3569,6 +3569,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
         return;
     }
 
+    /* Early check to avoid creating target */
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) {
+        return;
+    }
+
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);