From patchwork Thu Aug 9 22:31:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 955887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41mjrt1c8Dz9s47 for ; Fri, 10 Aug 2018 08:40:46 +1000 (AEST) Received: from localhost ([::1]:53429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fntbn-0006y5-RN for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2018 18:40:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fntT4-00084s-Pd for qemu-devel@nongnu.org; Thu, 09 Aug 2018 18:31:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fntT2-0002jC-Dw for qemu-devel@nongnu.org; Thu, 09 Aug 2018 18:31:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58228 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fntSz-0002fn-9S; Thu, 09 Aug 2018 18:31:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAD838315E; Thu, 9 Aug 2018 22:31:36 +0000 (UTC) Received: from localhost (ovpn-204-42.brq.redhat.com [10.40.204.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DF91215670D; Thu, 9 Aug 2018 22:31:36 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 10 Aug 2018 00:31:14 +0200 Message-Id: <20180809223117.7846-9-mreitz@redhat.com> In-Reply-To: <20180809223117.7846-1-mreitz@redhat.com> References: <20180809223117.7846-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 09 Aug 2018 22:31:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 09 Aug 2018 22:31:36 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 08/11] iotests: Add filter commit test cases 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 , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch adds some tests on how commit copes with filter nodes. Signed-off-by: Max Reitz --- tests/qemu-iotests/040 | 130 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/040.out | 4 +- 2 files changed, 132 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 1beb5e6dab..f0544d6107 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -346,5 +346,135 @@ class TestReopenOverlay(ImageCommitTestCase): def test_reopen_overlay(self): self.run_commit_test(self.img1, self.img0) +class TestCommitWithFilters(iotests.QMPTestCase): + 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): + qemu_img('create', '-f', iotests.imgfmt, self.img0, '1M') + qemu_img('create', '-f', iotests.imgfmt, self.img1, '1M') + qemu_img('create', '-f', iotests.imgfmt, self.img2, '1M') + qemu_img('create', '-f', iotests.imgfmt, self.img3, '1M') + + self.vm = iotests.VM() + self.vm.launch() + result = self.vm.qmp('object-add', qom_type='throttle-group', id='tg') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-add', **{ + 'node-name': 'top-filter', + 'driver': 'throttle', + 'throttle-group': 'tg', + 'file': { + 'node-name': 'cow-3', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': self.img3 + }, + 'backing': { + 'node-name': 'cow-2', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': self.img2 + }, + 'backing': { + 'node-name': 'cow-1', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': self.img1 + }, + 'backing': { + 'node-name': 'bottom-filter', + 'driver': 'throttle', + 'throttle-group': 'tg', + 'file': { + 'node-name': 'cow-0', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': self.img0 + } + } + } + } + } + } + }) + self.assert_qmp(result, 'return', {}) + + def tearDown(self): + self.vm.shutdown() + os.remove(self.img3) + os.remove(self.img2) + os.remove(self.img1) + os.remove(self.img0) + + # Filters make for funny filenames, so we cannot just use + # self.imgX for the block-commit parameters + def get_filename(self, node): + return self.vm.node_info(node)['image']['filename'] + + def test_filterless_commit(self): + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', + job_id='commit', + device='top-filter', + top=self.get_filename('cow-2'), + base=self.get_filename('cow-1')) + self.assert_qmp(result, 'return', {}) + self.wait_until_completed(drive='commit') + + def test_commit_through_filter(self): + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', + job_id='commit', + device='top-filter', + top=self.get_filename('cow-1'), + base=self.get_filename('cow-0')) + # Cannot commit through explicitly added filters (yet, + # although in the future we probably want to make users use + # blockdev-copy for this) + self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_qmp(result, 'error/desc', 'Cannot commit through explicit filter nodes') + + def test_filtered_active_commit_with_filter(self): + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', + job_id='commit', + device='top-filter', + base=self.get_filename('cow-2')) + # Not specifying @top means active commit, so including the + # filter on top (which is not allowed right now) + self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_qmp(result, 'error/desc', 'Cannot commit through explicit filter nodes') + + def test_filtered_active_commit_without_filter(self): + cow3_name = self.get_filename('cow-3') + + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', + job_id='commit', + device='top-filter', + top=cow3_name, + base=self.get_filename('cow-2')) + # This is how you'd want to specify committing img3 into img2 + # disregarding the filter on top of img3 -- but that does not + # work, because you can only specify names of backing files + # (and img3 is not a backing file). The solution for this + # would be for block-commit to accept node names. + # Note that even if it did work, the above command would + # result in a non-active commit, because img3 is not the top + # node. Which is wrong, because img3 can still be written to, + # so it should be an active commit, but that is a different + # story. + self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_qmp(result, 'error/desc', + 'Top image file %s not found' % cow3_name) + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed']) diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index e20a75ce4f..49f84261d0 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -............................. +................................. ---------------------------------------------------------------------- -Ran 29 tests +Ran 33 tests OK