Merge remote-tracking branch 'remotes/nvme/tags/nvme-fixes-20210407-pull-request...
[qemu/ar7.git] / tests / qemu-iotests / 184
blobe4cbcd86345d1d4ebf4481ffb51a7f46ce3c5a8b
1 #!/usr/bin/env bash
2 # group: rw auto quick
4 # Test I/O throttle block filter driver interface
6 # Copyright (C) 2017 Manos Pitsidianakis
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.
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.
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/>.
22 # creator
23 owner="Manos Pitsidianakis"
25 seq=`basename $0`
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 trap "exit \$status" 0 1 2 3 15
32 # get standard environment, filters and checks
33 . ./common.rc
34 . ./common.filter
36 _supported_os Linux
37 _require_drivers throttle
39 do_run_qemu()
41 echo Testing: "$@" | _filter_imgfmt
42 $QEMU -nographic -qmp-pretty stdio -serial none "$@"
43 echo
46 run_qemu()
48 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\
49 | _filter_qemu_io | _filter_generated_node_ids
52 test_throttle=$($QEMU_IMG --help|grep throttle)
53 [ "$test_throttle" = "" ] && _supported_fmt throttle
55 echo
56 echo "== checking interface =="
58 run_qemu <<EOF
59 { "execute": "qmp_capabilities" }
60 { "execute": "blockdev-add",
61 "arguments": {
62 "driver": "null-co",
63 "node-name": "disk0"
66 { "execute": "object-add",
67 "arguments": {
68 "qom-type": "throttle-group",
69 "id": "group0",
70 "limits" : {
71 "iops-total": 1000
75 { "execute": "blockdev-add",
76 "arguments": {
77 "driver": "throttle",
78 "node-name": "throttle0",
79 "throttle-group": "group0",
80 "file": "disk0"
83 { "execute": "query-named-block-nodes" }
84 { "execute": "query-block" }
85 { "execute": "quit" }
86 EOF
88 echo
89 echo "== property changes in ThrottleGroup =="
91 run_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
102 { "execute" : "qom-get",
103 "arguments" : {
104 "path" : "group0",
105 "property" : "limits"
108 { "execute" : "qom-set",
109 "arguments" : {
110 "path" : "group0",
111 "property" : "limits",
112 "value" : {
113 "iops-total" : 0
117 { "execute" : "qom-get",
118 "arguments" : {
119 "path" : "group0",
120 "property" : "limits"
123 { "execute": "quit" }
126 echo
127 echo "== object creation/set errors =="
129 run_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
140 { "execute" : "qom-set",
141 "arguments" : {
142 "path" : "group0",
143 "property" : "x-iops-total",
144 "value" : 0
147 { "execute" : "qom-set",
148 "arguments" : {
149 "path" : "group0",
150 "property" : "limits",
151 "value" : {
152 "iops-total" : 10,
153 "iops-read" : 10
157 { "execute": "quit" }
160 echo
161 echo "== don't specify group =="
163 run_qemu <<EOF
164 { "execute": "qmp_capabilities" }
165 { "execute": "blockdev-add",
166 "arguments": {
167 "driver": "null-co",
168 "node-name": "disk0"
171 { "execute": "blockdev-add",
172 "arguments": {
173 "driver": "throttle",
174 "node-name": "throttle0",
175 "file": "disk0"
178 { "execute": "quit" }
181 echo
182 # success, all done
183 echo "*** done"
184 rm -f $seq.full
185 status=0