block/export: use VIRTIO_BLK_SECTOR_BITS
[qemu/kevin.git] / tests / qemu-iotests / 172
blob0ac942a6c5fb4cddf20a6618ad1c79d20eed3788
1 #!/usr/bin/env bash
2 # group: auto
4 # Test floppy configuration
6 # Copyright (C) 2016 Red Hat, Inc.
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.
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.
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/>.
22 # creator
23 owner=kwolf@redhat.com
25 seq=`basename $0`
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
33 _rm_test_img "$TEST_IMG.2"
34 _rm_test_img "$TEST_IMG.3"
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
42 _supported_fmt qcow2
43 _supported_proto file
44 _supported_os Linux
46 if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
47 _notrun "Requires a PC machine"
50 do_run_qemu()
53 if ! test -t 0; then
54 while read cmd; do
55 echo $cmd
56 done
58 echo quit
59 ) | $QEMU -accel qtest -nographic -monitor stdio -serial none "$@"
60 echo
63 check_floppy_qtree()
65 echo
66 echo Testing: "$@" | _filter_testdir
68 # QEMU_OPTIONS contains -nodefaults, we don't want that here because the
69 # defaults are part of what should be checked here.
71 # Apply the sed filter to stdout only, but keep the stderr output and
72 # filter the qemu program name in it.
73 printf "info qtree\ninfo block\n" |
74 (QEMU_OPTIONS="" do_run_qemu "$@" |
75 _filter_testdir |_filter_generated_node_ids | _filter_hmp |
76 sed -ne '/^ dev: isa-fdc/,/^ dev:/{x;p};/^[a-z][^ ]* (NODE_NAME):* /,/^(qemu)$/{p}') 2>&1 |
77 _filter_win32 | _filter_qemu | _filter_qom_path
80 check_cache_mode()
82 echo "info block none0" |
83 QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |
84 _filter_win32 | _filter_qemu | grep "Cache mode"
88 size=720k
90 _make_test_img $size
92 TEST_IMG="$TEST_IMG.2" _make_test_img $size
93 TEST_IMG="$TEST_IMG.3" _make_test_img $size
95 # Default drive semantics:
97 # By default you get a single empty floppy drive. You can override it with
98 # -drive and using the same index, but if you use -drive to add a floppy to a
99 # different index, you get both of them. However, as soon as you use any
100 # '-device floppy', even to a different slot, the default drive is disabled.
102 echo
103 echo
104 echo === Default ===
106 check_floppy_qtree
108 echo
109 echo
110 echo === Using -fda/-fdb options ===
112 check_floppy_qtree -fda "$TEST_IMG"
113 check_floppy_qtree -fdb "$TEST_IMG"
114 check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2"
115 check_floppy_qtree -fdb ""
118 echo
119 echo
120 echo === Using -drive options ===
122 check_floppy_qtree -drive if=floppy,file="$TEST_IMG"
123 check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
124 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG.2",index=1
126 echo
127 echo
128 echo === Using -drive if=none and -global ===
130 check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
131 check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
132 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
133 -global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
135 echo
136 echo
137 echo === Using -drive if=none and -device ===
139 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
140 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
141 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
142 -device floppy,drive=none0 -device floppy,drive=none1,unit=1
144 echo
145 echo
146 echo === Mixing -fdX and -global ===
148 # Working
149 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
150 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
152 # Conflicting
153 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
154 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
155 # Conflicting, -fdX wins
156 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global floppy.drive=none0
158 echo
159 echo
160 echo === Mixing -fdX and -device ===
162 # Working
163 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
164 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
166 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
167 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
169 # Conflicting
170 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
171 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
173 echo
174 echo
175 echo === Mixing -drive and -device ===
177 # Working
178 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
179 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
181 # Conflicting
182 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
184 echo
185 echo
186 echo === Mixing -global and -device ===
188 # Working
189 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
190 -global isa-fdc.driveA=none0 -device floppy,drive=none1
191 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
192 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
194 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
195 -global isa-fdc.driveB=none0 -device floppy,drive=none1
196 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
197 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
198 check_floppy_qtree -drive if=none,file="$TEST_IMG" \
199 -global floppy.drive=none0 -device floppy,unit=0
201 # Conflicting
202 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
203 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
204 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
205 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
206 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
207 -global floppy.drive=none0 -device floppy,drive=none1,unit=0
209 echo
210 echo
211 echo === Attempt to use drive twice ===
213 # if=none
214 check_floppy_qtree -drive if=none -device floppy,drive=none0 -device floppy -device floppy,drive=none0
215 check_floppy_qtree -drive if=none -global floppy.drive=none0 -device floppy -device floppy
216 # if=floppy
217 check_floppy_qtree -fda "" -device floppy,drive=floppy0
218 check_floppy_qtree -fda "" -global floppy.drive=floppy0
219 # default if=floppy (not found, because it's created later)
220 check_floppy_qtree -device floppy,drive=floppy0
222 echo
223 echo
224 echo === Too many floppy drives ===
226 # Working
227 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
228 -drive if=none,file="$TEST_IMG.2" \
229 -drive if=none,file="$TEST_IMG.3" \
230 -global isa-fdc.driveB=none0 \
231 -device floppy,drive=none1
233 echo
234 echo
235 echo === Creating an empty drive with anonymous BB ===
237 check_floppy_qtree -device floppy
238 check_floppy_qtree -device floppy,drive-type=120
239 check_floppy_qtree -device floppy,drive-type=144
240 check_floppy_qtree -device floppy,drive-type=288
242 echo
243 echo
244 echo === Try passing different drive size with image ===
246 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
247 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
249 echo
250 echo
251 echo === Try passing different block sizes ===
253 # Explicitly setting the default is okay
254 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
255 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
257 # Changing it is not
258 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
259 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
261 echo
262 echo
263 echo === Writethrough caching ===
265 check_cache_mode -device floppy,drive=none0
266 check_cache_mode -device floppy,drive=none0,write-cache=on
267 check_cache_mode -device floppy,drive=none0,write-cache=off
269 # success, all done
270 echo "*** done"
271 rm -f $seq.full
272 status=0