xref: /openbmc/qemu/tests/qemu-iotests/018 (revision f5a4bbd9)
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
43*f5a4bbd9SStefan Hajnoczi_supported_fmt qcow qcow2 vmdk qed
4416701400SKevin Wolf_supported_os Linux
4516701400SKevin Wolf
4616701400SKevin WolfTEST_OFFSETS="0 4294967296"
4716701400SKevin Wolf
4816701400SKevin Wolf_make_test_img 6G
4916701400SKevin Wolf
5016701400SKevin Wolfecho "Filling base image"
5116701400SKevin Wolfecho
5216701400SKevin Wolf
5316701400SKevin Wolffor offset in $TEST_OFFSETS; do
5416701400SKevin Wolf    # Some clusters with alternating backing file/image file reads
5516701400SKevin Wolf    io writev $(( offset )) 512 1024 64
5616701400SKevin Wolf
5716701400SKevin Wolf    # Complete backing clusters
5816701400SKevin Wolf    io writev $(( offset  + 64 * 1024))  65536 65536 1
5916701400SKevin Wolfdone
6016701400SKevin Wolf_check_test_img
6116701400SKevin Wolf
6216701400SKevin Wolfecho "Creating test image with backing file"
6316701400SKevin Wolfecho
6416701400SKevin Wolf
6516701400SKevin Wolfmv $TEST_IMG $TEST_IMG.base
6616701400SKevin Wolf_make_test_img -b $TEST_IMG.base 6G
6716701400SKevin Wolf
6816701400SKevin Wolfecho "Filling test image"
6916701400SKevin Wolfecho
7016701400SKevin Wolf
7116701400SKevin Wolffor offset in $TEST_OFFSETS; do
7216701400SKevin Wolf    # Some clusters with alternating backing file/image file reads
7316701400SKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
7416701400SKevin Wolf
7516701400SKevin Wolf    # Complete test image clusters
7616701400SKevin Wolf    io writev $(( offset + 64 * 1024 + 65536))  65536 65536 1
7716701400SKevin Wolfdone
7816701400SKevin Wolf_check_test_img
7916701400SKevin Wolf
8016701400SKevin Wolfmv $TEST_IMG $TEST_IMG.orig
8116701400SKevin Wolf$QEMU_IMG convert -O $IMGFMT $TEST_IMG.orig $TEST_IMG
8216701400SKevin Wolf
8316701400SKevin Wolfecho "Reading"
8416701400SKevin Wolfecho
8516701400SKevin Wolf
8616701400SKevin Wolffor offset in $TEST_OFFSETS; do
8716701400SKevin Wolf    # Some clusters with alternating backing file/image file reads
8816701400SKevin Wolf    io readv $(( offset )) 512 1024 64
8916701400SKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
9016701400SKevin Wolf
9116701400SKevin Wolf    # Complete test image clusters
9216701400SKevin Wolf    io readv $(( offset  + 64 * 1024))  65536 65536 1
9316701400SKevin Wolf    io readv $(( offset + 64 * 1024 + 65536))  65536 65536 1
9416701400SKevin Wolf
9516701400SKevin Wolf    # Empty sectors
9616701400SKevin Wolf    io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1
9716701400SKevin Wolfdone
9816701400SKevin Wolf_check_test_img
9916701400SKevin Wolf
10016701400SKevin Wolf# success, all done
10116701400SKevin Wolfecho "*** done"
10216701400SKevin Wolfrm -f $seq.full
10316701400SKevin Wolfstatus=0
104