qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap()
[qemu/ar7.git] / tests / qemu-iotests / 087
blob678e748c58c737de8d035c8d2ed7d5bcc375e027
1 #!/usr/bin/env bash
3 # Test unsupported blockdev-add cases
5 # Copyright (C) 2014 Red Hat, Inc.
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=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 status=1 # failure is the default!
29 _cleanup()
31 _cleanup_test_img
33 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
39 _supported_fmt qcow2
40 _supported_proto file
41 _supported_os Linux
42 _require_working_luks
44 do_run_qemu()
46 echo Testing: "$@"
47 $QEMU -nographic -qmp stdio -serial none "$@"
48 echo
51 run_qemu()
53 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
54 | _filter_qemu | _filter_imgfmt \
55 | _filter_actual_image_size
58 size=128M
60 _make_test_img $size
62 echo
63 echo === Missing ID and node-name ===
64 echo
66 run_qemu <<EOF
67 { "execute": "qmp_capabilities" }
68 { "execute": "blockdev-add",
69 "arguments": {
70 "driver": "$IMGFMT",
71 "file": {
72 "driver": "file",
73 "filename": "$TEST_IMG"
77 { "execute": "quit" }
78 EOF
80 echo
81 echo === Duplicate ID ===
82 echo
84 run_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF
85 { "execute": "qmp_capabilities" }
86 { "execute": "blockdev-add",
87 "arguments": {
88 "driver": "$IMGFMT",
89 "node-name": "disk",
90 "file": {
91 "driver": "null-co"
95 { "execute": "blockdev-add",
96 "arguments": {
97 "driver": "$IMGFMT",
98 "node-name": "test-node",
99 "file": {
100 "driver": "null-co"
104 { "execute": "quit" }
107 echo
108 echo === aio=native without O_DIRECT ===
109 echo
111 # Skip this test if AIO is not enabled in this build
112 run_qemu_filter_aio()
114 run_qemu "$@" | \
115 sed -e 's/is not supported in this build/it requires cache.direct=on, which was not specified/'
118 run_qemu_filter_aio <<EOF
119 { "execute": "qmp_capabilities" }
120 { "execute": "blockdev-add",
121 "arguments": {
122 "driver": "$IMGFMT",
123 "node-name": "disk",
124 "file": {
125 "driver": "file",
126 "filename": "$TEST_IMG",
127 "aio": "native"
131 { "execute": "quit" }
134 echo
135 echo === Encrypted image QCow ===
136 echo
138 _make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size
139 run_qemu <<EOF
140 { "execute": "qmp_capabilities" }
141 { "execute": "object-add",
142 "arguments": {
143 "qom-type": "secret",
144 "id": "sec0",
145 "props": {
146 "data": "123456"
150 { "execute": "blockdev-add",
151 "arguments": {
152 "driver": "$IMGFMT",
153 "node-name": "disk",
154 "file": {
155 "driver": "file",
156 "filename": "$TEST_IMG"
158 "encrypt": {
159 "format": "aes",
160 "key-secret": "sec0"
164 { "execute": "quit" }
167 echo
168 echo === Encrypted image LUKS ===
169 echo
171 _make_test_img --object secret,id=sec0,data=123456 -o encrypt.format=luks,encrypt.key-secret=sec0 $size
172 run_qemu <<EOF
173 { "execute": "qmp_capabilities" }
174 { "execute": "object-add",
175 "arguments": {
176 "qom-type": "secret",
177 "id": "sec0",
178 "props": {
179 "data": "123456"
183 { "execute": "blockdev-add",
184 "arguments": {
185 "driver": "$IMGFMT",
186 "node-name": "disk",
187 "file": {
188 "driver": "file",
189 "filename": "$TEST_IMG"
191 "encrypt": {
192 "format": "luks",
193 "key-secret": "sec0"
197 { "execute": "quit" }
200 echo
201 echo === Missing driver ===
202 echo
204 _make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size
205 run_qemu -S <<EOF
206 { "execute": "qmp_capabilities" }
207 { "execute": "blockdev-add",
208 "arguments": {
209 "node-name": "disk"
212 { "execute": "quit" }
215 # success, all done
216 echo "*** done"
217 rm -f $seq.full
218 status=0