Statistics
| Branch: | Revision:

root / tests / qemu-iotests / 024 @ a8aec295

History | View | Annotate | Download (4.2 kB)

1 908eaf68 Stefan Hajnoczi
#!/bin/bash
2 939e1640 Kevin Wolf
#
3 939e1640 Kevin Wolf
# Rebasing COW images
4 939e1640 Kevin Wolf
#
5 939e1640 Kevin Wolf
# Copyright (C) 2009 Red Hat, Inc.
6 939e1640 Kevin Wolf
#
7 939e1640 Kevin Wolf
# This program is free software; you can redistribute it and/or modify
8 939e1640 Kevin Wolf
# it under the terms of the GNU General Public License as published by
9 939e1640 Kevin Wolf
# the Free Software Foundation; either version 2 of the License, or
10 939e1640 Kevin Wolf
# (at your option) any later version.
11 939e1640 Kevin Wolf
#
12 939e1640 Kevin Wolf
# This program is distributed in the hope that it will be useful,
13 939e1640 Kevin Wolf
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14 939e1640 Kevin Wolf
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 939e1640 Kevin Wolf
# GNU General Public License for more details.
16 939e1640 Kevin Wolf
#
17 939e1640 Kevin Wolf
# You should have received a copy of the GNU General Public License
18 939e1640 Kevin Wolf
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 939e1640 Kevin Wolf
#
20 939e1640 Kevin Wolf
21 939e1640 Kevin Wolf
# creator
22 939e1640 Kevin Wolf
owner=kwolf@redhat.com
23 939e1640 Kevin Wolf
24 939e1640 Kevin Wolf
seq=`basename $0`
25 939e1640 Kevin Wolf
echo "QA output created by $seq"
26 939e1640 Kevin Wolf
27 939e1640 Kevin Wolf
here=`pwd`
28 939e1640 Kevin Wolf
tmp=/tmp/$$
29 939e1640 Kevin Wolf
status=1	# failure is the default!
30 939e1640 Kevin Wolf
31 939e1640 Kevin Wolf
_cleanup()
32 939e1640 Kevin Wolf
{
33 939e1640 Kevin Wolf
	_cleanup_test_img
34 939e1640 Kevin Wolf
	rm -f $TEST_DIR/t.$IMGFMT.base_old
35 939e1640 Kevin Wolf
	rm -f $TEST_DIR/t.$IMGFMT.base_new
36 939e1640 Kevin Wolf
}
37 939e1640 Kevin Wolf
trap "_cleanup; exit \$status" 0 1 2 3 15
38 939e1640 Kevin Wolf
39 939e1640 Kevin Wolf
# get standard environment, filters and checks
40 939e1640 Kevin Wolf
. ./common.rc
41 939e1640 Kevin Wolf
. ./common.filter
42 939e1640 Kevin Wolf
. ./common.pattern
43 939e1640 Kevin Wolf
44 f5a4bbd9 Stefan Hajnoczi
# Currently only qcow2 and qed support rebasing
45 f5a4bbd9 Stefan Hajnoczi
_supported_fmt qcow2 qed
46 9cdfa1b3 MORITA Kazutaka
_supported_proto generic
47 939e1640 Kevin Wolf
_supported_os Linux
48 939e1640 Kevin Wolf
49 939e1640 Kevin Wolf
CLUSTER_SIZE=65536
50 939e1640 Kevin Wolf
51 939e1640 Kevin Wolf
# Cluster allocations to be tested:
52 939e1640 Kevin Wolf
#
53 939e1640 Kevin Wolf
# Backing (old) 11  --  11  --  11  --  11  --
54 939e1640 Kevin Wolf
# Backing (new) 22  22  --  --  22  22  --  --
55 939e1640 Kevin Wolf
# COW image     33  33  33  33  --  --  --  --
56 d586bc63 Kevin Wolf
#
57 d586bc63 Kevin Wolf
# The pattern is written twice to have both an alloc -> non-alloc and a
58 d586bc63 Kevin Wolf
# non-alloc -> alloc transition in the COW image.
59 939e1640 Kevin Wolf
60 939e1640 Kevin Wolf
echo "Creating backing file"
61 939e1640 Kevin Wolf
echo
62 939e1640 Kevin Wolf
63 939e1640 Kevin Wolf
_make_test_img 1G
64 dd0c35d6 Stefan Hajnoczi
io_pattern writev 0 $CLUSTER_SIZE $((2 * CLUSTER_SIZE)) 8 0x11
65 939e1640 Kevin Wolf
mv $TEST_IMG $TEST_IMG.base_old
66 939e1640 Kevin Wolf
67 939e1640 Kevin Wolf
echo "Creating new backing file"
68 939e1640 Kevin Wolf
echo
69 939e1640 Kevin Wolf
70 939e1640 Kevin Wolf
_make_test_img 1G
71 dd0c35d6 Stefan Hajnoczi
io_pattern writev 0 $((2 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 4 0x22
72 939e1640 Kevin Wolf
mv $TEST_IMG $TEST_IMG.base_new
73 939e1640 Kevin Wolf
74 939e1640 Kevin Wolf
echo "Creating COW image"
75 939e1640 Kevin Wolf
echo
76 939e1640 Kevin Wolf
77 939e1640 Kevin Wolf
_make_test_img -b $TEST_IMG.base_old 1G
78 939e1640 Kevin Wolf
io_pattern writev 0 $((4 * CLUSTER_SIZE)) 0 1 0x33
79 d586bc63 Kevin Wolf
io_pattern writev $((8 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 0 1 0x33
80 939e1640 Kevin Wolf
81 939e1640 Kevin Wolf
echo "Read before the rebase to make sure everything is set up correctly"
82 939e1640 Kevin Wolf
echo
83 939e1640 Kevin Wolf
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
84 939e1640 Kevin Wolf
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
85 939e1640 Kevin Wolf
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
86 939e1640 Kevin Wolf
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
87 939e1640 Kevin Wolf
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
88 939e1640 Kevin Wolf
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
89 939e1640 Kevin Wolf
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
90 939e1640 Kevin Wolf
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
91 d586bc63 Kevin Wolf
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
92 d586bc63 Kevin Wolf
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
93 d586bc63 Kevin Wolf
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
94 d586bc63 Kevin Wolf
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
95 d586bc63 Kevin Wolf
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
96 d586bc63 Kevin Wolf
io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
97 d586bc63 Kevin Wolf
io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
98 d586bc63 Kevin Wolf
io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
99 939e1640 Kevin Wolf
100 939e1640 Kevin Wolf
echo
101 939e1640 Kevin Wolf
echo Rebase and test again
102 939e1640 Kevin Wolf
echo
103 939e1640 Kevin Wolf
$QEMU_IMG rebase -b $TEST_IMG.base_new $TEST_IMG
104 939e1640 Kevin Wolf
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
105 939e1640 Kevin Wolf
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
106 939e1640 Kevin Wolf
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
107 939e1640 Kevin Wolf
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
108 939e1640 Kevin Wolf
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
109 939e1640 Kevin Wolf
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
110 939e1640 Kevin Wolf
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
111 939e1640 Kevin Wolf
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
112 d586bc63 Kevin Wolf
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
113 d586bc63 Kevin Wolf
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
114 d586bc63 Kevin Wolf
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
115 d586bc63 Kevin Wolf
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
116 d586bc63 Kevin Wolf
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
117 d586bc63 Kevin Wolf
io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
118 d586bc63 Kevin Wolf
io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
119 d586bc63 Kevin Wolf
io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
120 939e1640 Kevin Wolf
121 939e1640 Kevin Wolf
122 939e1640 Kevin Wolf
# success, all done
123 939e1640 Kevin Wolf
echo "*** done"
124 939e1640 Kevin Wolf
rm -f $seq.full
125 939e1640 Kevin Wolf
status=0