From patchwork Tue Oct 27 16:43:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 536739 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 D5460140D8E for ; Wed, 28 Oct 2015 03:45:08 +1100 (AEDT) Received: from localhost ([::1]:60972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr7Mw-0006Pm-Jr for incoming@patchwork.ozlabs.org; Tue, 27 Oct 2015 12:45:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr7MX-0005oV-03 for qemu-devel@nongnu.org; Tue, 27 Oct 2015 12:44:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zr7MU-0004RU-E9 for qemu-devel@nongnu.org; Tue, 27 Oct 2015 12:44:40 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:53819 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr7MU-0004Jc-79; Tue, 27 Oct 2015 12:44:38 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DgDADAqC9W/5tjdVteGQEBAg4BAQGDCIFDqg0BAQEBAQEFAYENAY8/hC+BWoYaAoE+ORMBAQEBAQEBgQqEMwEBBHkQPxI8GxmINAHGBQEshjCKUgcXhBcFh0OOdYgMhRiBWYdjhWqEPIhQIwM9hAZwhW4BAQE X-IPAS-Result: A2DgDADAqC9W/5tjdVteGQEBAg4BAQGDCIFDqg0BAQEBAQEFAYENAY8/hC+BWoYaAoE+ORMBAQEBAQEBgQqEMwEBBHkQPxI8GxmINAHGBQEshjCKUgcXhBcFh0OOdYgMhRiBWYdjhWqEPIhQIwM9hAZwhW4BAQE X-IronPort-AV: E=Sophos;i="5.20,205,1444687200"; d="scan'208";a="38859933" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 27 Oct 2015 17:43:57 +0100 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Zr7Lp-00049Y-Dc; Tue, 27 Oct 2015 17:43:57 +0100 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1Zr7Lc-0005MT-AX; Tue, 27 Oct 2015 18:43:44 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 27 Oct 2015 18:43:42 +0200 Message-Id: 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 , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: [Qemu-devel] [PATCH 1/1] 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 --- 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