From patchwork Thu Aug 9 21:37:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 10562073 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 4903413B4 for ; Thu, 9 Aug 2018 22:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3524B2BB95 for ; Thu, 9 Aug 2018 22:15:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 291BA2BBA6; Thu, 9 Aug 2018 22:15:30 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 948C82BB95 for ; Thu, 9 Aug 2018 22:15:29 +0000 (UTC) Received: from localhost ([::1]:53167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fntDM-0008JG-R7 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Aug 2018 18:15:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnsdV-0004dG-E1 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 17:38:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnsdU-0004UL-3R for qemu-devel@nongnu.org; Thu, 09 Aug 2018 17:38:25 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47666 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 1fnsdR-0004Qe-1g; Thu, 09 Aug 2018 17:38:21 -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 90ABC81663CF; Thu, 9 Aug 2018 21:38:20 +0000 (UTC) Received: from localhost (ovpn-204-42.brq.redhat.com [10.40.204.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32E822166BA2; Thu, 9 Aug 2018 21:38:20 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 9 Aug 2018 23:37:58 +0200 Message-Id: <20180809213801.15098-9-mreitz@redhat.com> In-Reply-To: <20180809213801.15098-1-mreitz@redhat.com> References: <20180809213801.15098-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.8]); Thu, 09 Aug 2018 21:38:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 09 Aug 2018 21:38:20 +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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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