1*e4603fe1SKevin Wolf#!/bin/bash 2*e4603fe1SKevin Wolf# 3*e4603fe1SKevin Wolf# Test that temporary backing file overrides (on the command line or in 4*e4603fe1SKevin Wolf# blockdev-add) don't replace the original path stored in the image during 5*e4603fe1SKevin Wolf# header updates. 6*e4603fe1SKevin Wolf# 7*e4603fe1SKevin Wolf# Copyright (C) 2015 Red Hat, Inc. 8*e4603fe1SKevin Wolf# 9*e4603fe1SKevin Wolf# This program is free software; you can redistribute it and/or modify 10*e4603fe1SKevin Wolf# it under the terms of the GNU General Public License as published by 11*e4603fe1SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 12*e4603fe1SKevin Wolf# (at your option) any later version. 13*e4603fe1SKevin Wolf# 14*e4603fe1SKevin Wolf# This program is distributed in the hope that it will be useful, 15*e4603fe1SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 16*e4603fe1SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*e4603fe1SKevin Wolf# GNU General Public License for more details. 18*e4603fe1SKevin Wolf# 19*e4603fe1SKevin Wolf# You should have received a copy of the GNU General Public License 20*e4603fe1SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 21*e4603fe1SKevin Wolf# 22*e4603fe1SKevin Wolf 23*e4603fe1SKevin Wolf# creator 24*e4603fe1SKevin Wolfowner=kwolf@redhat.com 25*e4603fe1SKevin Wolf 26*e4603fe1SKevin Wolfseq="$(basename $0)" 27*e4603fe1SKevin Wolfecho "QA output created by $seq" 28*e4603fe1SKevin Wolf 29*e4603fe1SKevin Wolfhere="$PWD" 30*e4603fe1SKevin Wolftmp=/tmp/$$ 31*e4603fe1SKevin Wolfstatus=1 # failure is the default! 32*e4603fe1SKevin Wolf 33*e4603fe1SKevin Wolf_cleanup() 34*e4603fe1SKevin Wolf{ 35*e4603fe1SKevin Wolf _cleanup_test_img 36*e4603fe1SKevin Wolf} 37*e4603fe1SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 38*e4603fe1SKevin Wolf 39*e4603fe1SKevin Wolf# get standard environment, filters and checks 40*e4603fe1SKevin Wolf. ./common.rc 41*e4603fe1SKevin Wolf. ./common.filter 42*e4603fe1SKevin Wolf. ./common.qemu 43*e4603fe1SKevin Wolf 44*e4603fe1SKevin Wolf_supported_fmt qcow2 45*e4603fe1SKevin Wolf_supported_proto generic 46*e4603fe1SKevin Wolf_supported_os Linux 47*e4603fe1SKevin Wolf 48*e4603fe1SKevin Wolfqemu_comm_method="monitor" 49*e4603fe1SKevin Wolf 50*e4603fe1SKevin Wolf 51*e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.orig" _make_test_img 64M 52*e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M 53*e4603fe1SKevin Wolf_make_test_img 64M 54*e4603fe1SKevin Wolf_img_info | _filter_img_info 55*e4603fe1SKevin Wolf 56*e4603fe1SKevin Wolfecho 57*e4603fe1SKevin Wolfecho "=== HMP commit ===" 58*e4603fe1SKevin Wolfecho 59*e4603fe1SKevin Wolf# bdrv_make_empty() involves a header update for qcow2 60*e4603fe1SKevin Wolf 61*e4603fe1SKevin Wolf# Test that a backing file isn't written 62*e4603fe1SKevin Wolf_launch_qemu -drive file="$TEST_IMG",backing.file.filename="$TEST_IMG.base" 63*e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE "commit ide0-hd0" "(qemu)" 64*e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)' 65*e4603fe1SKevin Wolf_cleanup_qemu 66*e4603fe1SKevin Wolf_img_info | _filter_img_info 67*e4603fe1SKevin Wolf 68*e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the 69*e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format 70*e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M 71*e4603fe1SKevin Wolf_launch_qemu -drive file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT 72*e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE "commit ide0-hd0" "(qemu)" 73*e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)' 74*e4603fe1SKevin Wolf_cleanup_qemu 75*e4603fe1SKevin Wolf_img_info | _filter_img_info 76*e4603fe1SKevin Wolf 77*e4603fe1SKevin Wolfecho 78*e4603fe1SKevin Wolfecho "=== Marking image dirty (lazy refcounts) ===" 79*e4603fe1SKevin Wolfecho 80*e4603fe1SKevin Wolf 81*e4603fe1SKevin Wolf# Test that a backing file isn't written 82*e4603fe1SKevin Wolf_make_test_img 64M 83*e4603fe1SKevin Wolf$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io 84*e4603fe1SKevin Wolf_img_info | _filter_img_info 85*e4603fe1SKevin Wolf 86*e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the 87*e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format 88*e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M 89*e4603fe1SKevin Wolf$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,backing.driver=$IMGFMT,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io 90*e4603fe1SKevin Wolf_img_info | _filter_img_info 91*e4603fe1SKevin Wolf 92*e4603fe1SKevin Wolf# success, all done 93*e4603fe1SKevin Wolfecho '*** done' 94*e4603fe1SKevin Wolfrm -f $seq.full 95*e4603fe1SKevin Wolfstatus=0 96