xref: /openbmc/qemu/tests/qemu-iotests/019 (revision 9128ae5e617b67c95a27822a938bed1607119ba2)
1*9128ae5eSKevin Wolf#!/bin/sh
2*9128ae5eSKevin Wolf#
3*9128ae5eSKevin Wolf# When using a backing file for the output image in qemu-img convert,
4*9128ae5eSKevin Wolf# the backing file clusters must not copied. The data must still be
5*9128ae5eSKevin Wolf# read correctly.
6*9128ae5eSKevin Wolf#
7*9128ae5eSKevin Wolf# Copyright (C) 2009 Red Hat, Inc.
8*9128ae5eSKevin Wolf#
9*9128ae5eSKevin Wolf# This program is free software; you can redistribute it and/or modify
10*9128ae5eSKevin Wolf# it under the terms of the GNU General Public License as published by
11*9128ae5eSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
12*9128ae5eSKevin Wolf# (at your option) any later version.
13*9128ae5eSKevin Wolf#
14*9128ae5eSKevin Wolf# This program is distributed in the hope that it will be useful,
15*9128ae5eSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
16*9128ae5eSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*9128ae5eSKevin Wolf# GNU General Public License for more details.
18*9128ae5eSKevin Wolf#
19*9128ae5eSKevin Wolf# You should have received a copy of the GNU General Public License
20*9128ae5eSKevin Wolf# along with this program; if not, write to the Free Software
21*9128ae5eSKevin Wolf# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
22*9128ae5eSKevin Wolf# USA
23*9128ae5eSKevin Wolf#
24*9128ae5eSKevin Wolf
25*9128ae5eSKevin Wolf# creator
26*9128ae5eSKevin Wolfowner=kwolf@redhat.com
27*9128ae5eSKevin Wolf
28*9128ae5eSKevin Wolfseq=`basename $0`
29*9128ae5eSKevin Wolfecho "QA output created by $seq"
30*9128ae5eSKevin Wolf
31*9128ae5eSKevin Wolfhere=`pwd`
32*9128ae5eSKevin Wolftmp=/tmp/$$
33*9128ae5eSKevin Wolfstatus=1	# failure is the default!
34*9128ae5eSKevin Wolf
35*9128ae5eSKevin Wolf_cleanup()
36*9128ae5eSKevin Wolf{
37*9128ae5eSKevin Wolf	_cleanup_test_img
38*9128ae5eSKevin Wolf    rm -f $TEST_IMG.base
39*9128ae5eSKevin Wolf    rm -f $TEST_IMG.orig
40*9128ae5eSKevin Wolf}
41*9128ae5eSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
42*9128ae5eSKevin Wolf
43*9128ae5eSKevin Wolf# get standard environment, filters and checks
44*9128ae5eSKevin Wolf. ./common.rc
45*9128ae5eSKevin Wolf. ./common.filter
46*9128ae5eSKevin Wolf. ./common.pattern
47*9128ae5eSKevin Wolf
48*9128ae5eSKevin Wolf# Any format supporting backing files
49*9128ae5eSKevin Wolf_supported_fmt qcow qcow2 vmdk
50*9128ae5eSKevin Wolf_supported_os Linux
51*9128ae5eSKevin Wolf
52*9128ae5eSKevin WolfTEST_OFFSETS="0 4294967296"
53*9128ae5eSKevin Wolf
54*9128ae5eSKevin Wolf_make_test_img 6G
55*9128ae5eSKevin Wolf
56*9128ae5eSKevin Wolfecho "Filling base image"
57*9128ae5eSKevin Wolfecho
58*9128ae5eSKevin Wolf
59*9128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
60*9128ae5eSKevin Wolf    # Some clusters with alternating backing file/image file reads
61*9128ae5eSKevin Wolf    io writev $(( offset )) 512 1024 64
62*9128ae5eSKevin Wolf
63*9128ae5eSKevin Wolf    # Complete backing clusters
64*9128ae5eSKevin Wolf    io writev $(( offset  + 1024 * 1024))  65536 65536 1
65*9128ae5eSKevin Wolfdone
66*9128ae5eSKevin Wolf_check_test_img
67*9128ae5eSKevin Wolf
68*9128ae5eSKevin Wolfecho "Creating test image with backing file"
69*9128ae5eSKevin Wolfecho
70*9128ae5eSKevin Wolf
71*9128ae5eSKevin Wolfmv $TEST_IMG $TEST_IMG.base
72*9128ae5eSKevin Wolf_make_test_img -b $TEST_IMG.base 6G
73*9128ae5eSKevin Wolf
74*9128ae5eSKevin Wolfecho "Filling test image"
75*9128ae5eSKevin Wolfecho
76*9128ae5eSKevin Wolf
77*9128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
78*9128ae5eSKevin Wolf    # Some clusters with alternating backing file/image file reads
79*9128ae5eSKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
80*9128ae5eSKevin Wolf
81*9128ae5eSKevin Wolf    # Complete test image clusters
82*9128ae5eSKevin Wolf    io writev $(( offset + 1024 * 1024 + 65536))  65536 65536 1
83*9128ae5eSKevin Wolfdone
84*9128ae5eSKevin Wolf_check_test_img
85*9128ae5eSKevin Wolf
86*9128ae5eSKevin Wolfmv $TEST_IMG $TEST_IMG.orig
87*9128ae5eSKevin Wolf$QEMU_IMG convert -O $IMGFMT -B $TEST_IMG.base $TEST_IMG.orig $TEST_IMG
88*9128ae5eSKevin Wolf
89*9128ae5eSKevin Wolfecho "Checking if backing clusters are allocated when they shouldn't"
90*9128ae5eSKevin Wolfecho
91*9128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
92*9128ae5eSKevin Wolf    # Complete backing clusters
93*9128ae5eSKevin Wolf    is_allocated $(( offset  + 1024 * 1024))  65536 65536 1
94*9128ae5eSKevin Wolfdone
95*9128ae5eSKevin Wolf
96*9128ae5eSKevin Wolfecho "Reading"
97*9128ae5eSKevin Wolfecho
98*9128ae5eSKevin Wolf
99*9128ae5eSKevin Wolffor offset in $TEST_OFFSETS; do
100*9128ae5eSKevin Wolf    # Some clusters with alternating backing file/image file reads
101*9128ae5eSKevin Wolf    io readv $(( offset )) 512 1024 64
102*9128ae5eSKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
103*9128ae5eSKevin Wolf
104*9128ae5eSKevin Wolf    # Complete test image clusters
105*9128ae5eSKevin Wolf    io readv $(( offset  + 1024 * 1024))  65536 65536 1
106*9128ae5eSKevin Wolf    io readv $(( offset + 1024 * 1024 + 65536))  65536 65536 1
107*9128ae5eSKevin Wolf
108*9128ae5eSKevin Wolf    # Empty sectors
109*9128ae5eSKevin Wolf    io_zero readv $(( offset + 1024 * 1024 + 65536 * 4 )) 65536 65536 1
110*9128ae5eSKevin Wolfdone
111*9128ae5eSKevin Wolf_check_test_img
112*9128ae5eSKevin Wolf
113*9128ae5eSKevin Wolf# success, all done
114*9128ae5eSKevin Wolfecho "*** done"
115*9128ae5eSKevin Wolfrm -f $seq.full
116*9128ae5eSKevin Wolfstatus=0
117