1#!/usr/bin/env bash 2# group: rw auto quick 3# 4# Test I/O throttle block filter driver interface 5# 6# Copyright (C) 2017 Manos Pitsidianakis 7# 8# This program is free software; you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation; either version 2 of the License, or 11# (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see <http://www.gnu.org/licenses/>. 20# 21 22# creator 23owner="Manos Pitsidianakis" 24 25seq=`basename $0` 26echo "QA output created by $seq" 27 28status=1 # failure is the default! 29 30trap "exit \$status" 0 1 2 3 15 31 32# get standard environment, filters and checks 33. ./common.rc 34. ./common.filter 35 36_supported_os Linux 37_require_drivers throttle 38 39do_run_qemu() 40{ 41 echo Testing: "$@" | _filter_imgfmt 42 $QEMU -nographic -qmp-pretty stdio -serial none "$@" 43 echo 44} 45 46run_qemu() 47{ 48 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ 49 | _filter_qemu_io | _filter_generated_node_ids 50} 51 52test_throttle=$($QEMU_IMG --help|grep throttle) 53[ "$test_throttle" = "" ] && _supported_fmt throttle 54 55echo 56echo "== checking interface ==" 57 58run_qemu <<EOF 59{ "execute": "qmp_capabilities" } 60{ "execute": "blockdev-add", 61 "arguments": { 62 "driver": "null-co", 63 "node-name": "disk0" 64 } 65} 66{ "execute": "object-add", 67 "arguments": { 68 "qom-type": "throttle-group", 69 "id": "group0", 70 "limits" : { 71 "iops-total": 1000 72 } 73 } 74} 75{ "execute": "blockdev-add", 76 "arguments": { 77 "driver": "throttle", 78 "node-name": "throttle0", 79 "throttle-group": "group0", 80 "file": "disk0" 81 } 82} 83{ "execute": "query-named-block-nodes" } 84{ "execute": "query-block" } 85{ "execute": "quit" } 86EOF 87 88echo 89echo "== property changes in ThrottleGroup ==" 90 91run_qemu <<EOF 92{ "execute": "qmp_capabilities" } 93{ "execute": "object-add", 94 "arguments": { 95 "qom-type": "throttle-group", 96 "id": "group0", 97 "limits": { 98 "iops-total": 1000 99 } 100 } 101} 102{ "execute" : "qom-get", 103 "arguments" : { 104 "path" : "group0", 105 "property" : "limits" 106 } 107} 108{ "execute" : "qom-set", 109 "arguments" : { 110 "path" : "group0", 111 "property" : "limits", 112 "value" : { 113 "iops-total" : 0 114 } 115 } 116} 117{ "execute" : "qom-get", 118 "arguments" : { 119 "path" : "group0", 120 "property" : "limits" 121 } 122} 123{ "execute": "quit" } 124EOF 125 126echo 127echo "== object creation/set errors ==" 128 129run_qemu <<EOF 130{ "execute": "qmp_capabilities" } 131{ "execute": "object-add", 132 "arguments": { 133 "qom-type": "throttle-group", 134 "id": "group0", 135 "limits": { 136 "iops-total": 1000 137 } 138 } 139} 140{ "execute" : "qom-set", 141 "arguments" : { 142 "path" : "group0", 143 "property" : "x-iops-total", 144 "value" : 0 145 } 146} 147{ "execute" : "qom-set", 148 "arguments" : { 149 "path" : "group0", 150 "property" : "limits", 151 "value" : { 152 "iops-total" : 10, 153 "iops-read" : 10 154 } 155 } 156} 157{ "execute": "quit" } 158EOF 159 160echo 161echo "== don't specify group ==" 162 163run_qemu <<EOF 164{ "execute": "qmp_capabilities" } 165{ "execute": "blockdev-add", 166 "arguments": { 167 "driver": "null-co", 168 "node-name": "disk0" 169 } 170} 171{ "execute": "blockdev-add", 172 "arguments": { 173 "driver": "throttle", 174 "node-name": "throttle0", 175 "file": "disk0" 176 } 177} 178{ "execute": "quit" } 179EOF 180 181echo 182# success, all done 183echo "*** done" 184rm -f $seq.full 185status=0 186