From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c01IY-0000z2-IQ for qemu-devel@nongnu.org; Fri, 28 Oct 2016 03:09:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c01IU-000052-UJ for qemu-devel@nongnu.org; Fri, 28 Oct 2016 03:09:54 -0400 From: Alberto Garcia Date: Fri, 28 Oct 2016 10:08:07 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH v13 06/19] block: Check blockers in all nodes involved in a block-commit job List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Eric Blake , Markus Armbruster , Max Reitz , Alberto Garcia qmp_block_commit() checks for op blockers in the active and destination (base) images. However all nodes between top_bs and base are also involved, and they are removed from the chain afterwards. In addition to that, if top_bs is not the active layer then top_bs's overlay also needs to be checked because it's involved in the job (its backing image string needs to be updated to point to 'base'). This patch checks that none of those nodes are blocked. Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf --- blockdev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index d11a74f..de5b5f5 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3001,6 +3001,7 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device, Error **errp) { BlockDriverState *bs; + BlockDriverState *iter; BlockDriverState *base_bs, *top_bs; AioContext *aio_context; Error *local_err = NULL; @@ -3067,8 +3068,10 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device, assert(bdrv_get_aio_context(base_bs) == aio_context); - if (bdrv_op_is_blocked(base_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) { - goto out; + for (iter = top_bs; iter != backing_bs(base_bs); iter = backing_bs(iter)) { + if (bdrv_op_is_blocked(iter, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) { + goto out; + } } /* Do not allow attempts to commit an image into itself */ @@ -3086,6 +3089,10 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device, commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed, on_error, block_job_cb, bs, &local_err, false); } else { + BlockDriverState *overlay_bs = bdrv_find_overlay(bs, top_bs); + if (bdrv_op_is_blocked(overlay_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) { + goto out; + } commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed, on_error, block_job_cb, bs, has_backing_file ? backing_file : NULL, &local_err); -- 2.9.3