qapi/error: Check format string argument in error_*prepend()
[qemu/armbru.git] / tests / qemu-iotests / 253
blobd88d5afa45b92c34e3b200f5d5f0ee17457fa1fa
1 #!/usr/bin/env bash
3 # Test qemu-img vs. unaligned images; O_DIRECT version
4 # (Originates from 221)
6 # Copyright (C) 2019 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 seq="$(basename $0)"
23 echo "QA output created by $seq"
25 status=1 # failure is the default!
27 _cleanup()
29 _cleanup_test_img
31 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
37 _supported_fmt raw
38 _supported_proto file
39 _supported_os Linux
41 _default_cache_mode none
42 _supported_cache_modes none directsync
44 echo
45 echo "=== Check mapping of unaligned raw image ==="
46 echo
48 # We do not know how large a physical sector is, but it is certainly
49 # going to be a factor of 1 MB
50 size=$((1 * 1024 * 1024 - 1))
52 # qemu-img create rounds size up to BDRV_SECTOR_SIZE
53 _make_test_img $size
54 $QEMU_IMG map --output=json --image-opts \
55 "driver=$IMGFMT,file.driver=file,file.filename=$TEST_IMG,cache.direct=on" \
56 | _filter_qemu_img_map
58 # so we resize it and check again
59 truncate --size=$size "$TEST_IMG"
60 $QEMU_IMG map --output=json --image-opts \
61 "driver=$IMGFMT,file.driver=file,file.filename=$TEST_IMG,cache.direct=on" \
62 | _filter_qemu_img_map
64 # qemu-io with O_DIRECT always writes whole physical sectors. Again,
65 # we do not know how large a physical sector is, so we just start
66 # writing from a 64 kB boundary, which should always be aligned.
67 offset=$((1 * 1024 * 1024 - 64 * 1024))
68 $QEMU_IO -c "w $offset $((size - offset))" "$TEST_IMG" | _filter_qemu_io
69 $QEMU_IMG map --output=json --image-opts \
70 "driver=$IMGFMT,file.driver=file,file.filename=$TEST_IMG,cache.direct=on" \
71 | _filter_qemu_img_map
73 # Resize it and check again -- contrary to 221, we may not get partial
74 # sectors here, so there should be only two areas (one zero, one
75 # data).
76 truncate --size=$size "$TEST_IMG"
77 $QEMU_IMG map --output=json --image-opts \
78 "driver=$IMGFMT,file.driver=file,file.filename=$TEST_IMG,cache.direct=on" \
79 | _filter_qemu_img_map
81 # success, all done
82 echo '*** done'
83 rm -f $seq.full
84 status=0