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