From patchwork Fri Aug 25 13:23:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Pitsidianakis X-Patchwork-Id: 9922015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41350600C5 for ; Fri, 25 Aug 2017 13:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 349B228138 for ; Fri, 25 Aug 2017 13:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2901D2818A; Fri, 25 Aug 2017 13:29:00 +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=-6.9 required=2.0 tests=BAYES_00,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 625DD28138 for ; Fri, 25 Aug 2017 13:28:58 +0000 (UTC) Received: from localhost ([::1]:53320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlEfR-0001Ms-Vf for patchwork-qemu-devel@patchwork.kernel.org; Fri, 25 Aug 2017 09:28:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlEbT-0006z5-I8 for qemu-devel@nongnu.org; Fri, 25 Aug 2017 09:24:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlEbR-0003S8-P9 for qemu-devel@nongnu.org; Fri, 25 Aug 2017 09:24:51 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:40254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlEbO-0003PJ-4I; Fri, 25 Aug 2017 09:24:46 -0400 Received: from mail.ntua.gr (carp0.noc.ntua.gr [147.102.222.60]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v7PDOECj025252 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Aug 2017 16:24:14 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host carp0.noc.ntua.gr [147.102.222.60] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Fri, 25 Aug 2017 16:23:32 +0300 Message-Id: <20170825132332.6734-8-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825132332.6734-1-el13635@mail.ntua.gr> References: <20170825132332.6734-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH v3 7/7] qemu-iotests: add 191 for legacy throttling interface 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 , Alberto Garcia , Stefan Hajnoczi , qemu-block Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Manos Pitsidianakis --- 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 . +# + +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