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