Kevin Wolf | c75203c | 2014-03-06 15:52:14 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Test unsupported blockdev-add cases |
| 4 | # |
| 5 | # Copyright (C) 2014 Red Hat, Inc. |
| 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=kwolf@redhat.com |
| 23 | |
| 24 | seq=`basename $0` |
| 25 | echo "QA output created by $seq" |
| 26 | |
| 27 | here=`pwd` |
| 28 | tmp=/tmp/$$ |
| 29 | status=1 # failure is the default! |
| 30 | |
| 31 | # get standard environment, filters and checks |
| 32 | . ./common.rc |
| 33 | . ./common.filter |
| 34 | |
| 35 | _supported_fmt qcow2 |
| 36 | _supported_proto file |
| 37 | _supported_os Linux |
| 38 | |
| 39 | function do_run_qemu() |
| 40 | { |
| 41 | echo Testing: "$@" |
| 42 | $QEMU -nographic -qmp stdio -serial none "$@" |
| 43 | echo |
| 44 | } |
| 45 | |
| 46 | function run_qemu() |
| 47 | { |
Max Reitz | 4dd7b8d | 2014-12-19 17:17:06 +0100 | [diff] [blame] | 48 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \ |
| 49 | | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' |
Kevin Wolf | c75203c | 2014-03-06 15:52:14 +0100 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | size=128M |
| 53 | |
| 54 | _make_test_img $size |
| 55 | |
| 56 | echo |
| 57 | echo === Missing ID === |
| 58 | echo |
| 59 | |
| 60 | run_qemu <<EOF |
| 61 | { "execute": "qmp_capabilities" } |
| 62 | { "execute": "blockdev-add", |
| 63 | "arguments": { |
| 64 | "options": { |
| 65 | "driver": "$IMGFMT", |
| 66 | "file": { |
| 67 | "driver": "file", |
| 68 | "filename": "$TEST_IMG" |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | { "execute": "quit" } |
| 74 | EOF |
| 75 | |
| 76 | echo |
Kevin Wolf | f2d953e | 2014-04-17 13:27:05 +0200 | [diff] [blame] | 77 | echo === Duplicate ID === |
| 78 | echo |
| 79 | |
| 80 | run_qemu <<EOF |
| 81 | { "execute": "qmp_capabilities" } |
| 82 | { "execute": "blockdev-add", |
| 83 | "arguments": { |
| 84 | "options": { |
| 85 | "driver": "$IMGFMT", |
| 86 | "id": "disk", |
Kevin Wolf | 90d9d30 | 2014-04-17 13:40:30 +0200 | [diff] [blame] | 87 | "node-name": "test-node", |
Kevin Wolf | f2d953e | 2014-04-17 13:27:05 +0200 | [diff] [blame] | 88 | "file": { |
| 89 | "driver": "file", |
| 90 | "filename": "$TEST_IMG" |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | { "execute": "blockdev-add", |
| 96 | "arguments": { |
| 97 | "options": { |
| 98 | "driver": "$IMGFMT", |
| 99 | "id": "disk", |
| 100 | "file": { |
| 101 | "driver": "file", |
| 102 | "filename": "$TEST_IMG" |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | } |
Kevin Wolf | 90d9d30 | 2014-04-17 13:40:30 +0200 | [diff] [blame] | 107 | { "execute": "blockdev-add", |
| 108 | "arguments": { |
| 109 | "options": { |
| 110 | "driver": "$IMGFMT", |
| 111 | "id": "test-node", |
| 112 | "file": { |
| 113 | "driver": "file", |
| 114 | "filename": "$TEST_IMG" |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | { "execute": "blockdev-add", |
| 120 | "arguments": { |
| 121 | "options": { |
| 122 | "driver": "$IMGFMT", |
| 123 | "id": "disk2", |
| 124 | "node-name": "disk", |
| 125 | "file": { |
| 126 | "driver": "file", |
| 127 | "filename": "$TEST_IMG" |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | { "execute": "blockdev-add", |
| 133 | "arguments": { |
| 134 | "options": { |
| 135 | "driver": "$IMGFMT", |
| 136 | "id": "disk2", |
| 137 | "node-name": "test-node", |
| 138 | "file": { |
| 139 | "driver": "file", |
| 140 | "filename": "$TEST_IMG" |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | { "execute": "blockdev-add", |
| 146 | "arguments": { |
| 147 | "options": { |
| 148 | "driver": "$IMGFMT", |
| 149 | "id": "disk3", |
| 150 | "node-name": "disk3", |
| 151 | "file": { |
| 152 | "driver": "file", |
| 153 | "filename": "$TEST_IMG" |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
Kevin Wolf | f2d953e | 2014-04-17 13:27:05 +0200 | [diff] [blame] | 158 | { "execute": "quit" } |
| 159 | EOF |
| 160 | |
| 161 | echo |
Kevin Wolf | c75203c | 2014-03-06 15:52:14 +0100 | [diff] [blame] | 162 | echo === aio=native without O_DIRECT === |
| 163 | echo |
| 164 | |
| 165 | run_qemu <<EOF |
| 166 | { "execute": "qmp_capabilities" } |
| 167 | { "execute": "blockdev-add", |
| 168 | "arguments": { |
| 169 | "options": { |
| 170 | "driver": "$IMGFMT", |
| 171 | "id": "disk", |
| 172 | "aio": "native", |
| 173 | "file": { |
| 174 | "driver": "file", |
| 175 | "filename": "$TEST_IMG" |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | { "execute": "quit" } |
| 181 | EOF |
| 182 | |
| 183 | echo |
| 184 | echo === Encrypted image === |
| 185 | echo |
| 186 | |
| 187 | _make_test_img -o encryption=on $size |
Markus Armbruster | c3adb58 | 2014-03-14 09:22:48 +0100 | [diff] [blame] | 188 | run_qemu -S <<EOF |
| 189 | { "execute": "qmp_capabilities" } |
| 190 | { "execute": "blockdev-add", |
| 191 | "arguments": { |
| 192 | "options": { |
| 193 | "driver": "$IMGFMT", |
| 194 | "id": "disk", |
| 195 | "file": { |
| 196 | "driver": "file", |
| 197 | "filename": "$TEST_IMG" |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | { "execute": "quit" } |
| 203 | EOF |
| 204 | |
Kevin Wolf | c75203c | 2014-03-06 15:52:14 +0100 | [diff] [blame] | 205 | run_qemu <<EOF |
| 206 | { "execute": "qmp_capabilities" } |
| 207 | { "execute": "blockdev-add", |
| 208 | "arguments": { |
| 209 | "options": { |
| 210 | "driver": "$IMGFMT", |
| 211 | "id": "disk", |
| 212 | "file": { |
| 213 | "driver": "file", |
| 214 | "filename": "$TEST_IMG" |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | { "execute": "quit" } |
| 220 | EOF |
| 221 | |
Fam Zheng | fe509ee | 2014-09-18 15:36:43 -0500 | [diff] [blame] | 222 | echo |
| 223 | echo === Missing driver === |
| 224 | echo |
| 225 | |
| 226 | _make_test_img -o encryption=on $size |
| 227 | run_qemu -S <<EOF |
| 228 | { "execute": "qmp_capabilities" } |
| 229 | { "execute": "blockdev-add", |
| 230 | "arguments": { |
| 231 | "options": { |
| 232 | "id": "disk" |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | { "execute": "quit" } |
| 237 | EOF |
| 238 | |
Kevin Wolf | c75203c | 2014-03-06 15:52:14 +0100 | [diff] [blame] | 239 | # success, all done |
| 240 | echo "*** done" |
| 241 | rm -f $seq.full |
| 242 | status=0 |