xref: /qemu/tests/qemu-iotests/273 (revision d6f2c0b5a27f2a7e249ad6202fe88756c053ac0a)
1b1f6a8e1SKevin Wolf#!/usr/bin/env bash
2b1f6a8e1SKevin Wolf#
3b1f6a8e1SKevin Wolf# Test multiple blockdev-snapshot calls with 'backing': null
4b1f6a8e1SKevin Wolf#
5b1f6a8e1SKevin Wolf# Copyright (C) 2019 Red Hat, Inc.
6b1f6a8e1SKevin Wolf#
7b1f6a8e1SKevin Wolf# This program is free software; you can redistribute it and/or modify
8b1f6a8e1SKevin Wolf# it under the terms of the GNU General Public License as published by
9b1f6a8e1SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10b1f6a8e1SKevin Wolf# (at your option) any later version.
11b1f6a8e1SKevin Wolf#
12b1f6a8e1SKevin Wolf# This program is distributed in the hope that it will be useful,
13b1f6a8e1SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14b1f6a8e1SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15b1f6a8e1SKevin Wolf# GNU General Public License for more details.
16b1f6a8e1SKevin Wolf#
17b1f6a8e1SKevin Wolf# You should have received a copy of the GNU General Public License
18b1f6a8e1SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19b1f6a8e1SKevin Wolf#
20b1f6a8e1SKevin Wolf
21b1f6a8e1SKevin Wolfseq=$(basename "$0")
22b1f6a8e1SKevin Wolfecho "QA output created by $seq"
23b1f6a8e1SKevin Wolf
24b1f6a8e1SKevin Wolfstatus=1	# failure is the default!
25b1f6a8e1SKevin Wolf
26b1f6a8e1SKevin Wolf_cleanup()
27b1f6a8e1SKevin Wolf{
28b1f6a8e1SKevin Wolf    _cleanup_test_img
29b1f6a8e1SKevin Wolf}
30b1f6a8e1SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
31b1f6a8e1SKevin Wolf
32b1f6a8e1SKevin Wolf# get standard environment, filters and checks
33b1f6a8e1SKevin Wolf. ./common.rc
34b1f6a8e1SKevin Wolf. ./common.filter
35b1f6a8e1SKevin Wolf
36b1f6a8e1SKevin Wolf# This is a qcow2 regression test
37b1f6a8e1SKevin Wolf_supported_fmt qcow2
38b1f6a8e1SKevin Wolf_supported_proto file
39b1f6a8e1SKevin Wolf_supported_os Linux
40b1f6a8e1SKevin Wolf
41b1f6a8e1SKevin Wolfdo_run_qemu()
42b1f6a8e1SKevin Wolf{
43b1f6a8e1SKevin Wolf    echo Testing: "$@"
44b1f6a8e1SKevin Wolf    $QEMU -nographic -qmp-pretty stdio -nodefaults "$@"
45b1f6a8e1SKevin Wolf    echo
46b1f6a8e1SKevin Wolf}
47b1f6a8e1SKevin Wolf
48b1f6a8e1SKevin Wolfrun_qemu()
49b1f6a8e1SKevin Wolf{
50b1f6a8e1SKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp |
51*d6f2c0b5SMax Reitz        _filter_generated_node_ids | _filter_imgfmt |
52*d6f2c0b5SMax Reitz        _filter_actual_image_size | _filter_img_info
53b1f6a8e1SKevin Wolf}
54b1f6a8e1SKevin Wolf
55b1f6a8e1SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M
56b1f6a8e1SKevin WolfTEST_IMG="$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base"
57b1f6a8e1SKevin Wolf_make_test_img -b "$TEST_IMG.mid"
58b1f6a8e1SKevin Wolf
59b1f6a8e1SKevin Wolfrun_qemu \
60b1f6a8e1SKevin Wolf    -blockdev file,node-name=base,filename="$TEST_IMG.base" \
61b1f6a8e1SKevin Wolf     -blockdev file,node-name=midf,filename="$TEST_IMG.mid" \
62b1f6a8e1SKevin Wolf     -blockdev '{"driver":"qcow2","node-name":"mid","file":"midf","backing":null}' \
63b1f6a8e1SKevin Wolf     -blockdev file,node-name=topf,filename="$TEST_IMG" \
64b1f6a8e1SKevin Wolf     -blockdev '{"driver":"qcow2","file":"topf","node-name":"top","backing":null}' \
65b1f6a8e1SKevin Wolf<<EOF
66b1f6a8e1SKevin Wolf{"execute":"qmp_capabilities"}
67b1f6a8e1SKevin Wolf{"execute":"blockdev-snapshot","arguments":{"node":"base","overlay":"mid"}}
68b1f6a8e1SKevin Wolf{"execute":"blockdev-snapshot","arguments":{"node":"mid","overlay":"top"}}
69b1f6a8e1SKevin Wolf{"execute":"query-named-block-nodes"}
70b1f6a8e1SKevin Wolf{"execute":"x-debug-query-block-graph"}
71b1f6a8e1SKevin Wolf{"execute":"quit"}
72b1f6a8e1SKevin WolfEOF
73b1f6a8e1SKevin Wolf
74b1f6a8e1SKevin Wolf# success, all done
75b1f6a8e1SKevin Wolfecho "*** done"
76b1f6a8e1SKevin Wolfrm -f $seq.full
77b1f6a8e1SKevin Wolfstatus=0
78