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