]> Git Repo - qemu.git/blame - tests/qemu-iotests/028
iotests: Check dirty bitmap statistics in 124
[qemu.git] / tests / qemu-iotests / 028
CommitLineData
8268b767
SH
1#!/bin/bash
2#
3# Test that backing files can be smaller than the image
4#
5# Copyright (C) 2010 IBM, Corp.
6#
7# Based on 017:
8# Copyright (C) 2009 Red Hat, Inc.
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22#
23
24# creator
25[email protected]
26
27seq=`basename $0`
28echo "QA output created by $seq"
29
30here=`pwd`
8268b767
SH
31status=1 # failure is the default!
32
33_cleanup()
34{
ecfa1854 35 _cleanup_qemu
d40593dd
KW
36 rm -f "${TEST_IMG}.copy"
37 _cleanup_test_img
8268b767
SH
38}
39trap "_cleanup; exit \$status" 0 1 2 3 15
40
41# get standard environment, filters and checks
42. ./common.rc
43. ./common.filter
44. ./common.pattern
d40593dd 45. ./common.qemu
8268b767
SH
46
47# Any format supporting backing files except vmdk and qcow which do not support
48# smaller backing files.
f5a4bbd9 49_supported_fmt qcow2 qed
1f7bf7d0 50_supported_proto file
8268b767
SH
51_supported_os Linux
52
53# Choose a size that is not necessarily a cluster size multiple for image
54# formats that use clusters. This will ensure that the base image doesn't end
55# precisely on a cluster boundary (the easy case).
56image_size=$(( 4 * 1024 * 1024 * 1024 + 3 * 512 ))
57
58# The base image is smaller than the image file
59base_size=$(( image_size - 1024 * 1024 * 1024 ))
60
61offset=$(( base_size - 32 * 1024 ))
62
49557d65
FZ
63TEST_IMG_SAVE="$TEST_IMG"
64TEST_IMG="$TEST_IMG.base"
65
8268b767
SH
66_make_test_img $base_size
67
68echo "Filling base image"
69echo
70
71# Fill end of base image with a pattern, skipping every other sector
dd0c35d6 72io writev $offset 512 1024 32
8268b767
SH
73
74_check_test_img
75
76echo "Creating test image with backing file"
77echo
78
49557d65 79TEST_IMG="$TEST_IMG_SAVE"
fef9c191 80_make_test_img -b "$TEST_IMG.base" $image_size
8268b767
SH
81
82echo "Filling test image"
83echo
84
85# Write every other sector around where the base image ends
dd0c35d6 86io writev $(( offset + 512 )) 512 1024 64
8268b767
SH
87
88_check_test_img
89
90echo "Reading"
91echo
92
93# Base image sectors
dd0c35d6 94io readv $(( offset )) 512 1024 32
8268b767
SH
95
96# Image sectors
dd0c35d6 97io readv $(( offset + 512 )) 512 1024 64
8268b767
SH
98
99# Zero sectors beyond end of base image
dd0c35d6 100io_zero readv $(( offset + 32 * 1024 )) 512 1024 32
8268b767
SH
101
102_check_test_img
103
6ce2d77a 104# Rebase it on top of its base image
fef9c191 105$QEMU_IMG rebase -b "$TEST_IMG.base" "$TEST_IMG"
6ce2d77a 106
d40593dd
KW
107echo
108echo block-backup
109echo
110
111qemu_comm_method="monitor"
112_launch_qemu -drive file="${TEST_IMG}",cache=${CACHEMODE},id=disk
113h=$QEMU_HANDLE
114QEMU_COMM_TIMEOUT=1
115
8283c5c3 116# Silence output since it contains the disk image path and QEMU's readline
a174da36
EB
117# character echoing makes it very hard to filter the output. Plus, there
118# is no telling how many times the command will repeat before succeeding.
8283c5c3 119_send_qemu_cmd $h "drive_backup disk ${TEST_IMG}.copy" "(qemu)" >/dev/null
6ffb4cb6 120_send_qemu_cmd $h "" "Formatting" | _filter_img_create
a174da36
EB
121qemu_cmd_repeat=20 _send_qemu_cmd $h "info block-jobs" "No active jobs" >/dev/null
122_send_qemu_cmd $h "info block-jobs" "No active jobs"
d40593dd
KW
123_send_qemu_cmd $h 'quit' ""
124
125# Base image sectors
126TEST_IMG="${TEST_IMG}.copy" io readv $(( offset )) 512 1024 32
127
128# Image sectors
129TEST_IMG="${TEST_IMG}.copy" io readv $(( offset + 512 )) 512 1024 64
130
131# Zero sectors beyond end of base image
132TEST_IMG="${TEST_IMG}.copy" io_zero readv $(( offset + 32 * 1024 )) 512 1024 32
133
134
6ce2d77a
KW
135_check_test_img
136
8268b767
SH
137# success, all done
138echo "*** done"
139rm -f $seq.full
140status=0
This page took 0.37636 seconds and 4 git commands to generate.