1908eaf68SStefan Hajnoczi#!/bin/bash 216701400SKevin Wolf# 316701400SKevin Wolf# Merge backing file into test image when converting the image 416701400SKevin Wolf# 516701400SKevin Wolf# Copyright (C) 2009 Red Hat, Inc. 616701400SKevin Wolf# 716701400SKevin Wolf# This program is free software; you can redistribute it and/or modify 816701400SKevin Wolf# it under the terms of the GNU General Public License as published by 916701400SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 1016701400SKevin Wolf# (at your option) any later version. 1116701400SKevin Wolf# 1216701400SKevin Wolf# This program is distributed in the hope that it will be useful, 1316701400SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 1416701400SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1516701400SKevin Wolf# GNU General Public License for more details. 1616701400SKevin Wolf# 1716701400SKevin Wolf# You should have received a copy of the GNU General Public License 18e8c212d6SChristoph Hellwig# along with this program. If not, see <http://www.gnu.org/licenses/>. 1916701400SKevin Wolf# 2016701400SKevin Wolf 2116701400SKevin Wolf# creator 2216701400SKevin Wolfowner=kwolf@redhat.com 2316701400SKevin Wolf 2416701400SKevin Wolfseq=`basename $0` 2516701400SKevin Wolfecho "QA output created by $seq" 2616701400SKevin Wolf 2716701400SKevin Wolfhere=`pwd` 2816701400SKevin Wolftmp=/tmp/$$ 2916701400SKevin Wolfstatus=1 # failure is the default! 3016701400SKevin Wolf 3116701400SKevin Wolf_cleanup() 3216701400SKevin Wolf{ 3316701400SKevin Wolf _cleanup_test_img 3416701400SKevin Wolf} 3516701400SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 3616701400SKevin Wolf 3716701400SKevin Wolf# get standard environment, filters and checks 3816701400SKevin Wolf. ./common.rc 3916701400SKevin Wolf. ./common.filter 4016701400SKevin Wolf. ./common.pattern 4116701400SKevin Wolf 4216701400SKevin Wolf# Any format supporting backing files 43f5a4bbd9SStefan Hajnoczi_supported_fmt qcow qcow2 vmdk qed 441f7bf7d0SPeter Lieven_supported_proto file 4516701400SKevin Wolf_supported_os Linux 46d2329f27SFam Zheng_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" 4716701400SKevin Wolf 4816701400SKevin WolfTEST_OFFSETS="0 4294967296" 4916701400SKevin Wolf 50794d00f7SFam ZhengTEST_IMG_SAVE=$TEST_IMG 51794d00f7SFam ZhengTEST_IMG=$TEST_IMG.base 5216701400SKevin Wolf_make_test_img 6G 5316701400SKevin Wolf 5416701400SKevin Wolfecho "Filling base image" 5516701400SKevin Wolfecho 5616701400SKevin Wolf 5716701400SKevin Wolffor offset in $TEST_OFFSETS; do 5816701400SKevin Wolf # Some clusters with alternating backing file/image file reads 5916701400SKevin Wolf io writev $(( offset )) 512 1024 64 6016701400SKevin Wolf 6116701400SKevin Wolf # Complete backing clusters 6216701400SKevin Wolf io writev $(( offset + 64 * 1024)) 65536 65536 1 6316701400SKevin Wolfdone 6416701400SKevin Wolf_check_test_img 6516701400SKevin Wolf 6616701400SKevin Wolfecho "Creating test image with backing file" 6716701400SKevin Wolfecho 6816701400SKevin Wolf 69*9b337ae9SFam ZhengTEST_IMG="$TEST_IMG_SAVE.orig" 70*9b337ae9SFam Zheng_make_test_img -b "$TEST_IMG_SAVE.base" 6G 7116701400SKevin Wolf 7216701400SKevin Wolfecho "Filling test image" 7316701400SKevin Wolfecho 7416701400SKevin Wolf 7516701400SKevin Wolffor offset in $TEST_OFFSETS; do 7616701400SKevin Wolf # Some clusters with alternating backing file/image file reads 7716701400SKevin Wolf io writev $(( offset + 512 )) 512 1024 64 7816701400SKevin Wolf 7916701400SKevin Wolf # Complete test image clusters 8016701400SKevin Wolf io writev $(( offset + 64 * 1024 + 65536)) 65536 65536 1 8116701400SKevin Wolfdone 8216701400SKevin Wolf_check_test_img 8316701400SKevin Wolf 84*9b337ae9SFam ZhengTEST_IMG="$TEST_IMG_SAVE" 85*9b337ae9SFam Zheng$QEMU_IMG convert -f $IMGFMT -O $IMGFMT "$TEST_IMG.orig" "$TEST_IMG" 8616701400SKevin Wolf 8716701400SKevin Wolfecho "Reading" 8816701400SKevin Wolfecho 8916701400SKevin Wolf 9016701400SKevin Wolffor offset in $TEST_OFFSETS; do 9116701400SKevin Wolf # Some clusters with alternating backing file/image file reads 9216701400SKevin Wolf io readv $(( offset )) 512 1024 64 9316701400SKevin Wolf io readv $(( offset + 512 )) 512 1024 64 9416701400SKevin Wolf 9516701400SKevin Wolf # Complete test image clusters 9616701400SKevin Wolf io readv $(( offset + 64 * 1024)) 65536 65536 1 9716701400SKevin Wolf io readv $(( offset + 64 * 1024 + 65536)) 65536 65536 1 9816701400SKevin Wolf 9916701400SKevin Wolf # Empty sectors 10016701400SKevin Wolf io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1 10116701400SKevin Wolfdone 10216701400SKevin Wolf_check_test_img 10316701400SKevin Wolf 10416701400SKevin Wolf# success, all done 10516701400SKevin Wolfecho "*** done" 10616701400SKevin Wolfrm -f $seq.full 10716701400SKevin Wolfstatus=0 108