]> Git Repo - qemu.git/blob - tests/qemu-iotests/024
qemu-iotests: explicitly use bash interpreter
[qemu.git] / tests / qemu-iotests / 024
1 #!/bin/bash
2 #
3 # Rebasing COW images
4 #
5 # Copyright (C) 2009 Red Hat, Inc.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 # creator
22 [email protected]
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1        # failure is the default!
30
31 _cleanup()
32 {
33         _cleanup_test_img
34         rm -f $TEST_DIR/t.$IMGFMT.base_old
35         rm -f $TEST_DIR/t.$IMGFMT.base_new
36 }
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42 . ./common.pattern
43
44 # Currently only qcow2 supports rebasing
45 _supported_fmt qcow2
46 _supported_os Linux
47
48 CLUSTER_SIZE=65536
49
50 # Cluster allocations to be tested:
51 #
52 # Backing (old) 11  --  11  --  11  --  11  --
53 # Backing (new) 22  22  --  --  22  22  --  --
54 # COW image     33  33  33  33  --  --  --  --
55
56 echo "Creating backing file"
57 echo
58
59 _make_test_img 1G
60 io_pattern writev $((-2 * CLUSTER_SIZE)) $CLUSTER_SIZE $((2 * CLUSTER_SIZE)) 4 0x11
61 mv $TEST_IMG $TEST_IMG.base_old
62
63 echo "Creating new backing file"
64 echo
65
66 _make_test_img 1G
67 io_pattern writev $((-4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 2 0x22
68 mv $TEST_IMG $TEST_IMG.base_new
69
70 echo "Creating COW image"
71 echo
72
73 _make_test_img -b $TEST_IMG.base_old 1G
74 io_pattern writev 0 $((4 * CLUSTER_SIZE)) 0 1 0x33
75
76 echo "Read before the rebase to make sure everything is set up correctly"
77 echo
78 io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
79 io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
80 io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
81 io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
82 io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
83 io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
84 io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
85 io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
86
87 echo
88 echo Rebase and test again
89 echo
90 $QEMU_IMG rebase -b $TEST_IMG.base_new $TEST_IMG
91 io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
92 io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
93 io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
94 io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
95 io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
96 io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
97 io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
98 io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
99
100
101 # success, all done
102 echo "*** done"
103 rm -f $seq.full
104 status=0
This page took 0.027543 seconds and 4 git commands to generate.