From patchwork Fri Apr 24 15:01:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 464228 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 B2ADC140150 for ; Sat, 25 Apr 2015 01:05:15 +1000 (AEST) Received: from localhost ([::1]:45224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlfAH-0001b0-Ry for incoming@patchwork.ozlabs.org; Fri, 24 Apr 2015 11:05:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylf7K-0004Al-O5 for qemu-devel@nongnu.org; Fri, 24 Apr 2015 11:02:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ylf7G-0006HA-An for qemu-devel@nongnu.org; Fri, 24 Apr 2015 11:02:10 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51756 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylf7G-0006FM-18; Fri, 24 Apr 2015 11:02:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AucFALVZOlVbdWOb/2dsb2JhbABbgwyBLrRoBAUBgQKYPQKBPUwBAQEBAQGBC4QhAQEEeRBRPBsZiC8BzBoBAQEHIoYWiiUHhC0FhkKFFpAzlVUjYIEFghI7MYJEAQEB X-IPAS-Result: AucFALVZOlVbdWOb/2dsb2JhbABbgwyBLrRoBAUBgQKYPQKBPUwBAQEBAQGBC4QhAQEEeRBRPBsZiC8BzBoBAQEHIoYWiiUHhC0FhkKFFpAzlVUjYIEFghI7MYJEAQEB X-IronPort-AV: E=Sophos;i="5.11,640,1422918000"; d="scan'208";a="345267716" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 24 Apr 2015 17:02:00 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Ylf7A-0004vi-I1; Fri, 24 Apr 2015 17:02:00 +0200 Received: from fanzine.local.igalia.com ([192.168.10.13] helo=perseus.local) by mail.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Ylf79-0007GP-9G; Fri, 24 Apr 2015 17:01:59 +0200 Received: from berto by perseus.local with local (Exim 4.84) (envelope-from ) id 1Ylf77-0005Vd-Vw; Fri, 24 Apr 2015 18:01:57 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 24 Apr 2015 18:01:54 +0300 Message-Id: <574376101d6c88225d4ea82089630ff4be36c8f3.1429885069.git.berto@igalia.com> X-Mailer: git-send-email 2.1.4 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, Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 10/11] qemu-iotests: test block-stream operations in parallel 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 This test case checks that it's possible to launch several stream operations in parallel in the same snapshot chain, each one involving a different set of nodes. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- tests/qemu-iotests/030 | 80 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/030.out | 4 +-- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 0927457..c199cef 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -145,6 +145,86 @@ class TestSingleDrive(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') +class TestParallelOps(iotests.QMPTestCase): + image_len = 2 * 1024 * 1024 # MB + num_ops = 4 # Number of parallel block-stream operations + num_imgs = num_ops * 2 + 1 + imgs = [] + + def setUp(self): + opts = [] + self.imgs = [] + + # Initialize file names and command-line options + for i in range(self.num_imgs): + img_depth = self.num_imgs - i - 1 + opts.append("backing." * img_depth + "node-name=node%d" % i) + self.imgs.append(os.path.join(iotests.test_dir, 'img-%d.img' % i)) + + # Create all images + iotests.create_image(self.imgs[0], self.image_len) + for i in range(1, self.num_imgs): + qemu_img('create', '-f', iotests.imgfmt, + '-o', 'backing_file=%s' % self.imgs[i-1], self.imgs[i]) + + # Put data into the images we are copying data from + for i in range(1, self.num_imgs, 2): + qemu_io('-f', iotests.imgfmt, + '-c', 'write -P %d %d 128K' % (i, i*128*1024), self.imgs[i]) + + # Attach the drive to the VM + self.vm = iotests.VM() + self.vm.add_drive("blkdebug::" + self.imgs[-1], ','.join(opts)) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + for img in self.imgs: + os.remove(img) + + # Test that it's possible to run several block-stream operations + # in parallel in the same snapshot chain + def test_stream_parallel(self): + self.assert_no_active_block_jobs() + + # Check that the maps don't match before the streaming operations + for i in range(2, self.num_imgs, 2): + self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i]), + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]), + 'image file map matches backing file before streaming') + + # Create all streaming jobs + pending_jobs = [] + for i in range(2, self.num_imgs, 2): + node_name = 'node%d' % i + pending_jobs.append(node_name) + result = self.vm.qmp('block-stream', device=node_name, base=self.imgs[i-2], speed=32768) + self.assert_qmp(result, 'return', {}) + + # The block job on the active image is always referenced by + # its device name. Therefore we have to replace the node name + # with the device name in the list of pending jobs + pending_jobs.pop() + pending_jobs.append("drive0") + + # Wait for all jobs to be finished. + while len(pending_jobs) > 0: + for event in self.vm.get_qmp_events(wait=True): + if event['event'] == 'BLOCK_JOB_COMPLETED': + node_name = self.dictpath(event, 'data/device') + self.assertTrue(node_name in pending_jobs) + self.assert_qmp_absent(event, 'data/error') + pending_jobs.remove(node_name) + + self.assert_no_active_block_jobs() + self.vm.shutdown() + + # Check that all maps match now + for i in range(2, self.num_imgs, 2): + self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i]), + qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]), + 'image file map does not match backing file after streaming') + class TestSmallerBackingFile(iotests.QMPTestCase): backing_len = 1 * 1024 * 1024 # MB image_len = 2 * backing_len diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out index 96961ed..b6f2576 100644 --- a/tests/qemu-iotests/030.out +++ b/tests/qemu-iotests/030.out @@ -1,5 +1,5 @@ -............... +................ ---------------------------------------------------------------------- -Ran 15 tests +Ran 16 tests OK