4 # Produce an I/O error in file-posix, and hope that it is not catastrophic.
5 # Regression test for: https://bugzilla.redhat.com/show_bug.cgi?id=2234374
7 # Copyright (C) 2023 Red Hat, Inc.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 echo "QA output created by $seq"
26 status
=1 # failure is the default!
31 rm -f "$TEST_DIR/fuse-export"
33 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # get standard environment, filters and checks
40 # Format-agnostic (we do not use any), but we do test the file protocol
42 _require_drivers blkdebug null-co
44 if [ "$IMGOPTSSYNTAX" = "true" ]; then
45 # We need `$QEMU_IO -f file` to work; IMGOPTSSYNTAX uses --image-opts,
47 _unsupported_fmt
$IMGFMT
50 # This is a regression test of a bug in which flie-posix would access zone
51 # information in case of an I/O error even when there is no zone information,
52 # resulting in a division by zero.
53 # To reproduce the problem, we need to trigger an I/O error inside of
54 # file-posix, which can be done (rootless) by providing a FUSE export that
55 # presents only errors when accessed.
58 _send_qemu_cmd
$QEMU_HANDLE \
59 "{'execute': 'qmp_capabilities'}" \
62 _send_qemu_cmd
$QEMU_HANDLE \
63 "{'execute': 'blockdev-add',
67 'inject-error': [{'event': 'none'}],
74 # FUSE mountpoint must exist and be a regular file
75 touch "$TEST_DIR/fuse-export"
77 # The grep -v to filter fusermount's (benign) error when /etc/fuse.conf does
78 # not contain user_allow_other and the subsequent check for missing FUSE support
79 # have both been taken from iotest 308.
80 output
=$
(_send_qemu_cmd
$QEMU_HANDLE \
81 "{'execute': 'block-export-add',
86 'mountpoint': '$TEST_DIR/fuse-export',
90 |
grep -v 'option allow_other only allowed if')
92 if echo "$output" |
grep -q "Parameter 'type' does not accept value 'fuse'"; then
93 _notrun
'No FUSE support'
98 # This should fail, but gracefully, i.e. just print an I/O error, not crash.
99 $QEMU_IO -f file -c 'write 0 64M' "$TEST_DIR/fuse-export" | _filter_qemu_io
102 capture_events
=BLOCK_EXPORT_DELETED _send_qemu_cmd
$QEMU_HANDLE \
103 "{'execute': 'block-export-del',
104 'arguments': {'id': 'exp0'}}" \
107 _wait_event
$QEMU_HANDLE \
108 'BLOCK_EXPORT_DELETED'
110 _send_qemu_cmd
$QEMU_HANDLE \
111 "{'execute': 'blockdev-del',
112 'arguments': {'node-name': 'node0'}}" \