From: Paolo Bonzini Date: Wed, 7 Feb 2018 16:29:20 +0000 (+0100) Subject: block: early check for blockers on drive-mirror X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=cb2af9176fcb6b0b71bbac8c83498c4caa37ab05;p=qemu.git block: early check for blockers on drive-mirror 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 Reviewed-by: Fam Zheng Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- diff --git a/blockdev.c b/blockdev.c index bdbdeae7e4..7423c5317b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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);