111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick 3e4603fe1SKevin Wolf# 4e4603fe1SKevin Wolf# Test that temporary backing file overrides (on the command line or in 5e4603fe1SKevin Wolf# blockdev-add) don't replace the original path stored in the image during 6e4603fe1SKevin Wolf# header updates. 7e4603fe1SKevin Wolf# 8e4603fe1SKevin Wolf# Copyright (C) 2015 Red Hat, Inc. 9e4603fe1SKevin Wolf# 10e4603fe1SKevin Wolf# This program is free software; you can redistribute it and/or modify 11e4603fe1SKevin Wolf# it under the terms of the GNU General Public License as published by 12e4603fe1SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 13e4603fe1SKevin Wolf# (at your option) any later version. 14e4603fe1SKevin Wolf# 15e4603fe1SKevin Wolf# This program is distributed in the hope that it will be useful, 16e4603fe1SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 17e4603fe1SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18e4603fe1SKevin Wolf# GNU General Public License for more details. 19e4603fe1SKevin Wolf# 20e4603fe1SKevin Wolf# You should have received a copy of the GNU General Public License 21e4603fe1SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 22e4603fe1SKevin Wolf# 23e4603fe1SKevin Wolf 24e4603fe1SKevin Wolf# creator 25e4603fe1SKevin Wolfowner=kwolf@redhat.com 26e4603fe1SKevin Wolf 27e4603fe1SKevin Wolfseq="$(basename $0)" 28e4603fe1SKevin Wolfecho "QA output created by $seq" 29e4603fe1SKevin Wolf 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 45*0988928eSThomas Huth_supported_proto file 46e4603fe1SKevin Wolf_supported_os Linux 4794254c9bSMax Reitz# We are going to use lazy-refcounts 4894254c9bSMax Reitz_unsupported_imgopts 'compat=0.10' 49e4603fe1SKevin Wolf 50e4603fe1SKevin Wolfqemu_comm_method="monitor" 51e4603fe1SKevin Wolf 52e4603fe1SKevin Wolf 53e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.orig" _make_test_img 64M 54e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M 55e4603fe1SKevin Wolf_make_test_img 64M 56e4603fe1SKevin Wolf_img_info | _filter_img_info 57e4603fe1SKevin Wolf 58e4603fe1SKevin Wolfecho 59e4603fe1SKevin Wolfecho "=== HMP commit ===" 60e4603fe1SKevin Wolfecho 61e4603fe1SKevin Wolf# bdrv_make_empty() involves a header update for qcow2 62e4603fe1SKevin Wolf 63e4603fe1SKevin Wolf# Test that a backing file isn't written 64137a905fSBo Tu_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base" 65137a905fSBo Tu_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)" 66e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)' 67e4603fe1SKevin Wolf_cleanup_qemu 68e4603fe1SKevin Wolf_img_info | _filter_img_info 69e4603fe1SKevin Wolf 70e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the 71e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format 72e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M 73137a905fSBo Tu_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT 74137a905fSBo Tu_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)" 75e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)' 76e4603fe1SKevin Wolf_cleanup_qemu 77e4603fe1SKevin Wolf_img_info | _filter_img_info 78e4603fe1SKevin Wolf 79e4603fe1SKevin Wolfecho 80e4603fe1SKevin Wolfecho "=== Marking image dirty (lazy refcounts) ===" 81e4603fe1SKevin Wolfecho 82e4603fe1SKevin Wolf 83e4603fe1SKevin Wolf# Test that a backing file isn't written 84e4603fe1SKevin Wolf_make_test_img 64M 85e4603fe1SKevin Wolf$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io 86e4603fe1SKevin Wolf_img_info | _filter_img_info 87e4603fe1SKevin Wolf 88e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the 89e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format 90e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M 91e4603fe1SKevin 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 92e4603fe1SKevin Wolf_img_info | _filter_img_info 93e4603fe1SKevin Wolf 94e4603fe1SKevin Wolf# success, all done 95e4603fe1SKevin Wolfecho '*** done' 96e4603fe1SKevin Wolfrm -f $seq.full 97e4603fe1SKevin Wolfstatus=0 98