xref: /openbmc/qemu/tests/qemu-iotests/017 (revision a98f49f46abb2034277633405479a4ab790c381e)
1908eaf68SStefan Hajnoczi#!/bin/bash
22557d865SKevin Wolf#
32557d865SKevin Wolf# Simple backing file reads
42557d865SKevin Wolf#
52557d865SKevin Wolf# Copyright (C) 2009 Red Hat, Inc.
62557d865SKevin Wolf#
72557d865SKevin Wolf# This program is free software; you can redistribute it and/or modify
82557d865SKevin Wolf# it under the terms of the GNU General Public License as published by
92557d865SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
102557d865SKevin Wolf# (at your option) any later version.
112557d865SKevin Wolf#
122557d865SKevin Wolf# This program is distributed in the hope that it will be useful,
132557d865SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
142557d865SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
152557d865SKevin Wolf# GNU General Public License for more details.
162557d865SKevin Wolf#
172557d865SKevin 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/>.
192557d865SKevin Wolf#
202557d865SKevin Wolf
212557d865SKevin Wolf# creator
222557d865SKevin Wolfowner=kwolf@redhat.com
232557d865SKevin Wolf
242557d865SKevin Wolfseq=`basename $0`
252557d865SKevin Wolfecho "QA output created by $seq"
262557d865SKevin Wolf
272557d865SKevin Wolfhere=`pwd`
282557d865SKevin Wolfstatus=1	# failure is the default!
292557d865SKevin Wolf
302557d865SKevin Wolf_cleanup()
312557d865SKevin Wolf{
322557d865SKevin Wolf	_cleanup_test_img
332557d865SKevin Wolf}
342557d865SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
352557d865SKevin Wolf
362557d865SKevin Wolf# get standard environment, filters and checks
372557d865SKevin Wolf. ./common.rc
382557d865SKevin Wolf. ./common.filter
392557d865SKevin Wolf. ./common.pattern
402557d865SKevin Wolf
412557d865SKevin Wolf# Any format supporting backing files
42f5a4bbd9SStefan Hajnoczi_supported_fmt qcow qcow2 vmdk qed
439cdfa1b3SMORITA Kazutaka_supported_proto generic
44*a98f49f4SJeff Cody_unsupported_proto vxhs
452557d865SKevin Wolf_supported_os Linux
46d2329f27SFam Zheng_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
472557d865SKevin Wolf
482557d865SKevin WolfTEST_OFFSETS="0 4294967296"
492557d865SKevin Wolf
50794d00f7SFam ZhengTEST_IMG_SAVE=$TEST_IMG
51794d00f7SFam ZhengTEST_IMG=$TEST_IMG.base
522557d865SKevin Wolf_make_test_img 6G
532557d865SKevin Wolf
542557d865SKevin Wolfecho "Filling base image"
552557d865SKevin Wolfecho
562557d865SKevin Wolf
572557d865SKevin Wolffor offset in $TEST_OFFSETS; do
582557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
592557d865SKevin Wolf    io writev $(( offset )) 512 1024 64
602557d865SKevin Wolf
612557d865SKevin Wolf    # Complete backing clusters
622557d865SKevin Wolf    io writev $(( offset  + 64 * 1024))  65536 65536 1
632557d865SKevin Wolfdone
642557d865SKevin Wolf_check_test_img
652557d865SKevin Wolf
662557d865SKevin Wolfecho "Creating test image with backing file"
672557d865SKevin Wolfecho
682557d865SKevin Wolf
69794d00f7SFam ZhengTEST_IMG=$TEST_IMG_SAVE
7002cde168SJeff Cody_make_test_img -b "$TEST_IMG.base" 6G
712557d865SKevin Wolf
722557d865SKevin Wolfecho "Filling test image"
732557d865SKevin Wolfecho
742557d865SKevin Wolf
752557d865SKevin Wolffor offset in $TEST_OFFSETS; do
762557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
772557d865SKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
782557d865SKevin Wolf
792557d865SKevin Wolf    # Complete test image clusters
802557d865SKevin Wolf    io writev $(( offset + 64 * 1024 + 65536))  65536 65536 1
812557d865SKevin Wolfdone
822557d865SKevin Wolf_check_test_img
832557d865SKevin Wolf
842557d865SKevin Wolfecho "Reading"
852557d865SKevin Wolfecho
862557d865SKevin Wolf
872557d865SKevin Wolffor offset in $TEST_OFFSETS; do
882557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
892557d865SKevin Wolf    io readv $(( offset )) 512 1024 64
902557d865SKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
912557d865SKevin Wolf
922557d865SKevin Wolf    # Complete test image clusters
932557d865SKevin Wolf    io readv $(( offset  + 64 * 1024))  65536 65536 1
942557d865SKevin Wolf    io readv $(( offset + 64 * 1024 + 65536))  65536 65536 1
952557d865SKevin Wolf
962557d865SKevin Wolf    # Empty sectors
972557d865SKevin Wolf    io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1
982557d865SKevin Wolfdone
992557d865SKevin Wolf_check_test_img
1002557d865SKevin Wolf
1012557d865SKevin Wolf# success, all done
1022557d865SKevin Wolfecho "*** done"
1032557d865SKevin Wolfrm -f $seq.full
1042557d865SKevin Wolfstatus=0
105