2 # group: rw auto quick snapshot
4 # Test which nodes are involved in internal snapshots
6 # Copyright (C) 2019 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/>.
23 owner=kwolf@redhat.com
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
44 _require_drivers copy-on-read
46 # Internal snapshots are (currently) impossible with refcount_bits=1,
47 # and generally impossible with external data files
48 _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file
50 _require_devices virtio-blk
62 ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
68 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
69 _filter_generated_node_ids | _filter_imgfmt | _filter_vmstate_size
76 if [ -n "$BACKING_FILE" ]; then
77 _make_test_img -b "$BACKING_FILE" -F $IMGFMT $size
81 printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date
86 echo "=== No block devices at all ==="
92 echo "=== -drive if=none ==="
95 run_test -drive driver=file,file="$TEST_IMG",if=none
96 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=none
97 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=none -device virtio-blk,drive=none0
100 echo "=== -drive if=virtio ==="
103 run_test -drive driver=file,file="$TEST_IMG",if=virtio
104 run_test -drive driver=$IMGFMT,file="$TEST_IMG",if=virtio
107 echo "=== Simple -blockdev ==="
110 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file
111 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
112 -blockdev driver=$IMGFMT,file=file,node-name=fmt
113 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
114 -blockdev driver=raw,file=file,node-name=raw \
115 -blockdev driver=$IMGFMT,file=raw,node-name=fmt
118 echo "=== -blockdev with a filter on top ==="
121 run_test -blockdev driver=file,filename="$TEST_IMG",node-name=file \
122 -blockdev driver=$IMGFMT,file=file,node-name=fmt \
123 -blockdev driver=copy-on-read,file=fmt,node-name=filter
126 echo "=== -blockdev with a backing file ==="
129 TEST_IMG="$TEST_IMG.base" _make_test_img $size
131 BACKING_FILE="$TEST_IMG.base" \
132 run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
133 -blockdev driver=file,filename="$TEST_IMG",node-name=file \
134 -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt
136 BACKING_FILE="$TEST_IMG.base" \
137 run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
138 -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \
139 -blockdev driver=file,filename="$TEST_IMG",node-name=file \
140 -blockdev driver=$IMGFMT,file=file,backing=backing-fmt,node-name=fmt
142 # A snapshot should be present on the overlay, but not the backing file
143 echo Internal snapshots on overlay:
144 $QEMU_IMG snapshot -l "$TEST_IMG" | _filter_date | _filter_vmstate_size
146 echo Internal snapshots on backing file:
147 $QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size
150 echo "=== -blockdev with NBD server on the backing file ==="
153 _make_test_img -b "$TEST_IMG.base" -F $IMGFMT $size
155 nbd_server_start unix:$SOCK_DIR/nbd
156 nbd_server_add -w backing-fmt
161 run_qemu -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \
162 -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \
163 -blockdev driver=file,filename="$TEST_IMG",node-name=file \
164 -blockdev driver=$IMGFMT,file=file,backing=backing-fmt,node-name=fmt |
167 # This time, a snapshot should be created on both files
168 echo Internal snapshots on overlay:
169 $QEMU_IMG snapshot -l "$TEST_IMG" | _filter_date | _filter_vmstate_size
171 echo Internal snapshots on backing file:
172 $QEMU_IMG snapshot -l "$TEST_IMG.base" | _filter_date | _filter_vmstate_size