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