]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/038
iotest 134: test cluster-misaligned encrypted write
[mirror_qemu.git] / tests / qemu-iotests / 038
CommitLineData
11a82d14 1#!/usr/bin/env bash
0446919d
KW
2#
3# Test COW from backing files with AIO
4#
5# Copyright (C) 2012 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
22owner=kwolf@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
0446919d
KW
27status=1 # failure is the default!
28
29_cleanup()
30{
31 _cleanup_test_img
32}
33trap "_cleanup; exit \$status" 0 1 2 3 15
34
35# get standard environment, filters and checks
36. ./common.rc
37. ./common.filter
38
39_supported_fmt qcow2 qed
1f7bf7d0 40_supported_proto file
0446919d
KW
41_supported_os Linux
42
43CLUSTER_SIZE=2M
44size=128M
45
46echo
47echo "== creating backing file for COW tests =="
48
1b935e1d
FZ
49TEST_IMG_SAVE="$TEST_IMG"
50TEST_IMG="$TEST_IMG.base"
51
0446919d
KW
52_make_test_img $size
53
8cedcffd 54backing_io()
0446919d
KW
55{
56 local offset=$1
57 local sectors=$2
58 local op=$3
59 local pattern=0
60 local cur_sec=0
61
62 for i in $(seq 0 $((sectors - 1))); do
63 cur_sec=$((offset / 65536 + i))
64 pattern=$(( ( (cur_sec % 128) + (cur_sec / 128)) % 128 ))
65
66 echo "$op -P $pattern $((cur_sec * 64))k 64k"
67 done
68}
69
fef9c191 70backing_io 0 256 write | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
0446919d 71
1b935e1d 72TEST_IMG="$TEST_IMG_SAVE"
0446919d 73
fef9c191 74_make_test_img -b "$TEST_IMG.base" 6G
0446919d
KW
75
76echo
77echo "== Some concurrent requests touching the same cluster =="
78
8cedcffd 79overlay_io()
0446919d
KW
80{
81 # Start with a request touching two clusters
82 echo aio_write -P 0x80 2020k 80k
83
84 # Then add some requests all over the place
85 for i in $(seq 0 15; seq 17 31; seq 33 47); do
86 echo aio_write -P $((0x81 + i)) $((i * 128))k 64k
87 done
88
89 # Then backwards overwriting part of them
90 for i in $( (seq 0 15; seq 17 31; seq 33 47) | tac); do
91 echo aio_write -P $((0x81 + i)) $((i * 128 + 32))k 64k
92 done
93
94 # And finally crossing the next cluster boundary
95 echo aio_write -P 0x90 4080k 80k
96}
97
fef9c191 98overlay_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io |\
c21bddf2
HR
99 sed -e 's/bytes at offset [0-9]*/bytes at offset XXX/g' \
100 -e 's/qemu-io> //g' | paste - - | sort | tr '\t' '\n'
0446919d
KW
101
102echo
103echo "== Verify image content =="
104
8cedcffd 105verify_io()
0446919d
KW
106{
107 echo read -P 31 2016k 4k
108 echo read -P 0x80 2020k 80k
109 echo read -P 32 2100k 12k
110 echo read -P 33 2112k 64k
111
112 echo read -P 63 4064k 16k
113 echo read -P 0x90 4080k 80k
114 echo read -P 65 4160k 64k
115
116 for i in $(seq 0 15; seq 17 31; seq 33 47); do
117 echo read -P $((0x81 + i)) $((i * 128))k 96k
118 done
119
120 for i in $(seq 0 14; seq 16 30; seq 32 47); do
121 local cur_sec=$(( i * 2 + 1 ))
122 local pattern=$(( ( (cur_sec % 128) + (cur_sec / 128)) % 128 ))
123
124 echo read -P $pattern $((i * 128 + 96))k 32k
125 done
126}
127
fef9c191 128verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
0446919d
KW
129
130_check_test_img
131
132# success, all done
133echo "*** done"
134rm -f $seq.full
135status=0