xref: /openbmc/qemu/tests/qemu-iotests/031 (revision e287a351)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick
3f394f1feSKevin Wolf#
4f394f1feSKevin Wolf# Test that all qcow2 header extensions survive a header rewrite
5f394f1feSKevin Wolf#
6f394f1feSKevin Wolf# Copyright (C) 2011 Red Hat, Inc.
7f394f1feSKevin Wolf#
8f394f1feSKevin Wolf# This program is free software; you can redistribute it and/or modify
9f394f1feSKevin Wolf# it under the terms of the GNU General Public License as published by
10f394f1feSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
11f394f1feSKevin Wolf# (at your option) any later version.
12f394f1feSKevin Wolf#
13f394f1feSKevin Wolf# This program is distributed in the hope that it will be useful,
14f394f1feSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
15f394f1feSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16f394f1feSKevin Wolf# GNU General Public License for more details.
17f394f1feSKevin Wolf#
18f394f1feSKevin Wolf# You should have received a copy of the GNU General Public License
19f394f1feSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20f394f1feSKevin Wolf#
21f394f1feSKevin Wolf
22f394f1feSKevin Wolf# creator
23f394f1feSKevin Wolfowner=kwolf@redhat.com
24f394f1feSKevin Wolf
25f394f1feSKevin Wolfseq=`basename $0`
26f394f1feSKevin Wolfecho "QA output created by $seq"
27f394f1feSKevin Wolf
28f394f1feSKevin Wolfstatus=1	# failure is the default!
29f394f1feSKevin Wolf
30f394f1feSKevin Wolf_cleanup()
31f394f1feSKevin Wolf{
32f394f1feSKevin Wolf	_cleanup_test_img
33f394f1feSKevin Wolf}
34f394f1feSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
35f394f1feSKevin Wolf
36f394f1feSKevin Wolf# get standard environment, filters and checks
37f394f1feSKevin Wolf. ./common.rc
38f394f1feSKevin Wolf. ./common.filter
39f394f1feSKevin Wolf. ./common.pattern
40f394f1feSKevin Wolf
41f394f1feSKevin Wolf# This tests qcow2-specific low-level functionality
42f394f1feSKevin Wolf_supported_fmt qcow2
4357284d2aSMax Reitz_supported_proto file fuse
443be2024aSMax Reitz# We want to test compat=0.10, which does not support external data
45*e287a351SVladimir Sementsov-Ogievskiy# files or refcount widths other than 16 or compression type
46*e287a351SVladimir Sementsov-Ogievskiy_unsupported_imgopts data_file compression_type \
47*e287a351SVladimir Sementsov-Ogievskiy    'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
48f394f1feSKevin Wolf
49f394f1feSKevin WolfCLUSTER_SIZE=65536
501042ec94SKevin Wolf
511042ec94SKevin Wolf# qcow2.py output depends on the exact options used, so override the command
521042ec94SKevin Wolf# line here as an exception
53407fb56aSMax Reitzfor compat in "compat=0.10" "compat=1.1"; do
541042ec94SKevin Wolf
551042ec94SKevin Wolf    echo
56407fb56aSMax Reitz    echo ===== Testing with -o $compat =====
57f394f1feSKevin Wolf    echo
58f394f1feSKevin Wolf    echo === Create image with unknown header extension ===
59f394f1feSKevin Wolf    echo
60407fb56aSMax Reitz    _make_test_img -o $compat 64M
61ea81ca9dSMax Reitz    $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension"
62984d7a52SVladimir Sementsov-Ogievskiy    _qcow2_dump_header
63f394f1feSKevin Wolf    _check_test_img
64f394f1feSKevin Wolf
65f394f1feSKevin Wolf    echo
66f394f1feSKevin Wolf    echo === Rewrite header with no backing file ===
67f394f1feSKevin Wolf    echo
68fef9c191SJeff Cody    $QEMU_IMG rebase -u -b "" "$TEST_IMG"
69984d7a52SVladimir Sementsov-Ogievskiy    _qcow2_dump_header
70f394f1feSKevin Wolf    _check_test_img
71f394f1feSKevin Wolf
72f394f1feSKevin Wolf    echo
73f394f1feSKevin Wolf    echo === Add a backing file and format ===
74f394f1feSKevin Wolf    echo
75fef9c191SJeff Cody    $QEMU_IMG rebase -u -b "/some/backing/file/path" -F host_device "$TEST_IMG"
76984d7a52SVladimir Sementsov-Ogievskiy    _qcow2_dump_header
771042ec94SKevin Wolfdone
78f394f1feSKevin Wolf
79f394f1feSKevin Wolf# success, all done
80f394f1feSKevin Wolfecho "*** done"
81f394f1feSKevin Wolfrm -f $seq.full
82f394f1feSKevin Wolfstatus=0
83