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 40*3be2024aSMax Reitz# External data files would add nodes to the block graph, so it would 41*3be2024aSMax Reitz# not match the reference output 42*3be2024aSMax Reitz_unsupported_imgopts data_file 43b1f6a8e1SKevin Wolf 44b1f6a8e1SKevin Wolfdo_run_qemu() 45b1f6a8e1SKevin Wolf{ 46b1f6a8e1SKevin Wolf echo Testing: "$@" 47b1f6a8e1SKevin Wolf $QEMU -nographic -qmp-pretty stdio -nodefaults "$@" 48b1f6a8e1SKevin Wolf echo 49b1f6a8e1SKevin Wolf} 50b1f6a8e1SKevin Wolf 51b1f6a8e1SKevin Wolfrun_qemu() 52b1f6a8e1SKevin Wolf{ 53b1f6a8e1SKevin Wolf do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | 54d6f2c0b5SMax Reitz _filter_generated_node_ids | _filter_imgfmt | 55d6f2c0b5SMax Reitz _filter_actual_image_size | _filter_img_info 56b1f6a8e1SKevin Wolf} 57b1f6a8e1SKevin Wolf 58b1f6a8e1SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M 59b1f6a8e1SKevin WolfTEST_IMG="$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base" 60b1f6a8e1SKevin Wolf_make_test_img -b "$TEST_IMG.mid" 61b1f6a8e1SKevin Wolf 62b1f6a8e1SKevin Wolfrun_qemu \ 63b1f6a8e1SKevin Wolf -blockdev file,node-name=base,filename="$TEST_IMG.base" \ 64b1f6a8e1SKevin Wolf -blockdev file,node-name=midf,filename="$TEST_IMG.mid" \ 65b1f6a8e1SKevin Wolf -blockdev '{"driver":"qcow2","node-name":"mid","file":"midf","backing":null}' \ 66b1f6a8e1SKevin Wolf -blockdev file,node-name=topf,filename="$TEST_IMG" \ 67b1f6a8e1SKevin Wolf -blockdev '{"driver":"qcow2","file":"topf","node-name":"top","backing":null}' \ 68b1f6a8e1SKevin Wolf<<EOF 69b1f6a8e1SKevin Wolf{"execute":"qmp_capabilities"} 70b1f6a8e1SKevin Wolf{"execute":"blockdev-snapshot","arguments":{"node":"base","overlay":"mid"}} 71b1f6a8e1SKevin Wolf{"execute":"blockdev-snapshot","arguments":{"node":"mid","overlay":"top"}} 72b1f6a8e1SKevin Wolf{"execute":"query-named-block-nodes"} 73b1f6a8e1SKevin Wolf{"execute":"x-debug-query-block-graph"} 74b1f6a8e1SKevin Wolf{"execute":"quit"} 75b1f6a8e1SKevin WolfEOF 76b1f6a8e1SKevin Wolf 77b1f6a8e1SKevin Wolf# success, all done 78b1f6a8e1SKevin Wolfecho "*** done" 79b1f6a8e1SKevin Wolfrm -f $seq.full 80b1f6a8e1SKevin Wolfstatus=0 81