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