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