From: Manos Pitsidianakis <el13635@mail.ntua.gr>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: qemu-block <qemu-block@nongnu.org>,
Alberto Garcia <berto@igalia.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH v3 7/7] qemu-iotests: add 191 for legacy throttling interface
Date: Fri, 25 Aug 2017 16:23:32 +0300 [thread overview]
Message-ID: <20170825132332.6734-8-el13635@mail.ntua.gr> (raw)
In-Reply-To: <20170825132332.6734-1-el13635@mail.ntua.gr>
Check that the implicit throttle filter driver node, used for
compatibility with the legacy throttling interface on the BlockBackend
level, works.
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
---
tests/qemu-iotests/191 | 138 +++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/191.out | 5 ++
tests/qemu-iotests/group | 1 +
3 files changed, 144 insertions(+)
create mode 100644 tests/qemu-iotests/191
create mode 100644 tests/qemu-iotests/191.out
diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191
new file mode 100644
index 0000000000..82fd0b2fe5
--- /dev/null
+++ b/tests/qemu-iotests/191
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+#
+# Tests that the legacy throttling interface using an implicit throttle filter
+# driver node works
+#
+# Copyright (C) 2017 Manos Pitsidianakis
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import iotests
+
+class TestLegacyThrottling(iotests.QMPTestCase):
+ test_img = os.path.join(iotests.test_dir, "test.img")
+ target_img = os.path.join(iotests.test_dir, "target.img")
+ base_img = os.path.join(iotests.test_dir, "base.img")
+
+ def setUp(self):
+ iotests.qemu_img("create", "-f", iotests.imgfmt, self.base_img, "1G")
+ iotests.qemu_img("create", "-f", iotests.imgfmt, self.test_img, "-b", self.base_img)
+ iotests.qemu_io("-f", iotests.imgfmt, "-c", "write -P0x5d 1M 128M", self.test_img)
+ self.vm = iotests.VM().add_drive(self.test_img)
+ self.vm.launch()
+
+ def tearDown(self):
+ self.do_check_throttle_node(expect=True)
+ params = {"device": "drive0",
+ "bps": 0,
+ "bps_rd": 0,
+ "bps_wr": 0,
+ "iops": 0,
+ "iops_rd": 0,
+ "iops_wr": 0,
+ }
+ """
+ This must remove the implicit throttle_node
+ """
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False,
+ **params)
+ self.do_check_throttle_node(expect=False)
+ self.vm.shutdown()
+
+ def do_test_job(self, cmd, **args):
+ params = {"device": "drive0",
+ "bps": 1024,
+ "bps_rd": 0,
+ "bps_wr": 0,
+ "iops": 0,
+ "iops_rd": 0,
+ "iops_wr": 0,
+ }
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False,
+ **params)
+ self.assert_qmp(result, "return", {})
+ result = self.vm.qmp(cmd, **args)
+ self.assert_qmp(result, "return", {})
+ result = self.vm.qmp("query-block-jobs")
+ self.assert_qmp(result, "return[0]/device", "drive0")
+
+ def do_check_throttle_node(self, expect):
+ result = self.vm.qmp("query-named-block-nodes")
+ for r in result["return"]:
+ if r["drv"] == "throttle":
+ self.assertTrue(expect)
+ return
+ if expect:
+ """ throttle_node missing! """
+ self.assertTrue(False)
+
+ def do_check_params(self, file):
+ result = self.vm.qmp("query-block")
+ self.assert_qmp(result, "return[0]/inserted/bps", 1024)
+ self.assert_qmp(result, "return[0]/inserted/drv", iotests.imgfmt)
+ self.assert_qmp(result, "return[0]/inserted/file", file)
+
+ """
+ Check that query-block reports the correct throttling parameters while
+ ignoring the implicit throttle node.
+ """
+ def test_query_block(self):
+ params = {"device": "drive0",
+ "bps": 1024,
+ "bps_rd": 0,
+ "bps_wr": 0,
+ "iops": 0,
+ "iops_rd": 0,
+ "iops_wr": 0,
+ }
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False,
+ **params)
+ self.assert_qmp(result, "return", {})
+ self.do_check_params(file=self.test_img)
+
+ """
+ Check that the throttle node doesn't get removed by block jobs, and that
+ query-block reports the correct throttling parameters
+ """
+ def test_drive_mirror(self):
+ self.do_test_job("drive-mirror", device="drive0",
+ target=self.target_img,
+ sync="full")
+ self.vm.event_wait("BLOCK_JOB_READY")
+ self.vm.qmp("block-job-complete", device="drive0")
+ """
+ query-block should report `target_img` now
+ """
+ self.do_check_params(file=self.target_img)
+
+ def test_drive_backup(self):
+ self.do_test_job("drive-backup", device="drive0",
+ target=self.target_img,
+ sync="full")
+ self.vm.event_wait("BLOCK_JOB_COMPLETED")
+ self.do_check_params(file=self.test_img)
+
+ def test_block_commit(self):
+ self.do_test_job("block-commit", device="drive0")
+ self.vm.event_wait("BLOCK_JOB_READY")
+ self.vm.qmp("block-job-complete", device="drive0")
+ """
+ query-block should report the backing file `base_img` now
+ """
+ self.do_check_params(file=self.base_img)
+
+if __name__ == "__main__":
+ iotests.main(supported_fmts=["qcow2"])
diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out
new file mode 100644
index 0000000000..89968f35d7
--- /dev/null
+++ b/tests/qemu-iotests/191.out
@@ -0,0 +1,5 @@
+....
+----------------------------------------------------------------------
+Ran 4 tests
+
+OK
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index fee98440a5..ff732f0385 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -187,4 +187,5 @@
188 rw auto quick
189 rw auto
190 rw auto quick
+191 rw auto quick
192 rw auto quick
--
2.11.0
prev parent reply other threads:[~2017-08-25 13:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-25 13:23 [Qemu-devel] [PATCH v3 0/6] block: remove legacy I/O throttling Manos Pitsidianakis
2017-08-25 13:23 ` [Qemu-devel] [PATCH v3 1/7] block: skip implicit nodes in snapshots, blockjobs Manos Pitsidianakis
2017-08-28 11:40 ` Alberto Garcia
2017-09-07 10:04 ` Kevin Wolf
2017-08-25 13:23 ` [Qemu-devel] [PATCH v3 2/7] block: add options parameter to bdrv_new_open_driver() Manos Pitsidianakis
2017-09-07 12:12 ` Kevin Wolf
2017-08-25 13:23 ` [Qemu-devel] [PATCH v3 3/7] block: require job-id when device is a node name Manos Pitsidianakis
2017-08-28 11:52 ` Alberto Garcia
2017-09-07 12:24 ` Kevin Wolf
2017-08-25 13:23 ` [Qemu-devel] [PATCH v3 4/7] block: remove legacy I/O throttling Manos Pitsidianakis
2017-08-28 12:00 ` Alberto Garcia
2017-09-05 14:42 ` Stefan Hajnoczi
2017-09-07 13:26 ` Kevin Wolf
2017-09-08 15:44 ` Manos Pitsidianakis
2017-09-08 16:00 ` Kevin Wolf
2017-09-08 17:47 ` Manos Pitsidianakis
2017-08-25 13:23 ` [Qemu-devel] [PATCH v3 5/7] block/throttle-groups.c: remove throttle-groups list Manos Pitsidianakis
2017-08-28 13:51 ` Alberto Garcia
2017-08-25 13:23 ` [Qemu-devel] [PATCH v3 6/7] block: remove BlockBackendPublic Manos Pitsidianakis
2017-08-25 13:23 ` Manos Pitsidianakis [this message]
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=20170825132332.6734-8-el13635@mail.ntua.gr \
--to=el13635@mail.ntua.gr \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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: link
Be 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).