024 4.2 KB
Newer Older
1
#!/bin/bash
K
Kevin Wolf 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#
# Rebasing COW images
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# creator
owner=kwolf@redhat.com

seq=`basename $0`
echo "QA output created by $seq"

here=`pwd`
status=1	# failure is the default!

_cleanup()
{
	_cleanup_test_img
33 34
	rm -f "$TEST_DIR/t.$IMGFMT.base_old"
	rm -f "$TEST_DIR/t.$IMGFMT.base_new"
K
Kevin Wolf 已提交
35 36 37 38 39 40 41 42
}
trap "_cleanup; exit \$status" 0 1 2 3 15

# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.pattern

43 44
# Currently only qcow2 and qed support rebasing
_supported_fmt qcow2 qed
45
_supported_proto file
K
Kevin Wolf 已提交
46 47 48 49 50 51 52 53 54
_supported_os Linux

CLUSTER_SIZE=65536

# Cluster allocations to be tested:
#
# Backing (old) 11  --  11  --  11  --  11  --
# Backing (new) 22  22  --  --  22  22  --  --
# COW image     33  33  33  33  --  --  --  --
K
Kevin Wolf 已提交
55 56 57
#
# The pattern is written twice to have both an alloc -> non-alloc and a
# non-alloc -> alloc transition in the COW image.
K
Kevin Wolf 已提交
58 59 60 61

echo "Creating backing file"
echo

62 63 64
TEST_IMG_SAVE="$TEST_IMG"
TEST_IMG="$TEST_IMG.base_old"

K
Kevin Wolf 已提交
65
_make_test_img 1G
66
io_pattern writev 0 $CLUSTER_SIZE $((2 * CLUSTER_SIZE)) 8 0x11
67 68

TEST_IMG="$TEST_IMG_SAVE.base_new"
K
Kevin Wolf 已提交
69 70 71 72 73

echo "Creating new backing file"
echo

_make_test_img 1G
74
io_pattern writev 0 $((2 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 4 0x22
75 76 77


TEST_IMG="$TEST_IMG_SAVE"
K
Kevin Wolf 已提交
78 79 80 81

echo "Creating COW image"
echo

82
_make_test_img -b "$TEST_IMG.base_old" 1G
K
Kevin Wolf 已提交
83
io_pattern writev 0 $((4 * CLUSTER_SIZE)) 0 1 0x33
K
Kevin Wolf 已提交
84
io_pattern writev $((8 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 0 1 0x33
K
Kevin Wolf 已提交
85 86 87 88 89 90 91 92 93 94 95

echo "Read before the rebase to make sure everything is set up correctly"
echo
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
K
Kevin Wolf 已提交
96 97 98 99 100 101 102 103
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
K
Kevin Wolf 已提交
104 105 106 107

echo
echo Rebase and test again
echo
108
$QEMU_IMG rebase -b "$TEST_IMG.base_new" "$TEST_IMG"
K
Kevin Wolf 已提交
109 110 111 112 113 114 115 116
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
K
Kevin Wolf 已提交
117 118 119 120 121 122 123 124
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
K
Kevin Wolf 已提交
125 126 127 128 129 130


# success, all done
echo "*** done"
rm -f $seq.full
status=0