111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw backing auto quick 316701400SKevin Wolf# 416701400SKevin Wolf# Merge backing file into test image when converting the image 516701400SKevin Wolf# 616701400SKevin Wolf# Copyright (C) 2009 Red Hat, Inc. 716701400SKevin Wolf# 816701400SKevin Wolf# This program is free software; you can redistribute it and/or modify 916701400SKevin Wolf# it under the terms of the GNU General Public License as published by 1016701400SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 1116701400SKevin Wolf# (at your option) any later version. 1216701400SKevin Wolf# 1316701400SKevin Wolf# This program is distributed in the hope that it will be useful, 1416701400SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 1516701400SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1616701400SKevin Wolf# GNU General Public License for more details. 1716701400SKevin Wolf# 1816701400SKevin Wolf# You should have received a copy of the GNU General Public License 19e8c212d6SChristoph Hellwig# along with this program. If not, see <http://www.gnu.org/licenses/>. 2016701400SKevin Wolf# 2116701400SKevin Wolf 2216701400SKevin Wolf# creator 2316701400SKevin Wolfowner=kwolf@redhat.com 2416701400SKevin Wolf 2516701400SKevin Wolfseq=`basename $0` 2616701400SKevin Wolfecho "QA output created by $seq" 2716701400SKevin Wolf 2816701400SKevin Wolfstatus=1 # failure is the default! 2916701400SKevin Wolf 3016701400SKevin Wolf_cleanup() 3116701400SKevin Wolf{ 3216701400SKevin Wolf _cleanup_test_img 3316701400SKevin Wolf} 3416701400SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 3516701400SKevin Wolf 3616701400SKevin Wolf# get standard environment, filters and checks 3716701400SKevin Wolf. ./common.rc 3816701400SKevin Wolf. ./common.filter 3916701400SKevin Wolf. ./common.pattern 4016701400SKevin Wolf 4116701400SKevin Wolf# Any format supporting backing files 42f5a4bbd9SStefan Hajnoczi_supported_fmt qcow qcow2 vmdk qed 431f7bf7d0SPeter Lieven_supported_proto file 4416701400SKevin Wolf_supported_os Linux 45325dd915SMax Reitz_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ 46325dd915SMax Reitz "streamOptimized" 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 699b337ae9SFam ZhengTEST_IMG="$TEST_IMG_SAVE.orig" 70b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG_SAVE.base" -F $IMGFMT 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 849b337ae9SFam ZhengTEST_IMG="$TEST_IMG_SAVE" 859b337ae9SFam 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