From patchwork Wed Oct 28 13:43:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 537343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0EB1413BC for ; Thu, 29 Oct 2015 00:46:16 +1100 (AEDT) Received: from localhost ([::1]:38069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrR3O-0002Na-Eo for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2015 09:46:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrR1Y-000881-Co for qemu-devel@nongnu.org; Wed, 28 Oct 2015 09:44:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrR1V-0005S2-0w for qemu-devel@nongnu.org; Wed, 28 Oct 2015 09:44:20 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:41303 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrR1U-0005Rt-Lj; Wed, 28 Oct 2015 09:44:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DjBQDHzzBW/5tjdVteGQEBAg4BAQGDCIFDqg4BAQEBAQEFAYENAY9ChCEBDYFahhsCgTo4FAEBAQEBAQGBCkETAYNhAQEEeRA/EjwbGYg0AcVNASyGMIpVBxeEFwWHRY54iAyFGIFZh2OFaoQ+iFAfAQFChAZwghGDbAEBAQ X-IPAS-Result: A2DjBQDHzzBW/5tjdVteGQEBAg4BAQGDCIFDqg4BAQEBAQEFAYENAY9ChCEBDYFahhsCgTo4FAEBAQEBAQGBCkETAYNhAQEEeRA/EjwbGYg0AcVNASyGMIpVBxeEFwWHRY54iAyFGIFZh2OFaoQ+iFAfAQFChAZwghGDbAEBAQ X-IronPort-AV: E=Sophos;i="5.20,210,1444687200"; d="scan'208";a="38773080" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Oct 2015 14:44:13 +0100 Received: from 85-76-137-228-nat.elisa-mobile.fi ([85.76.137.228] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZrR1R-00008A-5k; Wed, 28 Oct 2015 14:44:13 +0100 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZrR1C-0007PK-Tz; Wed, 28 Oct 2015 15:43:58 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 28 Oct 2015 15:43:50 +0200 Message-Id: <5cafa09cd82d2ea2c32d741f56b481ac1ae986ac.1446039123.git.berto@igalia.com> X-Mailer: git-send-email 2.6.1 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 Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, qemu-stable@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 2/2] qemu-iotests: Test the reopening of overlay_bs in 'block-commit' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The 'block-commit' command needs the overlay image of 'top' to be opened in read-write mode in order to update the backing file string. If 'top' is not the active layer or its backing file then its overlay needs to be reopened during the block job. This is a test case for that scenario. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- tests/qemu-iotests/040 | 30 ++++++++++++++++++++++++++++++ tests/qemu-iotests/040.out | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index ea2f98e..5bdaf3d 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -41,6 +41,7 @@ class ImageCommitTestCase(iotests.QMPTestCase): while not completed: for event in self.vm.get_qmp_events(wait=True): if event['event'] == 'BLOCK_JOB_COMPLETED': + self.assert_qmp_absent(event, 'data/error') self.assert_qmp(event, 'data/type', 'commit') self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/offset', event['data']['len']) @@ -251,5 +252,34 @@ class TestSetSpeed(ImageCommitTestCase): class TestActiveZeroLengthImage(TestSingleDrive): image_len = 0 +class TestReopenOverlay(ImageCommitTestCase): + image_len = 1024 * 1024 + img0 = os.path.join(iotests.test_dir, '0.img') + img1 = os.path.join(iotests.test_dir, '1.img') + img2 = os.path.join(iotests.test_dir, '2.img') + img3 = os.path.join(iotests.test_dir, '3.img') + + def setUp(self): + iotests.create_image(self.img0, self.image_len) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.img0, self.img1) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.img1, self.img2) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.img2, self.img3) + qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xab 0 128K', self.img1) + self.vm = iotests.VM().add_drive(self.img3) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(self.img0) + os.remove(self.img1) + os.remove(self.img2) + os.remove(self.img3) + + # This tests what happens when the overlay image of the 'top' node + # needs to be reopened in read-write mode in order to update the + # backing image string. + def test_reopen_overlay(self): + self.run_commit_test(self.img1, self.img0) + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed']) diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index 42314e9..4fd1c2d 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -........................ +......................... ---------------------------------------------------------------------- -Ran 24 tests +Ran 25 tests OK