In cases where we abort the block/mirror job, there's no point in installing the new backing chain before we finish aborting.
Move this to the "success" portion of mirror_exit. Signed-off-by: John Snow <js...@redhat.com> --- block/mirror.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index cba555b4ef..c164fee883 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -642,16 +642,6 @@ static void mirror_exit(Job *job) * required before it could become a backing file of target_bs. */ bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL, &error_abort); - if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) { - BlockDriverState *backing = s->is_none_mode ? src : s->base; - if (backing_bs(target_bs) != backing) { - bdrv_set_backing_hd(target_bs, backing, &local_err); - if (local_err) { - error_report_err(local_err); - ret = -EPERM; - } - } - } if (s->to_replace) { replace_aio_context = bdrv_get_aio_context(s->to_replace); @@ -659,9 +649,18 @@ static void mirror_exit(Job *job) } if (s->should_complete && ret == 0) { - BlockDriverState *to_replace = src; - if (s->to_replace) { - to_replace = s->to_replace; + BlockDriverState *to_replace = s->to_replace ? s->to_replace : src; + + if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) { + BlockDriverState *backing = s->is_none_mode ? src : s->base; + if (backing_bs(target_bs) != backing) { + bdrv_set_backing_hd(target_bs, backing, &local_err); + if (local_err) { + error_report_err(local_err); + ret = -EPERM; + goto clean; + } + } } if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) { @@ -678,6 +677,8 @@ static void mirror_exit(Job *job) ret = -EPERM; } } + + clean: if (s->to_replace) { bdrv_op_unblock_all(s->to_replace, s->replace_blocker); error_free(s->replace_blocker); -- 2.14.4