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