]>
Commit | Line | Data |
---|---|---|
1e13e201 MP |
1 | #!/bin/bash |
2 | # | |
3 | # Test I/O throttle block filter driver interface | |
4 | # | |
5 | # Copyright (C) 2017 Manos Pitsidianakis | |
6 | # | |
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. | |
11 | # | |
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. | |
16 | # | |
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/>. | |
19 | # | |
20 | ||
21 | # creator | |
22 | owner="Manos Pitsidianakis" | |
23 | ||
24 | seq=`basename $0` | |
25 | echo "QA output created by $seq" | |
26 | ||
27 | here=`pwd` | |
28 | status=1 # failure is the default! | |
29 | ||
b5d92efa | 30 | trap "exit \$status" 0 1 2 3 15 |
1e13e201 MP |
31 | |
32 | # get standard environment, filters and checks | |
33 | . ./common.rc | |
34 | . ./common.filter | |
35 | ||
1e13e201 MP |
36 | _supported_os Linux |
37 | ||
38 | function do_run_qemu() | |
39 | { | |
40 | echo Testing: "$@" | _filter_imgfmt | |
41 | $QEMU -nographic -qmp-pretty stdio -serial none "$@" | |
42 | echo | |
43 | } | |
44 | ||
45 | function run_qemu() | |
46 | { | |
47 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ | |
b66df843 HR |
48 | | _filter_qemu_io | _filter_generated_node_ids \ |
49 | | _filter_actual_image_size | |
1e13e201 MP |
50 | } |
51 | ||
1e13e201 MP |
52 | test_throttle=$($QEMU_IMG --help|grep throttle) |
53 | [ "$test_throttle" = "" ] && _supported_fmt throttle | |
54 | ||
55 | echo | |
56 | echo "== checking interface ==" | |
57 | ||
58 | run_qemu <<EOF | |
59 | { "execute": "qmp_capabilities" } | |
60 | { "execute": "blockdev-add", | |
61 | "arguments": { | |
b5d92efa HR |
62 | "driver": "null-co", |
63 | "node-name": "disk0" | |
1e13e201 MP |
64 | } |
65 | } | |
66 | { "execute": "object-add", | |
67 | "arguments": { | |
68 | "qom-type": "throttle-group", | |
69 | "id": "group0", | |
70 | "props": { | |
71 | "limits" : { | |
72 | "iops-total": 1000 | |
73 | } | |
74 | } | |
75 | } | |
76 | } | |
77 | { "execute": "blockdev-add", | |
78 | "arguments": { | |
79 | "driver": "throttle", | |
80 | "node-name": "throttle0", | |
81 | "throttle-group": "group0", | |
82 | "file": "disk0" | |
83 | } | |
84 | } | |
85 | { "execute": "query-named-block-nodes" } | |
86 | { "execute": "query-block" } | |
87 | { "execute": "quit" } | |
88 | EOF | |
89 | ||
90 | echo | |
91 | echo "== property changes in ThrottleGroup ==" | |
92 | ||
93 | run_qemu <<EOF | |
94 | { "execute": "qmp_capabilities" } | |
95 | { "execute": "object-add", | |
96 | "arguments": { | |
97 | "qom-type": "throttle-group", | |
98 | "id": "group0", | |
99 | "props" : { | |
100 | "limits": { | |
101 | "iops-total": 1000 | |
102 | } | |
103 | } | |
104 | } | |
105 | } | |
106 | { "execute" : "qom-get", | |
107 | "arguments" : { | |
108 | "path" : "group0", | |
109 | "property" : "limits" | |
110 | } | |
111 | } | |
112 | { "execute" : "qom-set", | |
113 | "arguments" : { | |
114 | "path" : "group0", | |
115 | "property" : "limits", | |
116 | "value" : { | |
117 | "iops-total" : 0 | |
118 | } | |
119 | } | |
120 | } | |
121 | { "execute" : "qom-get", | |
122 | "arguments" : { | |
123 | "path" : "group0", | |
124 | "property" : "limits" | |
125 | } | |
126 | } | |
127 | { "execute": "quit" } | |
128 | EOF | |
129 | ||
130 | echo | |
131 | echo "== object creation/set errors ==" | |
132 | ||
133 | run_qemu <<EOF | |
134 | { "execute": "qmp_capabilities" } | |
135 | { "execute": "object-add", | |
136 | "arguments": { | |
137 | "qom-type": "throttle-group", | |
138 | "id": "group0", | |
139 | "props" : { | |
140 | "limits": { | |
141 | "iops-total": 1000 | |
142 | } | |
143 | } | |
144 | } | |
145 | } | |
146 | { "execute" : "qom-set", | |
147 | "arguments" : { | |
148 | "path" : "group0", | |
149 | "property" : "x-iops-total", | |
150 | "value" : 0 | |
151 | } | |
152 | } | |
153 | { "execute" : "qom-set", | |
154 | "arguments" : { | |
155 | "path" : "group0", | |
156 | "property" : "limits", | |
157 | "value" : { | |
158 | "iops-total" : 10, | |
159 | "iops-read" : 10 | |
160 | } | |
161 | } | |
162 | } | |
163 | { "execute": "quit" } | |
164 | EOF | |
165 | ||
166 | echo | |
167 | echo "== don't specify group ==" | |
168 | ||
169 | run_qemu <<EOF | |
170 | { "execute": "qmp_capabilities" } | |
171 | { "execute": "blockdev-add", | |
172 | "arguments": { | |
b5d92efa HR |
173 | "driver": "null-co", |
174 | "node-name": "disk0" | |
1e13e201 MP |
175 | } |
176 | } | |
177 | { "execute": "blockdev-add", | |
178 | "arguments": { | |
179 | "driver": "throttle", | |
180 | "node-name": "throttle0", | |
181 | "file": "disk0" | |
182 | } | |
183 | } | |
184 | { "execute": "quit" } | |
185 | EOF | |
186 | ||
187 | echo | |
188 | # success, all done | |
189 | echo "*** done" | |
190 | rm -f $seq.full | |
191 | status=0 |