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/>.
22 owner
=kwolf@redhat.com
25 echo "QA output created by $seq"
27 status
=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
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
61 ) |
$QEMU -nographic -monitor stdio
-nodefaults "$@"
67 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
68 _filter_generated_node_ids | _filter_imgfmt | _filter_vmstate_size
75 if [ -n "$BACKING_FILE" ]; then
76 _make_test_img
-b "$BACKING_FILE" -F $IMGFMT $size
80 printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu
"$@" | _filter_date
85 echo "=== No block devices at all ==="
91 echo "=== -drive if=none ==="
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
99 echo "=== -drive if=virtio ==="
102 run_test
-drive driver
=file,file="$TEST_IMG",if=virtio
103 run_test
-drive driver
=$IMGFMT,file="$TEST_IMG",if=virtio
106 echo "=== Simple -blockdev ==="
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
117 echo "=== -blockdev with a filter on top ==="
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
125 echo "=== -blockdev with a backing file ==="
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
149 echo "=== -blockdev with NBD server on the backing file ==="
152 _make_test_img
-b "$TEST_IMG.base" -F $IMGFMT $size
154 nbd_server_start unix:$SOCK_DIR/nbd
155 nbd_server_add -w backing-fmt
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 |
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