1*c5f6e493SKevin Wolf#!/bin/bash 2*c5f6e493SKevin Wolf# 3*c5f6e493SKevin Wolf# Test invalid backing file format in qcow2 images 4*c5f6e493SKevin Wolf# 5*c5f6e493SKevin Wolf# Copyright (C) 2014 Red Hat, Inc. 6*c5f6e493SKevin Wolf# 7*c5f6e493SKevin Wolf# This program is free software; you can redistribute it and/or modify 8*c5f6e493SKevin Wolf# it under the terms of the GNU General Public License as published by 9*c5f6e493SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*c5f6e493SKevin Wolf# (at your option) any later version. 11*c5f6e493SKevin Wolf# 12*c5f6e493SKevin Wolf# This program is distributed in the hope that it will be useful, 13*c5f6e493SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*c5f6e493SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*c5f6e493SKevin Wolf# GNU General Public License for more details. 16*c5f6e493SKevin Wolf# 17*c5f6e493SKevin Wolf# You should have received a copy of the GNU General Public License 18*c5f6e493SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*c5f6e493SKevin Wolf# 20*c5f6e493SKevin Wolf 21*c5f6e493SKevin Wolf# creator 22*c5f6e493SKevin Wolfowner=kwolf@redhat.com 23*c5f6e493SKevin Wolf 24*c5f6e493SKevin Wolfseq="$(basename $0)" 25*c5f6e493SKevin Wolfecho "QA output created by $seq" 26*c5f6e493SKevin Wolf 27*c5f6e493SKevin Wolfhere="$PWD" 28*c5f6e493SKevin Wolftmp=/tmp/$$ 29*c5f6e493SKevin Wolfstatus=1 # failure is the default! 30*c5f6e493SKevin Wolf 31*c5f6e493SKevin Wolf_cleanup() 32*c5f6e493SKevin Wolf{ 33*c5f6e493SKevin Wolf _cleanup_test_img 34*c5f6e493SKevin Wolf} 35*c5f6e493SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36*c5f6e493SKevin Wolf 37*c5f6e493SKevin Wolf# get standard environment, filters and checks 38*c5f6e493SKevin Wolf. ./common.rc 39*c5f6e493SKevin Wolf. ./common.filter 40*c5f6e493SKevin Wolf 41*c5f6e493SKevin Wolf_supported_fmt qcow2 42*c5f6e493SKevin Wolf_supported_proto generic 43*c5f6e493SKevin Wolf_supported_os Linux 44*c5f6e493SKevin Wolf 45*c5f6e493SKevin Wolf 46*c5f6e493SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M 47*c5f6e493SKevin Wolf_make_test_img -b "$TEST_IMG.base" 64M 48*c5f6e493SKevin Wolf 49*c5f6e493SKevin Wolf# Set an invalid backing file format 50*c5f6e493SKevin Wolf$PYTHON qcow2.py "$TEST_IMG" add-header-ext 0xE2792ACA "foo" 51*c5f6e493SKevin Wolf_img_info 52*c5f6e493SKevin Wolf 53*c5f6e493SKevin Wolf# Try opening the image. Should fail (and not probe) in the first case, but 54*c5f6e493SKevin Wolf# overriding the backing file format should be possible. 55*c5f6e493SKevin Wolf$QEMU_IO -c "open $TEST_IMG" -c "read 0 4k" 2>&1 | _filter_qemu_io | _filter_testdir 56*c5f6e493SKevin Wolf$QEMU_IO -c "open -o backing.driver=$IMGFMT $TEST_IMG" -c "read 0 4k" | _filter_qemu_io 57*c5f6e493SKevin Wolf 58*c5f6e493SKevin Wolf# success, all done 59*c5f6e493SKevin Wolfecho '*** done' 60*c5f6e493SKevin Wolfrm -f $seq.full 61*c5f6e493SKevin Wolfstatus=0 62