block: fix NetBSD qemu-iotests failure
[qemu/ar7.git] / tests / qemu-iotests / 247
blob546a794d3d47cba217c557a2f5b94f66c7d8ac63
1 #!/usr/bin/env bash
3 # Test for auto-read-only with commit block job
5 # Copyright (C) 2019 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
32 rm -f $TEST_IMG.[01234]
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
40 # Requires backing files and .bdrv_change_backing_file support
41 _supported_fmt qcow2 qed
42 _supported_proto file
44 size=128M
46 echo
47 echo "=== Try commit to backing file with auto-read-only ==="
48 echo
49 TEST_IMG="$TEST_IMG.0" _make_test_img $size
50 TEST_IMG="$TEST_IMG.1" _make_test_img $size
51 TEST_IMG="$TEST_IMG.2" _make_test_img $size
52 TEST_IMG="$TEST_IMG.3" _make_test_img $size
53 TEST_IMG="$TEST_IMG.4" _make_test_img $size
55 (cat <<EOF
56 {"execute":"qmp_capabilities"}
57 {"execute":"block-commit",
58 "arguments":{"device":"format-4", "top-node": "format-2", "base-node":"format-0", "job-id":"job0"}}
59 EOF
60 sleep 1
61 echo '{"execute":"quit"}'
62 ) | $QEMU -qmp stdio -nographic -nodefaults \
63 -blockdev file,node-name=file-0,filename=$TEST_IMG.0,auto-read-only=on \
64 -blockdev $IMGFMT,node-name=format-0,file=file-0,read-only=on \
65 -blockdev file,node-name=file-1,filename=$TEST_IMG.1,auto-read-only=on \
66 -blockdev $IMGFMT,node-name=format-1,file=file-1,read-only=on,backing=format-0 \
67 -blockdev file,node-name=file-2,filename=$TEST_IMG.2,auto-read-only=on \
68 -blockdev $IMGFMT,node-name=format-2,file=file-2,read-only=on,backing=format-1 \
69 -blockdev file,node-name=file-3,filename=$TEST_IMG.3,auto-read-only=on \
70 -blockdev $IMGFMT,node-name=format-3,file=file-3,read-only=on,backing=format-2 \
71 -blockdev file,node-name=file-4,filename=$TEST_IMG.4,auto-read-only=on \
72 -blockdev $IMGFMT,node-name=format-4,file=file-4,read-only=on,backing=format-3 |
73 _filter_qmp
75 # success, all done
76 echo "*** done"
77 rm -f $seq.full
78 status=0