]> Git Repo - qemu.git/blob - tests/qemu-iotests/267
tests/docker: Remove old Debian 9 containers
[qemu.git] / tests / qemu-iotests / 267
1 #!/usr/bin/env bash
2 #
3 # Test which nodes are involved in internal snapshots
4 #
5 # Copyright (C) 2019 Red Hat, Inc.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 # creator
22 [email protected]
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 status=1        # failure is the default!
28
29 _cleanup()
30 {
31     _cleanup_test_img
32     rm -f "$SOCK_DIR/nbd"
33 }
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39
40 _supported_fmt qcow2
41 _supported_proto file
42 _supported_os Linux
43 _require_drivers copy-on-read
44
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
48
49 _require_devices virtio-blk
50
51 do_run_qemu()
52 {
53     echo Testing: "$@"
54     (
55         if ! test -t 0; then
56             while read cmd; do
57                 echo $cmd
58             done
59         fi
60         echo quit
61     ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
62     echo
63 }
64
65 run_qemu()
66 {
67     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
68         _filter_generated_node_ids | _filter_imgfmt | _filter_vmstate_size
69 }
70
71 size=128M
72
73 run_test()
74 {
75     if [ -n "$BACKING_FILE" ]; then
76         _make_test_img -b "$BACKING_FILE" -F $IMGFMT $size
77     else
78         _make_test_img $size
79     fi
80     printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date
81 }
82
83
84 echo
85 echo "=== No block devices at all ==="
86 echo
87
88 run_test
89
90 echo
91 echo "=== -drive if=none ==="
92 echo
93
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
97
98 echo
99 echo "=== -drive if=virtio ==="
100 echo
101
102 run_test -drive driver=file,file="$TEST_IMG",if=virtio
103 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=virtio
104
105 echo
106 echo "=== Simple -blockdev ==="
107 echo
108
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
115
116 echo
117 echo "=== -blockdev with a filter on top ==="
118 echo
119
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
123
124 echo
125 echo "=== -blockdev with a backing file ==="
126 echo
127
128 TEST_IMG="$TEST_IMG.base" _make_test_img $size
129
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
134
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
140
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
144
145 echo Internal snapshots on backing file:
146 $QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
147
148 echo
149 echo "=== -blockdev with NBD server on the backing file ==="
150 echo
151
152 _make_test_img -b "$TEST_IMG.base" -F $IMGFMT $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
159 EOF
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
165
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
169
170 echo Internal snapshots on backing file:
171 $QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
172
173 # success, all done
174 echo "*** done"
175 rm -f $seq.full
176 status=0
This page took 0.035475 seconds and 4 git commands to generate.