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