es1370: check total frame count against current frame
[qemu/ar7.git] / tests / qemu-iotests / 267
blob3146273eef3335a15cdc8f576148349c9b2fbbd9
1 #!/usr/bin/env bash
3 # Test which nodes are involved in internal snapshots
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 "$SOCK_DIR/nbd"
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
40 _supported_fmt qcow2
41 _supported_proto file
42 _supported_os Linux
43 _require_drivers copy-on-read
45 # Internal snapshots are (currently) impossible with refcount_bits=1,
46 # and generally impossible with external data files
47 _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file
49 _require_devices virtio-blk
51 do_run_qemu()
53 echo Testing: "$@"
55 if ! test -t 0; then
56 while read cmd; do
57 echo $cmd
58 done
60 echo quit
61 ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
62 echo
65 run_qemu()
67 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
68 _filter_generated_node_ids | _filter_imgfmt | _filter_vmstate_size
71 size=128M
73 run_test()
75 if [ -n "$BACKING_FILE" ]; then
76 _make_test_img -b "$BACKING_FILE" $size
77 else
78 _make_test_img $size
80 printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date
84 echo
85 echo "=== No block devices at all ==="
86 echo
88 run_test
90 echo
91 echo "=== -drive if=none ==="
92 echo
94 run_test -drive driver=file,file="$TEST_IMG",if=none
95 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=none
96 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=none -device virtio-blk,drive=none0
98 echo
99 echo "=== -drive if=virtio ==="
100 echo
102 run_test -drive driver=file,file="$TEST_IMG",if=virtio
103 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=virtio
105 echo
106 echo "=== Simple -blockdev ==="
107 echo
109 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file
110 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
111 -blockdev driver=$IMGFMT,file=file,node-name=fmt
112 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
113 -blockdev driver=raw,file=file,node-name=raw \
114 -blockdev driver=$IMGFMT,file=raw,node-name=fmt
116 echo
117 echo "=== -blockdev with a filter on top ==="
118 echo
120 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
121 -blockdev driver=$IMGFMT,file=file,node-name=fmt \
122 -blockdev driver=copy-on-read,file=fmt,node-name=filter
124 echo
125 echo "=== -blockdev with a backing file ==="
126 echo
128 TEST_IMG="$TEST_IMG.base" _make_test_img $size
130 BACKING_FILE="$TEST_IMG.base" \
131 run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
132 -blockdev driver=file,filename="$TEST_IMG",node-name=file \
133 -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt
135 BACKING_FILE="$TEST_IMG.base" \
136 run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
137 -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \
138 -blockdev driver=file,filename="$TEST_IMG",node-name=file \
139 -blockdev driver=$IMGFMT,file=file,backing=backing-fmt,node-name=fmt
141 # A snapshot should be present on the overlay, but not the backing file
142 echo Internal snapshots on overlay:
143 $QEMU_IMG snapshot -l "$TEST_IMG" | _filter_date | _filter_vmstate_size
145 echo Internal snapshots on backing file:
146 $QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
148 echo
149 echo "=== -blockdev with NBD server on the backing file ==="
150 echo
152 _make_test_img -b "$TEST_IMG.base" $size
153 cat <<EOF |
154 nbd_server_start unix:$SOCK_DIR/nbd
155 nbd_server_add -w backing-fmt
156 savevm snap0
157 info snapshots
158 loadvm snap0
160 run_qemu -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
161 -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \
162 -blockdev driver=file,filename="$TEST_IMG",node-name=file \
163 -blockdev driver=$IMGFMT,file=file,backing=backing-fmt,node-name=fmt |
164 _filter_date
166 # This time, a snapshot should be created on both files
167 echo Internal snapshots on overlay:
168 $QEMU_IMG snapshot -l "$TEST_IMG" | _filter_date | _filter_vmstate_size
170 echo Internal snapshots on backing file:
171 $QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
173 # success, all done
174 echo "*** done"
175 rm -f $seq.full
176 status=0