xref: /openbmc/qemu/tests/qemu-iotests/018 (revision fef9c19139f4d69a080d99b8cbade163d0bbf0fc)
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
449cdfa1b3SMORITA Kazutaka_supported_proto generic
4516701400SKevin Wolf_supported_os Linux
4616701400SKevin Wolf
4716701400SKevin WolfTEST_OFFSETS="0 4294967296"
4816701400SKevin Wolf
49794d00f7SFam ZhengTEST_IMG_SAVE=$TEST_IMG
50794d00f7SFam ZhengTEST_IMG=$TEST_IMG.base
5116701400SKevin Wolf_make_test_img 6G
5216701400SKevin Wolf
5316701400SKevin Wolfecho "Filling base image"
5416701400SKevin Wolfecho
5516701400SKevin Wolf
5616701400SKevin Wolffor offset in $TEST_OFFSETS; do
5716701400SKevin Wolf    # Some clusters with alternating backing file/image file reads
5816701400SKevin Wolf    io writev $(( offset )) 512 1024 64
5916701400SKevin Wolf
6016701400SKevin Wolf    # Complete backing clusters
6116701400SKevin Wolf    io writev $(( offset  + 64 * 1024))  65536 65536 1
6216701400SKevin Wolfdone
6316701400SKevin Wolf_check_test_img
6416701400SKevin Wolf
6516701400SKevin Wolfecho "Creating test image with backing file"
6616701400SKevin Wolfecho
6716701400SKevin Wolf
68794d00f7SFam ZhengTEST_IMG=$TEST_IMG_SAVE
69*fef9c191SJeff Cody_make_test_img -b "$TEST_IMG.base" 6G
7016701400SKevin Wolf
7116701400SKevin Wolfecho "Filling test image"
7216701400SKevin Wolfecho
7316701400SKevin Wolf
7416701400SKevin Wolffor offset in $TEST_OFFSETS; do
7516701400SKevin Wolf    # Some clusters with alternating backing file/image file reads
7616701400SKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
7716701400SKevin Wolf
7816701400SKevin Wolf    # Complete test image clusters
7916701400SKevin Wolf    io writev $(( offset + 64 * 1024 + 65536))  65536 65536 1
8016701400SKevin Wolfdone
8116701400SKevin Wolf_check_test_img
8216701400SKevin Wolf
83*fef9c191SJeff Codymv "$TEST_IMG" "$TEST_IMG.orig"
84*fef9c191SJeff Cody$QEMU_IMG convert -O $IMGFMT "$TEST_IMG.orig" "$TEST_IMG"
8516701400SKevin Wolf
8616701400SKevin Wolfecho "Reading"
8716701400SKevin Wolfecho
8816701400SKevin Wolf
8916701400SKevin Wolffor offset in $TEST_OFFSETS; do
9016701400SKevin Wolf    # Some clusters with alternating backing file/image file reads
9116701400SKevin Wolf    io readv $(( offset )) 512 1024 64
9216701400SKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
9316701400SKevin Wolf
9416701400SKevin Wolf    # Complete test image clusters
9516701400SKevin Wolf    io readv $(( offset  + 64 * 1024))  65536 65536 1
9616701400SKevin Wolf    io readv $(( offset + 64 * 1024 + 65536))  65536 65536 1
9716701400SKevin Wolf
9816701400SKevin Wolf    # Empty sectors
9916701400SKevin Wolf    io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1
10016701400SKevin Wolfdone
10116701400SKevin Wolf_check_test_img
10216701400SKevin Wolf
10316701400SKevin Wolf# success, all done
10416701400SKevin Wolfecho "*** done"
10516701400SKevin Wolfrm -f $seq.full
10616701400SKevin Wolfstatus=0
107