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