111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Wolfstatus=1 # failure is the default! 30aafcdcc9SKevin Wolf 31aafcdcc9SKevin Wolf_cleanup() 32aafcdcc9SKevin Wolf{ 33aafcdcc9SKevin Wolf _cleanup_test_img 34aafcdcc9SKevin Wolf} 35aafcdcc9SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36aafcdcc9SKevin Wolf 37aafcdcc9SKevin Wolf# get standard environment, filters and checks 38aafcdcc9SKevin Wolf. ./common.rc 39aafcdcc9SKevin Wolf. ./common.filter 40aafcdcc9SKevin Wolf. ./common.pattern 41aafcdcc9SKevin Wolf 42aafcdcc9SKevin Wolf# This works for any image format (though unlikely to segfault for raw) 43aafcdcc9SKevin Wolf_supported_fmt generic 44aafcdcc9SKevin Wolf_supported_proto generic 45*325dd915SMax Reitz_unsupported_imgopts "subformat=streamOptimized" 46aafcdcc9SKevin Wolf 47aafcdcc9SKevin Wolfecho 48aafcdcc9SKevin Wolfecho === Prepare image === 49aafcdcc9SKevin Wolfecho 50aafcdcc9SKevin Wolf 51aafcdcc9SKevin WolfCLUSTER_SIZE=65536 52aafcdcc9SKevin Wolf_make_test_img 64M 53aafcdcc9SKevin Wolf 54aafcdcc9SKevin Wolf# Allocate every other cluster so that afterwards a big write request will 55aafcdcc9SKevin Wolf# actually loop a while and issue many I/O requests for the lower layer 5630edd9faSThomas Huthfor ((i=0;i<=4096;i+=128)); do echo "write ${i}k 64k"; done | $QEMU_IO "$TEST_IMG" | _filter_qemu_io 57aafcdcc9SKevin Wolf 58aafcdcc9SKevin Wolfecho 59aafcdcc9SKevin Wolfecho === AIO request during close === 60aafcdcc9SKevin Wolfecho 61fef9c191SJeff Cody$QEMU_IO -c "aio_write 0 4M" -c "close" "$TEST_IMG" | _filter_qemu_io 62aafcdcc9SKevin Wolf_check_test_img 63aafcdcc9SKevin Wolf 64aafcdcc9SKevin Wolf# success, all done 65aafcdcc9SKevin Wolfecho "*** done" 66aafcdcc9SKevin Wolfrm -f $seq.full 67aafcdcc9SKevin Wolfstatus=0 68