xref: /qemu/tests/qemu-iotests/031 (revision 1042ec94b19e0bfaae74c912ebbdfdbff8dd7db2)
1f394f1feSKevin Wolf#!/bin/bash
2f394f1feSKevin Wolf#
3f394f1feSKevin Wolf# Test that all qcow2 header extensions survive a header rewrite
4f394f1feSKevin Wolf#
5f394f1feSKevin Wolf# Copyright (C) 2011 Red Hat, Inc.
6f394f1feSKevin Wolf#
7f394f1feSKevin Wolf# This program is free software; you can redistribute it and/or modify
8f394f1feSKevin Wolf# it under the terms of the GNU General Public License as published by
9f394f1feSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10f394f1feSKevin Wolf# (at your option) any later version.
11f394f1feSKevin Wolf#
12f394f1feSKevin Wolf# This program is distributed in the hope that it will be useful,
13f394f1feSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14f394f1feSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15f394f1feSKevin Wolf# GNU General Public License for more details.
16f394f1feSKevin Wolf#
17f394f1feSKevin Wolf# You should have received a copy of the GNU General Public License
18f394f1feSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19f394f1feSKevin Wolf#
20f394f1feSKevin Wolf
21f394f1feSKevin Wolf# creator
22f394f1feSKevin Wolfowner=kwolf@redhat.com
23f394f1feSKevin Wolf
24f394f1feSKevin Wolfseq=`basename $0`
25f394f1feSKevin Wolfecho "QA output created by $seq"
26f394f1feSKevin Wolf
27f394f1feSKevin Wolfhere=`pwd`
28f394f1feSKevin Wolftmp=/tmp/$$
29f394f1feSKevin Wolfstatus=1	# failure is the default!
30f394f1feSKevin Wolf
31f394f1feSKevin Wolf_cleanup()
32f394f1feSKevin Wolf{
33f394f1feSKevin Wolf	_cleanup_test_img
34f394f1feSKevin Wolf}
35f394f1feSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
36f394f1feSKevin Wolf
37f394f1feSKevin Wolf# get standard environment, filters and checks
38f394f1feSKevin Wolf. ./common.rc
39f394f1feSKevin Wolf. ./common.filter
40f394f1feSKevin Wolf. ./common.pattern
41f394f1feSKevin Wolf
42f394f1feSKevin Wolf# This tests qcow2-specific low-level functionality
43f394f1feSKevin Wolf_supported_fmt qcow2
44f394f1feSKevin Wolf_supported_proto generic
45f394f1feSKevin Wolf_supported_os Linux
46f394f1feSKevin Wolf
47f394f1feSKevin WolfCLUSTER_SIZE=65536
48*1042ec94SKevin Wolf
49*1042ec94SKevin Wolf# qcow2.py output depends on the exact options used, so override the command
50*1042ec94SKevin Wolf# line here as an exception
51*1042ec94SKevin Wolffor IMGOPTS in "compat=0.10" "compat=1.1"; do
52*1042ec94SKevin Wolf
53*1042ec94SKevin Wolf    echo
54*1042ec94SKevin Wolf    echo ===== Testing with -o $IMGOPTS =====
55f394f1feSKevin Wolf    echo
56f394f1feSKevin Wolf    echo === Create image with unknown header extension ===
57f394f1feSKevin Wolf    echo
58f394f1feSKevin Wolf    _make_test_img 64M
59f394f1feSKevin Wolf    ./qcow2.py $TEST_IMG add-header-ext 0x12345678 "This is a test header extension"
60f394f1feSKevin Wolf    ./qcow2.py $TEST_IMG dump-header
61f394f1feSKevin Wolf    _check_test_img
62f394f1feSKevin Wolf
63f394f1feSKevin Wolf    echo
64f394f1feSKevin Wolf    echo === Rewrite header with no backing file ===
65f394f1feSKevin Wolf    echo
66f394f1feSKevin Wolf    $QEMU_IMG rebase -u -b "" $TEST_IMG
67f394f1feSKevin Wolf    ./qcow2.py $TEST_IMG dump-header
68f394f1feSKevin Wolf    _check_test_img
69f394f1feSKevin Wolf
70f394f1feSKevin Wolf    echo
71f394f1feSKevin Wolf    echo === Add a backing file and format ===
72f394f1feSKevin Wolf    echo
73f394f1feSKevin Wolf    $QEMU_IMG rebase -u -b "/some/backing/file/path" -F host_device $TEST_IMG
74f394f1feSKevin Wolf    ./qcow2.py $TEST_IMG dump-header
75*1042ec94SKevin Wolfdone
76f394f1feSKevin Wolf
77f394f1feSKevin Wolf# success, all done
78f394f1feSKevin Wolfecho "*** done"
79f394f1feSKevin Wolfrm -f $seq.full
80f394f1feSKevin Wolfstatus=0
81