Philippe Mathieu-Daudé | 11a82d1 | 2019-03-07 15:58:38 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 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 | |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 27 | status=1 # failure is the default! |
| 28 | |
Max Reitz | b5d92ef | 2017-11-23 03:08:30 +0100 | [diff] [blame] | 29 | trap "exit \$status" 0 1 2 3 15 |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 30 | |
| 31 | # get standard environment, filters and checks |
| 32 | . ./common.rc |
| 33 | . ./common.filter |
| 34 | |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 35 | _supported_os Linux |
Thomas Huth | 21b43d0 | 2019-08-23 15:35:52 +0200 | [diff] [blame] | 36 | _require_drivers throttle |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 37 | |
Eric Blake | 8cedcff | 2018-11-16 15:50:02 -0600 | [diff] [blame] | 38 | do_run_qemu() |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 39 | { |
| 40 | echo Testing: "$@" | _filter_imgfmt |
| 41 | $QEMU -nographic -qmp-pretty stdio -serial none "$@" |
| 42 | echo |
| 43 | } |
| 44 | |
Eric Blake | 8cedcff | 2018-11-16 15:50:02 -0600 | [diff] [blame] | 45 | run_qemu() |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 46 | { |
| 47 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ |
Max Reitz | 07cd7b6 | 2020-06-22 13:58:45 +0200 | [diff] [blame] | 48 | | _filter_qemu_io | _filter_generated_node_ids |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 49 | } |
| 50 | |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 51 | test_throttle=$($QEMU_IMG --help|grep throttle) |
| 52 | [ "$test_throttle" = "" ] && _supported_fmt throttle |
| 53 | |
| 54 | echo |
| 55 | echo "== checking interface ==" |
| 56 | |
| 57 | run_qemu <<EOF |
| 58 | { "execute": "qmp_capabilities" } |
| 59 | { "execute": "blockdev-add", |
| 60 | "arguments": { |
Max Reitz | b5d92ef | 2017-11-23 03:08:30 +0100 | [diff] [blame] | 61 | "driver": "null-co", |
| 62 | "node-name": "disk0" |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | { "execute": "object-add", |
| 66 | "arguments": { |
| 67 | "qom-type": "throttle-group", |
| 68 | "id": "group0", |
| 69 | "props": { |
| 70 | "limits" : { |
| 71 | "iops-total": 1000 |
| 72 | } |
| 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 | "props" : { |
| 99 | "limits": { |
| 100 | "iops-total": 1000 |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | { "execute" : "qom-get", |
| 106 | "arguments" : { |
| 107 | "path" : "group0", |
| 108 | "property" : "limits" |
| 109 | } |
| 110 | } |
| 111 | { "execute" : "qom-set", |
| 112 | "arguments" : { |
| 113 | "path" : "group0", |
| 114 | "property" : "limits", |
| 115 | "value" : { |
| 116 | "iops-total" : 0 |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | { "execute" : "qom-get", |
| 121 | "arguments" : { |
| 122 | "path" : "group0", |
| 123 | "property" : "limits" |
| 124 | } |
| 125 | } |
| 126 | { "execute": "quit" } |
| 127 | EOF |
| 128 | |
| 129 | echo |
| 130 | echo "== object creation/set errors ==" |
| 131 | |
| 132 | run_qemu <<EOF |
| 133 | { "execute": "qmp_capabilities" } |
| 134 | { "execute": "object-add", |
| 135 | "arguments": { |
| 136 | "qom-type": "throttle-group", |
| 137 | "id": "group0", |
| 138 | "props" : { |
| 139 | "limits": { |
| 140 | "iops-total": 1000 |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | { "execute" : "qom-set", |
| 146 | "arguments" : { |
| 147 | "path" : "group0", |
| 148 | "property" : "x-iops-total", |
| 149 | "value" : 0 |
| 150 | } |
| 151 | } |
| 152 | { "execute" : "qom-set", |
| 153 | "arguments" : { |
| 154 | "path" : "group0", |
| 155 | "property" : "limits", |
| 156 | "value" : { |
| 157 | "iops-total" : 10, |
| 158 | "iops-read" : 10 |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | { "execute": "quit" } |
| 163 | EOF |
| 164 | |
| 165 | echo |
| 166 | echo "== don't specify group ==" |
| 167 | |
| 168 | run_qemu <<EOF |
| 169 | { "execute": "qmp_capabilities" } |
| 170 | { "execute": "blockdev-add", |
| 171 | "arguments": { |
Max Reitz | b5d92ef | 2017-11-23 03:08:30 +0100 | [diff] [blame] | 172 | "driver": "null-co", |
| 173 | "node-name": "disk0" |
Manos Pitsidianakis | 1e13e20 | 2017-08-25 16:20:28 +0300 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | { "execute": "blockdev-add", |
| 177 | "arguments": { |
| 178 | "driver": "throttle", |
| 179 | "node-name": "throttle0", |
| 180 | "file": "disk0" |
| 181 | } |
| 182 | } |
| 183 | { "execute": "quit" } |
| 184 | EOF |
| 185 | |
| 186 | echo |
| 187 | # success, all done |
| 188 | echo "*** done" |
| 189 | rm -f $seq.full |
| 190 | status=0 |