]> Git Repo - qemu.git/blame - tests/qemu-iotests/024
target/mips: Remove stale TODO file
[qemu.git] / tests / qemu-iotests / 024
CommitLineData
11a82d14 1#!/usr/bin/env bash
9dd003a9 2# group: rw backing auto quick
939e1640
KW
3#
4# Rebasing COW images
5#
6# Copyright (C) 2009 Red Hat, Inc.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22# creator
23[email protected]
24
25seq=`basename $0`
26echo "QA output created by $seq"
27
939e1640
KW
28status=1 # failure is the default!
29
30_cleanup()
31{
28036a7f 32 _cleanup_test_img
f91ecbd7
HR
33 _rm_test_img "$TEST_DIR/t.$IMGFMT.base_old"
34 _rm_test_img "$TEST_DIR/t.$IMGFMT.base_new"
28036a7f 35
f91ecbd7
HR
36 _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT"
37 _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old"
38 _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new"
28036a7f 39 rmdir "$TEST_DIR/subdir" 2> /dev/null
939e1640
KW
40}
41trap "_cleanup; exit \$status" 0 1 2 3 15
42
43# get standard environment, filters and checks
44. ./common.rc
45. ./common.filter
46. ./common.pattern
47
f5a4bbd9
SH
48# Currently only qcow2 and qed support rebasing
49_supported_fmt qcow2 qed
1f7bf7d0 50_supported_proto file
939e1640
KW
51_supported_os Linux
52
53CLUSTER_SIZE=65536
54
55# Cluster allocations to be tested:
56#
57# Backing (old) 11 -- 11 -- 11 -- 11 --
58# Backing (new) 22 22 -- -- 22 22 -- --
59# COW image 33 33 33 33 -- -- -- --
d586bc63
KW
60#
61# The pattern is written twice to have both an alloc -> non-alloc and a
62# non-alloc -> alloc transition in the COW image.
939e1640
KW
63
64echo "Creating backing file"
65echo
66
f19f1189
FZ
67TEST_IMG_SAVE="$TEST_IMG"
68TEST_IMG="$TEST_IMG.base_old"
69
939e1640 70_make_test_img 1G
dd0c35d6 71io_pattern writev 0 $CLUSTER_SIZE $((2 * CLUSTER_SIZE)) 8 0x11
f19f1189
FZ
72
73TEST_IMG="$TEST_IMG_SAVE.base_new"
939e1640
KW
74
75echo "Creating new backing file"
76echo
77
78_make_test_img 1G
dd0c35d6 79io_pattern writev 0 $((2 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 4 0x22
f19f1189
FZ
80
81
82TEST_IMG="$TEST_IMG_SAVE"
939e1640
KW
83
84echo "Creating COW image"
85echo
86
b66ff2c2 87_make_test_img -b "$TEST_IMG.base_old" -F $IMGFMT 1G
939e1640 88io_pattern writev 0 $((4 * CLUSTER_SIZE)) 0 1 0x33
d586bc63 89io_pattern writev $((8 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 0 1 0x33
939e1640
KW
90
91echo "Read before the rebase to make sure everything is set up correctly"
92echo
93io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
94io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
95io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
96io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
97io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
98io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
99io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
100io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
d586bc63
KW
101io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
102io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
103io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
104io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
105io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
106io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
107io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
108io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
939e1640
KW
109
110echo
111echo Rebase and test again
112echo
b66ff2c2 113$QEMU_IMG rebase -b "$TEST_IMG.base_new" -F $IMGFMT "$TEST_IMG"
939e1640
KW
114io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
115io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
116io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
117io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
118io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
119io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
120io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
121io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
d586bc63
KW
122io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
123io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
124io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
125io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
126io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
127io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
128io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
129io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
939e1640 130
28036a7f
HR
131echo
132echo "=== Test rebase in a subdirectory of the working directory ==="
133echo
134
135# Clean up the old images beforehand so they do not interfere with
136# this test
137_cleanup
138
139mkdir "$TEST_DIR/subdir"
140
141# Relative to the overlay
142BASE_OLD_OREL="t.$IMGFMT.base_old"
143BASE_NEW_OREL="t.$IMGFMT.base_new"
144
145# Relative to $TEST_DIR (which is going to be our working directory)
146OVERLAY_WREL="subdir/t.$IMGFMT"
147
148BASE_OLD="$TEST_DIR/subdir/$BASE_OLD_OREL"
149BASE_NEW="$TEST_DIR/subdir/$BASE_NEW_OREL"
150OVERLAY="$TEST_DIR/$OVERLAY_WREL"
151
152# Test done here:
153#
154# Backing (old): 11 11 -- 11
155# Backing (new): -- 22 22 11
156# Overlay: -- -- -- --
157#
158# Rebasing works, we have verified that above. Here, we just want to
159# see that rebasing is done for the correct target backing file.
160
161TEST_IMG=$BASE_OLD _make_test_img 1M
162TEST_IMG=$BASE_NEW _make_test_img 1M
b66ff2c2 163TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD_OREL" -F $IMGFMT 1M
28036a7f
HR
164
165echo
166
167$QEMU_IO "$BASE_OLD" \
168 -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
169 -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \
170 | _filter_qemu_io
171
172$QEMU_IO "$BASE_NEW" \
173 -c "write -P 0x22 $((1 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
174 -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \
175 | _filter_qemu_io
176
177echo
178
179pushd "$TEST_DIR" >/dev/null
b66ff2c2 180$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" -F $IMGFMT "$OVERLAY_WREL"
28036a7f
HR
181popd >/dev/null
182
183# Verify the backing path is correct
b66ff2c2 184TEST_IMG=$OVERLAY _img_info | grep '^backing file:'
28036a7f
HR
185
186echo
187
188# Verify the data is correct
189$QEMU_IO "$OVERLAY" \
190 -c "read -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
191 -c "read -P 0x11 $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
192 -c "read -P 0x00 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
193 -c "read -P 0x11 $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
194 | _filter_qemu_io
195
196echo
197
198# Verify that cluster #3 is not allocated (because it is the same in
199# $BASE_OLD and $BASE_NEW)
200$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map
201
939e1640
KW
202
203# success, all done
204echo "*** done"
205rm -f $seq.full
206status=0
This page took 0.629679 seconds and 4 git commands to generate.