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