xref: /openbmc/qemu/tests/qemu-iotests/019 (revision e8c212d6824fbe5660b8653463f7a3b46fb34b80)
19128ae5eSKevin Wolf#!/bin/sh
29128ae5eSKevin Wolf#
39128ae5eSKevin Wolf# When using a backing file for the output image in qemu-img convert,
49128ae5eSKevin Wolf# the backing file clusters must not copied. The data must still be
59128ae5eSKevin Wolf# read correctly.
69128ae5eSKevin Wolf#
79128ae5eSKevin Wolf# Copyright (C) 2009 Red Hat, Inc.
89128ae5eSKevin Wolf#
99128ae5eSKevin Wolf# This program is free software; you can redistribute it and/or modify
109128ae5eSKevin Wolf# it under the terms of the GNU General Public License as published by
119128ae5eSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
129128ae5eSKevin Wolf# (at your option) any later version.
139128ae5eSKevin Wolf#
149128ae5eSKevin Wolf# This program is distributed in the hope that it will be useful,
159128ae5eSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
169128ae5eSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
179128ae5eSKevin Wolf# GNU General Public License for more details.
189128ae5eSKevin Wolf#
199128ae5eSKevin Wolf# You should have received a copy of the GNU General Public License
20*e8c212d6SChristoph Hellwig# along with this program.  If not, see <http://www.gnu.org/licenses/>.
219128ae5eSKevin Wolf#
229128ae5eSKevin Wolf
239128ae5eSKevin Wolf# creator
249128ae5eSKevin Wolfowner=kwolf@redhat.com
259128ae5eSKevin Wolf
269128ae5eSKevin Wolfseq=`basename $0`
279128ae5eSKevin Wolfecho "QA output created by $seq"
289128ae5eSKevin Wolf
299128ae5eSKevin Wolfhere=`pwd`
309128ae5eSKevin Wolftmp=/tmp/$$
319128ae5eSKevin Wolfstatus=1	# failure is the default!
329128ae5eSKevin Wolf
339128ae5eSKevin Wolf_cleanup()
349128ae5eSKevin Wolf{
359128ae5eSKevin Wolf	_cleanup_test_img
369128ae5eSKevin Wolf    rm -f $TEST_IMG.base
379128ae5eSKevin Wolf    rm -f $TEST_IMG.orig
389128ae5eSKevin Wolf}
399128ae5eSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
409128ae5eSKevin Wolf
419128ae5eSKevin Wolf# get standard environment, filters and checks
429128ae5eSKevin Wolf. ./common.rc
439128ae5eSKevin Wolf. ./common.filter
449128ae5eSKevin Wolf. ./common.pattern
459128ae5eSKevin Wolf
469128ae5eSKevin Wolf# Any format supporting backing files
479128ae5eSKevin Wolf_supported_fmt qcow qcow2 vmdk
489128ae5eSKevin Wolf_supported_os Linux
499128ae5eSKevin Wolf
509128ae5eSKevin WolfTEST_OFFSETS="0 4294967296"
519128ae5eSKevin Wolf
529128ae5eSKevin Wolf_make_test_img 6G
539128ae5eSKevin Wolf
549128ae5eSKevin Wolfecho "Filling base image"
559128ae5eSKevin Wolfecho
569128ae5eSKevin Wolf
579128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
589128ae5eSKevin Wolf    # Some clusters with alternating backing file/image file reads
599128ae5eSKevin Wolf    io writev $(( offset )) 512 1024 64
609128ae5eSKevin Wolf
619128ae5eSKevin Wolf    # Complete backing clusters
629128ae5eSKevin Wolf    io writev $(( offset  + 1024 * 1024))  65536 65536 1
639128ae5eSKevin Wolfdone
649128ae5eSKevin Wolf_check_test_img
659128ae5eSKevin Wolf
669128ae5eSKevin Wolfecho "Creating test image with backing file"
679128ae5eSKevin Wolfecho
689128ae5eSKevin Wolf
699128ae5eSKevin Wolfmv $TEST_IMG $TEST_IMG.base
709128ae5eSKevin Wolf_make_test_img -b $TEST_IMG.base 6G
719128ae5eSKevin Wolf
729128ae5eSKevin Wolfecho "Filling test image"
739128ae5eSKevin Wolfecho
749128ae5eSKevin Wolf
759128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
769128ae5eSKevin Wolf    # Some clusters with alternating backing file/image file reads
779128ae5eSKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
789128ae5eSKevin Wolf
799128ae5eSKevin Wolf    # Complete test image clusters
809128ae5eSKevin Wolf    io writev $(( offset + 1024 * 1024 + 65536))  65536 65536 1
819128ae5eSKevin Wolfdone
829128ae5eSKevin Wolf_check_test_img
839128ae5eSKevin Wolf
849128ae5eSKevin Wolfmv $TEST_IMG $TEST_IMG.orig
859128ae5eSKevin Wolf$QEMU_IMG convert -O $IMGFMT -B $TEST_IMG.base $TEST_IMG.orig $TEST_IMG
869128ae5eSKevin Wolf
879128ae5eSKevin Wolfecho "Checking if backing clusters are allocated when they shouldn't"
889128ae5eSKevin Wolfecho
899128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
909128ae5eSKevin Wolf    # Complete backing clusters
919128ae5eSKevin Wolf    is_allocated $(( offset  + 1024 * 1024))  65536 65536 1
929128ae5eSKevin Wolfdone
939128ae5eSKevin Wolf
949128ae5eSKevin Wolfecho "Reading"
959128ae5eSKevin Wolfecho
969128ae5eSKevin Wolf
979128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
989128ae5eSKevin Wolf    # Some clusters with alternating backing file/image file reads
999128ae5eSKevin Wolf    io readv $(( offset )) 512 1024 64
1009128ae5eSKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
1019128ae5eSKevin Wolf
1029128ae5eSKevin Wolf    # Complete test image clusters
1039128ae5eSKevin Wolf    io readv $(( offset  + 1024 * 1024))  65536 65536 1
1049128ae5eSKevin Wolf    io readv $(( offset + 1024 * 1024 + 65536))  65536 65536 1
1059128ae5eSKevin Wolf
1069128ae5eSKevin Wolf    # Empty sectors
1079128ae5eSKevin Wolf    io_zero readv $(( offset + 1024 * 1024 + 65536 * 4 )) 65536 65536 1
1089128ae5eSKevin Wolfdone
1099128ae5eSKevin Wolf_check_test_img
1109128ae5eSKevin Wolf
1119128ae5eSKevin Wolf# success, all done
1129128ae5eSKevin Wolfecho "*** done"
1139128ae5eSKevin Wolfrm -f $seq.full
1149128ae5eSKevin Wolfstatus=0
115