master
text 186 lines 3.69 KB
Raw
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
23 owner="Manos Pitsidianakis"
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 status=1 # failure is the default!
29
30 trap "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
39 do_run_qemu()
40 {
41 echo Testing: "$@" | _filter_imgfmt
42 $QEMU -nographic -qmp-pretty stdio -serial none "$@"
43 echo
44 }
45
46 run_qemu()
47 {
48 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp \
49 | _filter_qemu_io | _filter_generated_node_ids \
50 | _filter_img_info
51 }
52
53 test_throttle=$($QEMU_IMG --help|grep throttle)
54 [ "$test_throttle" = "" ] && _notrun "qemu-img does not support throttle"
55
56 echo
57 echo "== checking interface =="
58
59 run_qemu <<EOF
60 { "execute": "qmp_capabilities" }
61 { "execute": "blockdev-add",
62 "arguments": {
63 "driver": "null-co",
64 "node-name": "disk0"
65 }
66 }
67 { "execute": "object-add",
68 "arguments": {
69 "qom-type": "throttle-group",
70 "id": "group0",
71 "limits" : {
72 "iops-total": 1000
73 }
74 }
75 }
76 { "execute": "blockdev-add",
77 "arguments": {
78 "driver": "throttle",
79 "node-name": "throttle0",
80 "throttle-group": "group0",
81 "file": "disk0"
82 }
83 }
84 { "execute": "query-named-block-nodes" }
85 { "execute": "query-block" }
86 { "execute": "quit" }
87 EOF
88
89 echo
90 echo "== property changes in ThrottleGroup =="
91
92 run_qemu <<EOF
93 { "execute": "qmp_capabilities" }
94 { "execute": "object-add",
95 "arguments": {
96 "qom-type": "throttle-group",
97 "id": "group0",
98 "limits": {
99 "iops-total": 1000
100 }
101 }
102 }
103 { "execute" : "qom-get",
104 "arguments" : {
105 "path" : "group0",
106 "property" : "limits"
107 }
108 }
109 { "execute" : "qom-set",
110 "arguments" : {
111 "path" : "group0",
112 "property" : "limits",
113 "value" : {
114 "iops-total" : 0
115 }
116 }
117 }
118 { "execute" : "qom-get",
119 "arguments" : {
120 "path" : "group0",
121 "property" : "limits"
122 }
123 }
124 { "execute": "quit" }
125 EOF
126
127 echo
128 echo "== object creation/set errors =="
129
130 run_qemu <<EOF
131 { "execute": "qmp_capabilities" }
132 { "execute": "object-add",
133 "arguments": {
134 "qom-type": "throttle-group",
135 "id": "group0",
136 "limits": {
137 "iops-total": 1000
138 }
139 }
140 }
141 { "execute" : "qom-set",
142 "arguments" : {
143 "path" : "group0",
144 "property" : "x-iops-total",
145 "value" : 0
146 }
147 }
148 { "execute" : "qom-set",
149 "arguments" : {
150 "path" : "group0",
151 "property" : "limits",
152 "value" : {
153 "iops-total" : 10,
154 "iops-read" : 10
155 }
156 }
157 }
158 { "execute": "quit" }
159 EOF
160
161 echo
162 echo "== don't specify group =="
163
164 run_qemu <<EOF
165 { "execute": "qmp_capabilities" }
166 { "execute": "blockdev-add",
167 "arguments": {
168 "driver": "null-co",
169 "node-name": "disk0"
170 }
171 }
172 { "execute": "blockdev-add",
173 "arguments": {
174 "driver": "throttle",
175 "node-name": "throttle0",
176 "file": "disk0"
177 }
178 }
179 { "execute": "quit" }
180 EOF
181
182 echo
183 # success, all done
184 echo "*** done"
185 rm -f $seq.full
186 status=0