From patchwork Thu Mar 28 16:25:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10875283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86B2A186D for ; Thu, 28 Mar 2019 16:27:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E32128A6B for ; Thu, 28 Mar 2019 16:27:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EE7028BAF; Thu, 28 Mar 2019 16:27:22 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85CEE28A6B for ; Thu, 28 Mar 2019 16:27:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:39053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9Xs7-0002YH-9Y for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Mar 2019 12:27:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9Xqk-0001bX-DM for qemu-devel@nongnu.org; Thu, 28 Mar 2019 12:25:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9Xqi-0004NQ-Mc for qemu-devel@nongnu.org; Thu, 28 Mar 2019 12:25:54 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:33988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9Xqi-0004My-4C; Thu, 28 Mar 2019 12:25:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=m/aFFkGCA/OJoAk3GZeKk9aS56ZXz4NI1n41kqcJBKQ=; b=U1wbmwk4FZ0ccMPxKiuAh/lC3Ngyxt+gxv6d16qqMCQ5hhQPe8YVc9vTCThC+bM1Y8AT3xzARWki45Gg076yhCugXp4Cv7Bdi7eOIOvovxWcDQiJtFV2ZB8M/U1uKqbUl1rMm4uZR8+ZSwpx0zLNacjLGNo1oEBarP5YWw8+yaiMu0obtLC5OmAoDycsi0XNjuWPgEcG6Qprp5H2Jvw3iEtTZtYa0j4Upotg7JSQdWPY5D9NL+D30/fLqoPvFM18oLRC6KiPZ5xXm006UYmjkEELuhhp3MlXAeVRKje1lFEVyxHal8MGAGHHvoN655K3OfZ1ZwYGXEi4Ob1fdK8/vA==; Received: from 87-100-202-60.bb.dnainternet.fi ([87.100.202.60] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1h9Xqg-0007VO-PB; Thu, 28 Mar 2019 17:25:50 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1h9XqR-0003Y2-D7; Thu, 28 Mar 2019 18:25:35 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2019 18:25:11 +0200 Message-Id: <001949bcb5ba28d72ab14731dbcf8e6b239ebe78.1553789986.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH for-4.0 v2 3/3] block: test block-stream with a base node that is used by block-commit 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 , Vladimir Sementsov-Ogievskiy , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Andrey Shinkevich Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The base node of a block-stream operation indicates the first image from the backing chain starting from which no data is copied to the top node. The block-stream job allows others to use that base image, so a second block-stream job could be writing to it at the same time. An important restriction is that the base image must not disappear while the stream job is ongoing. stream_start() freezes the backing chain from top to base with that purpose but it does it too late in the code so there is a race condition there. This bug was fixed in the previous commit, and this patch contains an iotest for this scenario. Signed-off-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/030 | 17 +++++++++++++++++ tests/qemu-iotests/030.out | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 276e06b5ba..c6311d1825 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -314,6 +314,23 @@ class TestParallelOps(iotests.QMPTestCase): self.wait_until_completed(drive='commit-drive0') + # In this case the base node of the stream job is the same as the + # top node of commit job. Since block-commit removes the top node + # when it finishes, this is not allowed. + def test_overlapping_4(self): + self.assert_no_active_block_jobs() + + # Commit from node2 into node0 + result = self.vm.qmp('block-commit', device='drive0', top=self.imgs[2], base=self.imgs[0]) + self.assert_qmp(result, 'return', {}) + + # Stream from node2 into node4 + result = self.vm.qmp('block-stream', device='node4', base_node='node2', job_id='node4') + self.assert_qmp(result, 'error/class', 'GenericError') + + self.wait_until_completed() + self.assert_no_active_block_jobs() + # Test a block-stream and a block-commit job in parallel # Here the stream job is supposed to finish quickly in order to reproduce # the scenario that triggers the bug fixed in 3d5d319e1221 and 1a63a907507 diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out index 42314e9c00..4fd1c2dcd2 100644 --- a/tests/qemu-iotests/030.out +++ b/tests/qemu-iotests/030.out @@ -1,5 +1,5 @@ -........................ +......................... ---------------------------------------------------------------------- -Ran 24 tests +Ran 25 tests OK