hw/misc/mps2-scc: Support configurable number of OSCCLK values
[qemu/ar7.git] / tests / qemu-iotests / 309
blobb90b279994c91c3c6a4800e5e06efa33832643dd
1 #!/usr/bin/env bash
2 # group: rw auto quick
4 # Test qemu-nbd -A
6 # Copyright (C) 2018-2020 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
30 nbd_server_stop
32 trap "_cleanup; exit \$status" 0 1 2 3 15
34 # get standard environment, filters and checks
35 . ./common.rc
36 . ./common.filter
37 . ./common.nbd
39 _supported_fmt qcow2
40 _supported_proto file
41 _supported_os Linux
42 _require_command QEMU_NBD
44 echo
45 echo "=== Initial image setup ==="
46 echo
48 TEST_IMG="$TEST_IMG.base" _make_test_img 4M
49 $QEMU_IO -c 'w 0 2M' -f $IMGFMT "$TEST_IMG.base" | _filter_qemu_io
50 _make_test_img -b "$TEST_IMG.base" -F $IMGFMT 4M
51 $QEMU_IO -c 'w 1M 2M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
53 echo
54 echo "=== Check allocation over NBD ==="
55 echo
57 $QEMU_IMG map --output=json -f qcow2 "$TEST_IMG"
58 IMG="driver=nbd,server.type=unix,server.path=$nbd_unix_socket"
59 nbd_server_start_unix_socket -r -f qcow2 -A "$TEST_IMG"
60 # Normal -f raw NBD block status loses access to allocation information
61 $QEMU_IMG map --output=json --image-opts \
62 "$IMG" | _filter_qemu_img_map
63 # But when we use -A, coupled with x-dirty-bitmap in the client for feeding
64 # 2-bit block status from an alternative NBD metadata context (note that
65 # the client code for x-dirty-bitmap intentionally collapses all depths
66 # beyond 2 into a single value), we can determine:
67 # unallocated (depth 0) => "zero":false, "data":true
68 # local (depth 1) => "zero":false, "data":false
69 # backing (depth 2+) => "zero":true, "data":true
70 $QEMU_IMG map --output=json --image-opts \
71 "$IMG,x-dirty-bitmap=qemu:allocation-depth" | _filter_qemu_img_map
72 # More accurate results can be obtained by other NBD clients such as
73 # libnbd, but this test works without such external dependencies.
75 # success, all done
76 echo '*** done'
77 rm -f $seq.full
78 status=0