Statistics
| Branch: | Revision:

root / tests / qemu-iotests / 032 @ 9a05feab

History | View | Annotate | Download (1.8 kB)

1 aafcdcc9 Kevin Wolf
#!/bin/bash
2 aafcdcc9 Kevin Wolf
#
3 aafcdcc9 Kevin Wolf
# Test that AIO requests are drained before an image is closed. This used
4 aafcdcc9 Kevin Wolf
# to segfault because the request coroutine kept running even after the
5 aafcdcc9 Kevin Wolf
# BlockDriverState was freed.
6 aafcdcc9 Kevin Wolf
#
7 aafcdcc9 Kevin Wolf
# Copyright (C) 2011 Red Hat, Inc.
8 aafcdcc9 Kevin Wolf
#
9 aafcdcc9 Kevin Wolf
# This program is free software; you can redistribute it and/or modify
10 aafcdcc9 Kevin Wolf
# it under the terms of the GNU General Public License as published by
11 aafcdcc9 Kevin Wolf
# the Free Software Foundation; either version 2 of the License, or
12 aafcdcc9 Kevin Wolf
# (at your option) any later version.
13 aafcdcc9 Kevin Wolf
#
14 aafcdcc9 Kevin Wolf
# This program is distributed in the hope that it will be useful,
15 aafcdcc9 Kevin Wolf
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16 aafcdcc9 Kevin Wolf
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 aafcdcc9 Kevin Wolf
# GNU General Public License for more details.
18 aafcdcc9 Kevin Wolf
#
19 aafcdcc9 Kevin Wolf
# You should have received a copy of the GNU General Public License
20 aafcdcc9 Kevin Wolf
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 aafcdcc9 Kevin Wolf
#
22 aafcdcc9 Kevin Wolf
23 aafcdcc9 Kevin Wolf
# creator
24 aafcdcc9 Kevin Wolf
owner=kwolf@redhat.com
25 aafcdcc9 Kevin Wolf
26 aafcdcc9 Kevin Wolf
seq=`basename $0`
27 aafcdcc9 Kevin Wolf
echo "QA output created by $seq"
28 aafcdcc9 Kevin Wolf
29 aafcdcc9 Kevin Wolf
here=`pwd`
30 aafcdcc9 Kevin Wolf
tmp=/tmp/$$
31 aafcdcc9 Kevin Wolf
status=1	# failure is the default!
32 aafcdcc9 Kevin Wolf
33 aafcdcc9 Kevin Wolf
_cleanup()
34 aafcdcc9 Kevin Wolf
{
35 aafcdcc9 Kevin Wolf
	_cleanup_test_img
36 aafcdcc9 Kevin Wolf
}
37 aafcdcc9 Kevin Wolf
trap "_cleanup; exit \$status" 0 1 2 3 15
38 aafcdcc9 Kevin Wolf
39 aafcdcc9 Kevin Wolf
# get standard environment, filters and checks
40 aafcdcc9 Kevin Wolf
. ./common.rc
41 aafcdcc9 Kevin Wolf
. ./common.filter
42 aafcdcc9 Kevin Wolf
. ./common.pattern
43 aafcdcc9 Kevin Wolf
44 aafcdcc9 Kevin Wolf
# This works for any image format (though unlikely to segfault for raw)
45 aafcdcc9 Kevin Wolf
_supported_fmt generic
46 aafcdcc9 Kevin Wolf
_supported_proto generic
47 aafcdcc9 Kevin Wolf
_supported_os Linux
48 aafcdcc9 Kevin Wolf
49 aafcdcc9 Kevin Wolf
echo
50 aafcdcc9 Kevin Wolf
echo === Prepare image ===
51 aafcdcc9 Kevin Wolf
echo
52 aafcdcc9 Kevin Wolf
53 aafcdcc9 Kevin Wolf
CLUSTER_SIZE=65536
54 aafcdcc9 Kevin Wolf
_make_test_img 64M
55 aafcdcc9 Kevin Wolf
56 aafcdcc9 Kevin Wolf
# Allocate every other cluster so that afterwards a big write request will
57 aafcdcc9 Kevin Wolf
# actually loop a while and issue many I/O requests for the lower layer
58 fef9c191 Jeff Cody
for i in $(seq 0 128 4096); do echo "write ${i}k 64k"; done | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
59 aafcdcc9 Kevin Wolf
60 aafcdcc9 Kevin Wolf
echo
61 aafcdcc9 Kevin Wolf
echo === AIO request during close ===
62 aafcdcc9 Kevin Wolf
echo
63 fef9c191 Jeff Cody
$QEMU_IO -c "aio_write 0 4M" -c "close" "$TEST_IMG" | _filter_qemu_io
64 aafcdcc9 Kevin Wolf
_check_test_img
65 aafcdcc9 Kevin Wolf
66 aafcdcc9 Kevin Wolf
# success, all done
67 aafcdcc9 Kevin Wolf
echo "*** done"
68 aafcdcc9 Kevin Wolf
rm -f $seq.full
69 aafcdcc9 Kevin Wolf
status=0