02b83f7d7c
Use of -global to set a default backend for non-singleton devices is a bad idea. But as long as we permit it, we better test it. Test output demonstrates we screw up when -global floppy clashes with -fda or with -device floppy: according to "info qtree", only the latter backend is attached, but according to "info block", both are. Here's the clash with -device: Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global floppy.drive=none0 -device floppy,drive=none1,unit=0 dev: isa-fdc, id "" [...] driveA = "" driveB = "" [...] bus: floppy-bus.0 type floppy-bus dev: floppy, id "" unit = 0 (0x0) ---> drive = "none1" [...] none0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2) ---> Attached to: /machine/peripheral-anon/device[0] Cache mode: writeback none1 (NODE_NAME): TEST_DIR/t.qcow2.2 (qcow2) ---> Attached to: /machine/peripheral-anon/device[0] Removable device: not locked, tray closed Cache mode: writeback /machine/peripheral-anon/device[0] is the floppy created with -device. Test output further demonstrates the "Drive 'FOO' is already in use because it has been automatically connected to another device" error message can be misleading. With '-fda "" -global floppy.drive=floppy0', it's in use because -global reuses -fda's backend. There is no other device involved. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200622094227.1271650-4-armbru@redhat.com>
271 lines
9.0 KiB
Bash
Executable File
271 lines
9.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Test floppy configuration
|
|
#
|
|
# Copyright (C) 2016 Red Hat, Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
# creator
|
|
owner=kwolf@redhat.com
|
|
|
|
seq=`basename $0`
|
|
echo "QA output created by $seq"
|
|
|
|
status=1 # failure is the default!
|
|
|
|
_cleanup()
|
|
{
|
|
_cleanup_test_img
|
|
_rm_test_img "$TEST_IMG.2"
|
|
_rm_test_img "$TEST_IMG.3"
|
|
}
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common.rc
|
|
. ./common.filter
|
|
|
|
_supported_fmt qcow2
|
|
_supported_proto file
|
|
_supported_os Linux
|
|
|
|
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
|
|
_notrun "Requires a PC machine"
|
|
fi
|
|
|
|
do_run_qemu()
|
|
{
|
|
(
|
|
if ! test -t 0; then
|
|
while read cmd; do
|
|
echo $cmd
|
|
done
|
|
fi
|
|
echo quit
|
|
) | $QEMU -accel qtest -nographic -monitor stdio -serial none "$@"
|
|
echo
|
|
}
|
|
|
|
check_floppy_qtree()
|
|
{
|
|
echo
|
|
echo Testing: "$@" | _filter_testdir
|
|
|
|
# QEMU_OPTIONS contains -nodefaults, we don't want that here because the
|
|
# defaults are part of what should be checked here.
|
|
#
|
|
# Apply the sed filter to stdout only, but keep the stderr output and
|
|
# filter the qemu program name in it.
|
|
printf "info qtree\ninfo block\n" |
|
|
(QEMU_OPTIONS="" do_run_qemu "$@" |
|
|
_filter_testdir |_filter_generated_node_ids | _filter_hmp |
|
|
sed -ne '/^ dev: isa-fdc/,/^ dev:/{x;p};/^[a-z][^ ]* (NODE_NAME):* /,/^(qemu)$/{p}') 2>&1 |
|
|
_filter_win32 | _filter_qemu
|
|
}
|
|
|
|
check_cache_mode()
|
|
{
|
|
echo "info block none0" |
|
|
QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |
|
|
_filter_win32 | _filter_qemu | grep "Cache mode"
|
|
}
|
|
|
|
|
|
size=720k
|
|
|
|
_make_test_img $size
|
|
|
|
TEST_IMG="$TEST_IMG.2" _make_test_img $size
|
|
TEST_IMG="$TEST_IMG.3" _make_test_img $size
|
|
|
|
# Default drive semantics:
|
|
#
|
|
# By default you get a single empty floppy drive. You can override it with
|
|
# -drive and using the same index, but if you use -drive to add a floppy to a
|
|
# different index, you get both of them. However, as soon as you use any
|
|
# '-device floppy', even to a different slot, the default drive is disabled.
|
|
|
|
echo
|
|
echo
|
|
echo === Default ===
|
|
|
|
check_floppy_qtree
|
|
|
|
echo
|
|
echo
|
|
echo === Using -fda/-fdb options ===
|
|
|
|
check_floppy_qtree -fda "$TEST_IMG"
|
|
check_floppy_qtree -fdb "$TEST_IMG"
|
|
check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2"
|
|
check_floppy_qtree -fdb ""
|
|
|
|
|
|
echo
|
|
echo
|
|
echo === Using -drive options ===
|
|
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG"
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG.2",index=1
|
|
|
|
echo
|
|
echo
|
|
echo === Using -drive if=none and -global ===
|
|
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
|
|
|
|
echo
|
|
echo
|
|
echo === Using -drive if=none and -device ===
|
|
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-device floppy,drive=none0 -device floppy,drive=none1,unit=1
|
|
|
|
echo
|
|
echo
|
|
echo === Mixing -fdX and -global ===
|
|
|
|
# Working
|
|
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
|
|
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
|
|
|
|
# Conflicting (-fdX wins)
|
|
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
|
|
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
|
|
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global floppy.drive=none0
|
|
|
|
echo
|
|
echo
|
|
echo === Mixing -fdX and -device ===
|
|
|
|
# Working
|
|
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
|
|
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
|
|
|
|
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
|
|
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
|
|
|
|
# Conflicting
|
|
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
|
|
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
|
|
|
|
echo
|
|
echo
|
|
echo === Mixing -drive and -device ===
|
|
|
|
# Working
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
|
|
|
|
# Conflicting
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
|
|
|
|
echo
|
|
echo
|
|
echo === Mixing -global and -device ===
|
|
|
|
# Working
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveA=none0 -device floppy,drive=none1
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
|
|
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveB=none0 -device floppy,drive=none1
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" \
|
|
-global floppy.drive=none0 -device floppy,unit=0
|
|
|
|
# Conflicting
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
|
|
-global floppy.drive=none0 -device floppy,drive=none1,unit=0
|
|
|
|
echo
|
|
echo
|
|
echo === Attempt to use drive twice ===
|
|
|
|
# if=none
|
|
check_floppy_qtree -drive if=none -device floppy,drive=none0 -device floppy -device floppy,drive=none0
|
|
check_floppy_qtree -drive if=none -global floppy.drive=none0 -device floppy -device floppy
|
|
# if=floppy
|
|
check_floppy_qtree -fda "" -device floppy,drive=floppy0
|
|
check_floppy_qtree -fda "" -global floppy.drive=floppy0
|
|
# default if=floppy (not found, because it's created later)
|
|
check_floppy_qtree -device floppy,drive=floppy0
|
|
|
|
echo
|
|
echo
|
|
echo === Too many floppy drives ===
|
|
|
|
# Working
|
|
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
|
|
-drive if=none,file="$TEST_IMG.2" \
|
|
-drive if=none,file="$TEST_IMG.3" \
|
|
-global isa-fdc.driveB=none0 \
|
|
-device floppy,drive=none1
|
|
|
|
echo
|
|
echo
|
|
echo === Creating an empty drive with anonymous BB ===
|
|
|
|
check_floppy_qtree -device floppy
|
|
check_floppy_qtree -device floppy,drive-type=120
|
|
check_floppy_qtree -device floppy,drive-type=144
|
|
check_floppy_qtree -device floppy,drive-type=288
|
|
|
|
echo
|
|
echo
|
|
echo === Try passing different drive size with image ===
|
|
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
|
|
|
|
echo
|
|
echo
|
|
echo === Try passing different block sizes ===
|
|
|
|
# Explicitly setting the default is okay
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
|
|
|
|
# Changing it is not
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
|
|
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
|
|
|
|
echo
|
|
echo
|
|
echo === Writethrough caching ===
|
|
|
|
check_cache_mode -device floppy,drive=none0
|
|
check_cache_mode -device floppy,drive=none0,write-cache=on
|
|
check_cache_mode -device floppy,drive=none0,write-cache=off
|
|
|
|
# success, all done
|
|
echo "*** done"
|
|
rm -f $seq.full
|
|
status=0
|