1#!/usr/bin/env bash 2# group: rw auto quick 3# 4# Check that detect-zeroes=unmap works on writes with registered I/O buffers. 5# This is a regression test for 6# https://gitlab.com/qemu-project/qemu/-/issues/1404 where I/O requests failed 7# unexpectedly. 8# 9# Copyright Red Hat 10# 11# This program is free software; you can redistribute it and/or modify 12# it under the terms of the GNU General Public License as published by 13# the Free Software Foundation; either version 2 of the License, or 14# (at your option) any later version. 15# 16# This program is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19# GNU General Public License for more details. 20# 21# You should have received a copy of the GNU General Public License 22# along with this program. If not, see <http://www.gnu.org/licenses/>. 23# 24 25# creator 26owner=stefanha@redhat.com 27 28seq=`basename $0` 29echo "QA output created by $seq" 30 31status=1 # failure is the default! 32 33_cleanup() 34{ 35 _cleanup_test_img 36} 37trap "_cleanup; exit \$status" 0 1 2 3 15 38 39IMGOPTSSYNTAX=true 40 41# get standard environment, filters and checks 42cd .. 43. ./common.rc 44. ./common.filter 45 46_supported_fmt qcow2 47_supported_proto generic 48 49size=128M 50_make_test_img $size 51IMGSPEC="$TEST_IMG,discard=unmap,detect-zeroes=unmap" 52 53echo 54echo "== writing zero buffer to image ==" 55QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" $QEMU_IO -c "write -r -P 0 0 4k" --image-opts "$IMGSPEC" | _filter_qemu_io 56 57# success, all done 58echo "*** done" 59rm -f $seq.full 60status=0 61