tests: Factorize out migrate_test_start/end
[qemu/ar7.git] / tests / qemu-iotests / 184
blobee96c99af33bc689e6dcf1ffd4194e260a4176ed
1 #!/bin/bash
3 # Test I/O throttle block filter driver interface
5 # Copyright (C) 2017 Manos Pitsidianakis
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # creator
22 owner="Manos Pitsidianakis"
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 here=`pwd`
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
40 _supported_fmt qcow2
41 _supported_proto file
42 _supported_os Linux
44 function do_run_qemu()
46 echo Testing: "$@" | _filter_imgfmt
47 $QEMU -nographic -qmp-pretty stdio -serial none "$@"
48 echo
51 function run_qemu()
53 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\
54 | _filter_qemu_io | _filter_generated_node_ids \
55 | _filter_actual_image_size
58 _make_test_img 64M
59 test_throttle=$($QEMU_IMG --help|grep throttle)
60 [ "$test_throttle" = "" ] && _supported_fmt throttle
62 echo
63 echo "== checking interface =="
65 run_qemu <<EOF
66 { "execute": "qmp_capabilities" }
67 { "execute": "blockdev-add",
68 "arguments": {
69 "driver": "$IMGFMT",
70 "node-name": "disk0",
71 "file": {
72 "driver": "file",
73 "filename": "$TEST_IMG"
77 { "execute": "object-add",
78 "arguments": {
79 "qom-type": "throttle-group",
80 "id": "group0",
81 "props": {
82 "limits" : {
83 "iops-total": 1000
88 { "execute": "blockdev-add",
89 "arguments": {
90 "driver": "throttle",
91 "node-name": "throttle0",
92 "throttle-group": "group0",
93 "file": "disk0"
96 { "execute": "query-named-block-nodes" }
97 { "execute": "query-block" }
98 { "execute": "quit" }
99 EOF
101 echo
102 echo "== property changes in ThrottleGroup =="
104 run_qemu <<EOF
105 { "execute": "qmp_capabilities" }
106 { "execute": "object-add",
107 "arguments": {
108 "qom-type": "throttle-group",
109 "id": "group0",
110 "props" : {
111 "limits": {
112 "iops-total": 1000
117 { "execute" : "qom-get",
118 "arguments" : {
119 "path" : "group0",
120 "property" : "limits"
123 { "execute" : "qom-set",
124 "arguments" : {
125 "path" : "group0",
126 "property" : "limits",
127 "value" : {
128 "iops-total" : 0
132 { "execute" : "qom-get",
133 "arguments" : {
134 "path" : "group0",
135 "property" : "limits"
138 { "execute": "quit" }
141 echo
142 echo "== object creation/set errors =="
144 run_qemu <<EOF
145 { "execute": "qmp_capabilities" }
146 { "execute": "object-add",
147 "arguments": {
148 "qom-type": "throttle-group",
149 "id": "group0",
150 "props" : {
151 "limits": {
152 "iops-total": 1000
157 { "execute" : "qom-set",
158 "arguments" : {
159 "path" : "group0",
160 "property" : "x-iops-total",
161 "value" : 0
164 { "execute" : "qom-set",
165 "arguments" : {
166 "path" : "group0",
167 "property" : "limits",
168 "value" : {
169 "iops-total" : 10,
170 "iops-read" : 10
174 { "execute": "quit" }
177 echo
178 echo "== don't specify group =="
180 run_qemu <<EOF
181 { "execute": "qmp_capabilities" }
182 { "execute": "blockdev-add",
183 "arguments": {
184 "driver": "$IMGFMT",
185 "node-name": "disk0",
186 "file": {
187 "driver": "file",
188 "filename": "$TEST_IMG"
192 { "execute": "blockdev-add",
193 "arguments": {
194 "driver": "throttle",
195 "node-name": "throttle0",
196 "file": "disk0"
199 { "execute": "quit" }
202 echo
203 # success, all done
204 echo "*** done"
205 rm -f $seq.full
206 status=0