From patchwork Fri Oct 14 13:08:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9376789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9112F6022E for ; Fri, 14 Oct 2016 13:10:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7931629178 for ; Fri, 14 Oct 2016 13:10:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AAD02A58C; Fri, 14 Oct 2016 13:10:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 467BB29178 for ; Fri, 14 Oct 2016 13:10:39 +0000 (UTC) Received: from localhost ([::1]:47210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv2Fz-0006jM-0u for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Oct 2016 09:10:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv2FO-0006gg-79 for qemu-devel@nongnu.org; Fri, 14 Oct 2016 09:10:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bv2FL-0007Cu-R4 for qemu-devel@nongnu.org; Fri, 14 Oct 2016 09:10:01 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:33004 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv2FL-00073X-Jk; Fri, 14 Oct 2016 09:09:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ArAgCE2ABY/5tjdVtcHAEBBAEBCgEBgzwBAQEBAR2BU400lV4BAQEBAQEFAYEXAZIsgg+CCIYiAoIOOBQBAgEBAQEBAQFeJ4RiAgR5ED8SPBsZiFYBwwUBAQgohXKCUIdjhRMFjzOEY4VwkACJaYEmhGaQeB42RAYIgnocGYE9b4g1AQEB X-IPAS-Result: A2ArAgCE2ABY/5tjdVtcHAEBBAEBCgEBgzwBAQEBAR2BU400lV4BAQEBAQEFAYEXAZIsgg+CCIYiAoIOOBQBAgEBAQEBAQFeJ4RiAgR5ED8SPBsZiFYBwwUBAQgohXKCUIdjhRMFjzOEY4VwkACJaYEmhGaQeB42RAYIgnocGYE9b4g1AQEB X-IronPort-AV: E=Sophos;i="5.31,493,1473112800"; d="scan'208";a="118727410" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Oct 2016 15:08:59 +0200 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bv2EM-0004Qu-2S; Fri, 14 Oct 2016 15:08:58 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bv2E1-0006kN-So; Fri, 14 Oct 2016 16:08:37 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 14 Oct 2016 16:08:18 +0300 Message-Id: <05a3af06a4ca797458bb3132e781482e338b9edf.1476450059.git.berto@igalia.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH v11 06/19] block: Check blockers in all nodes involved in a block-commit job X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 07ec733..f13fc69 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);