From patchwork Wed Oct 26 10:29:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9396557 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 1DCF2600BA for ; Wed, 26 Oct 2016 10:44:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C1329841 for ; Wed, 26 Oct 2016 10:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDB6529945; Wed, 26 Oct 2016 10:44:43 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 4407229841 for ; Wed, 26 Oct 2016 10:44:43 +0000 (UTC) Received: from localhost ([::1]:33067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzLhK-0006W5-E0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Oct 2016 06:44:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzLTW-0003gP-4O for qemu-devel@nongnu.org; Wed, 26 Oct 2016 06:30:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzLTT-0001oo-Kr for qemu-devel@nongnu.org; Wed, 26 Oct 2016 06:30:26 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:61906 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzLTT-0001nL-E6; Wed, 26 Oct 2016 06:30:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BPAgB1hRBY/5tjdVtcHAEBBAEBCgEBgyoBAQEBAR2BSguNNZVXAQEBAQEBBQGBF5I0gg+CCYYiAoIAPxQBAgEBAQEBAQFiKIRjAgR5ED8SPBsZiFgBwEABAQgnhXKCUIdjhRMFjz6EZYVzkCCJcoEohGqRCx42UAYIgxkcGIE9b4hmAQEB X-IPAS-Result: A2BPAgB1hRBY/5tjdVtcHAEBBAEBCgEBgyoBAQEBAR2BSguNNZVXAQEBAQEBBQGBF5I0gg+CCYYiAoIAPxQBAgEBAQEBAQFiKIRjAgR5ED8SPBsZiFgBwEABAQgnhXKCUIdjhRMFjz6EZYVzkCCJcoEohGqRCx42UAYIgxkcGIE9b4hmAQEB X-IronPort-AV: E=Sophos;i="5.31,550,1473112800"; d="scan'208";a="202588321" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 26 Oct 2016 12:30:05 +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 1bzLT9-00026U-UC; Wed, 26 Oct 2016 12:30:04 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bzLSr-0001Zc-P0; Wed, 26 Oct 2016 13:29:45 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2016 13:29:20 +0300 Message-Id: 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 v12 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 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);