1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Wolfstatus=1 # failure is the default! 2816701400SKevin Wolf 2916701400SKevin Wolf_cleanup() 3016701400SKevin Wolf{ 3116701400SKevin Wolf _cleanup_test_img 3216701400SKevin Wolf} 3316701400SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 3416701400SKevin Wolf 3516701400SKevin Wolf# get standard environment, filters and checks 3616701400SKevin Wolf. ./common.rc 3716701400SKevin Wolf. ./common.filter 3816701400SKevin Wolf. ./common.pattern 3916701400SKevin Wolf 4016701400SKevin Wolf# Any format supporting backing files 41f5a4bbd9SStefan Hajnoczi_supported_fmt qcow qcow2 vmdk qed 421f7bf7d0SPeter Lieven_supported_proto file 4316701400SKevin Wolf_supported_os Linux 44d2329f27SFam Zheng_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" 4516701400SKevin Wolf 4616701400SKevin WolfTEST_OFFSETS="0 4294967296" 4716701400SKevin Wolf 48794d00f7SFam ZhengTEST_IMG_SAVE=$TEST_IMG 49794d00f7SFam ZhengTEST_IMG=$TEST_IMG.base 5016701400SKevin Wolf_make_test_img 6G 5116701400SKevin Wolf 5216701400SKevin Wolfecho "Filling base image" 5316701400SKevin Wolfecho 5416701400SKevin Wolf 5516701400SKevin Wolffor offset in $TEST_OFFSETS; do 5616701400SKevin Wolf # Some clusters with alternating backing file/image file reads 5716701400SKevin Wolf io writev $(( offset )) 512 1024 64 5816701400SKevin Wolf 5916701400SKevin Wolf # Complete backing clusters 6016701400SKevin Wolf io writev $(( offset + 64 * 1024)) 65536 65536 1 6116701400SKevin Wolfdone 6216701400SKevin Wolf_check_test_img 6316701400SKevin Wolf 6416701400SKevin Wolfecho "Creating test image with backing file" 6516701400SKevin Wolfecho 6616701400SKevin Wolf 679b337ae9SFam ZhengTEST_IMG="$TEST_IMG_SAVE.orig" 689b337ae9SFam Zheng_make_test_img -b "$TEST_IMG_SAVE.base" 6G 6916701400SKevin Wolf 7016701400SKevin Wolfecho "Filling test image" 7116701400SKevin Wolfecho 7216701400SKevin Wolf 7316701400SKevin Wolffor offset in $TEST_OFFSETS; do 7416701400SKevin Wolf # Some clusters with alternating backing file/image file reads 7516701400SKevin Wolf io writev $(( offset + 512 )) 512 1024 64 7616701400SKevin Wolf 7716701400SKevin Wolf # Complete test image clusters 7816701400SKevin Wolf io writev $(( offset + 64 * 1024 + 65536)) 65536 65536 1 7916701400SKevin Wolfdone 8016701400SKevin Wolf_check_test_img 8116701400SKevin Wolf 829b337ae9SFam ZhengTEST_IMG="$TEST_IMG_SAVE" 839b337ae9SFam Zheng$QEMU_IMG convert -f $IMGFMT -O $IMGFMT "$TEST_IMG.orig" "$TEST_IMG" 8416701400SKevin Wolf 8516701400SKevin Wolfecho "Reading" 8616701400SKevin Wolfecho 8716701400SKevin Wolf 8816701400SKevin Wolffor offset in $TEST_OFFSETS; do 8916701400SKevin Wolf # Some clusters with alternating backing file/image file reads 9016701400SKevin Wolf io readv $(( offset )) 512 1024 64 9116701400SKevin Wolf io readv $(( offset + 512 )) 512 1024 64 9216701400SKevin Wolf 9316701400SKevin Wolf # Complete test image clusters 9416701400SKevin Wolf io readv $(( offset + 64 * 1024)) 65536 65536 1 9516701400SKevin Wolf io readv $(( offset + 64 * 1024 + 65536)) 65536 65536 1 9616701400SKevin Wolf 9716701400SKevin Wolf # Empty sectors 9816701400SKevin Wolf io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1 9916701400SKevin Wolfdone 10016701400SKevin Wolf_check_test_img 10116701400SKevin Wolf 10216701400SKevin Wolf# success, all done 10316701400SKevin Wolfecho "*** done" 10416701400SKevin Wolfrm -f $seq.full 10516701400SKevin Wolfstatus=0 106