From: Max Reitz <mreitz@redhat.com> To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com> Subject: [Qemu-devel] [PATCH v4 08/11] iotests: Add filter commit test cases Date: Wed, 10 Apr 2019 22:20:30 +0200 [thread overview] Message-ID: <20190410202033.28617-9-mreitz@redhat.com> (raw) In-Reply-To: <20190410202033.28617-1-mreitz@redhat.com> This patch adds some tests on how commit copes with filter nodes. Signed-off-by: Max Reitz <mreitz@redhat.com> --- 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 b81133a474..dc3fe57fbd 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -394,5 +394,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 802ffaa0c0..220a5fa82c 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -........................................... +............................................... ---------------------------------------------------------------------- -Ran 43 tests +Ran 47 tests OK -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Max Reitz <mreitz@redhat.com> To: qemu-block@nongnu.org Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v4 08/11] iotests: Add filter commit test cases Date: Wed, 10 Apr 2019 22:20:30 +0200 [thread overview] Message-ID: <20190410202033.28617-9-mreitz@redhat.com> (raw) Message-ID: <20190410202030.lykM_jhTZaW4vTziq-Y_TECIT4B85bZ6Cf5roMnefKk@z> (raw) In-Reply-To: <20190410202033.28617-1-mreitz@redhat.com> This patch adds some tests on how commit copes with filter nodes. Signed-off-by: Max Reitz <mreitz@redhat.com> --- 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 b81133a474..dc3fe57fbd 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -394,5 +394,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 802ffaa0c0..220a5fa82c 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -........................................... +............................................... ---------------------------------------------------------------------- -Ran 43 tests +Ran 47 tests OK -- 2.20.1
next prev parent reply other threads:[~2019-04-10 20:21 UTC|newest] Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-10 20:20 [Qemu-devel] [PATCH v4 00/11] block: Deal with filters Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 01/11] block: Mark commit and mirror as filter drivers Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 02/11] block: Filtered children access functions Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-16 10:02 ` Vladimir Sementsov-Ogievskiy 2019-04-16 10:02 ` Vladimir Sementsov-Ogievskiy 2019-04-17 16:22 ` Max Reitz 2019-04-17 16:22 ` Max Reitz 2019-04-18 8:36 ` Vladimir Sementsov-Ogievskiy 2019-04-18 8:36 ` Vladimir Sementsov-Ogievskiy 2019-04-24 15:23 ` Max Reitz 2019-04-24 15:23 ` Max Reitz 2019-04-19 10:23 ` Vladimir Sementsov-Ogievskiy 2019-04-19 10:23 ` Vladimir Sementsov-Ogievskiy 2019-04-24 16:36 ` Max Reitz 2019-04-24 16:36 ` Max Reitz 2019-05-07 9:32 ` Vladimir Sementsov-Ogievskiy 2019-05-07 13:15 ` Max Reitz 2019-05-07 13:33 ` Vladimir Sementsov-Ogievskiy 2019-05-31 16:26 ` Max Reitz 2019-05-31 17:02 ` Max Reitz 2019-05-07 13:30 ` Vladimir Sementsov-Ogievskiy 2019-05-07 15:13 ` Max Reitz 2019-05-17 11:50 ` Vladimir Sementsov-Ogievskiy 2019-05-23 14:49 ` Max Reitz 2019-05-23 15:08 ` Vladimir Sementsov-Ogievskiy 2019-05-23 15:56 ` Max Reitz 2019-05-17 14:50 ` Vladimir Sementsov-Ogievskiy 2019-05-23 17:27 ` Max Reitz 2019-05-24 8:12 ` Vladimir Sementsov-Ogievskiy 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 03/11] block: Storage child access function Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-05-20 10:41 ` Vladimir Sementsov-Ogievskiy 2019-05-28 18:09 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 04/11] block: Inline bdrv_co_block_status_from_*() Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-05-21 8:57 ` Vladimir Sementsov-Ogievskiy 2019-05-28 17:58 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 05/11] block: Fix check_to_replace_node() Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 06/11] iotests: Add tests for mirror @replaces loops Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 07/11] block: Leave BDS.backing_file constant Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` Max Reitz [this message] 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 08/11] iotests: Add filter commit test cases Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 09/11] iotests: Add filter mirror " Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 10/11] iotests: Add test for commit in sub directory Max Reitz 2019-04-10 20:20 ` Max Reitz 2019-04-10 20:20 ` [Qemu-devel] [PATCH v4 11/11] iotests: Test committing to overridden backing Max Reitz 2019-04-10 20:20 ` Max Reitz
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190410202033.28617-9-mreitz@redhat.com \ --to=mreitz@redhat.com \ --cc=eblake@redhat.com \ --cc=kwolf@redhat.com \ --cc=qemu-block@nongnu.org \ --cc=qemu-devel@nongnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).