qemu/hw/isa
Markus Armbruster 6172e067a4 fdc: Reject clash between -drive if=floppy and -global isa-fdc
The floppy controller devices desugar their drive properties into
floppy devices (since commit a92bd191a4 "fdc: Move qdev properties to
FloppyDrive", v2.8.0).  This involves some bad magic in
fdctrl_connect_drives(), and exists for backward compatibility.

The functions for boards to create floppy controller devices
fdctrl_init_isa(), fdctrl_init_sysbus(), and sun4m_fdctrl_init()
desugar -drive if=floppy to these floppy controller drive properties.

If you use both -drive if=floppy (or its -fda / -fdb sugar) and
-global isa-fdc for the same floppy device, -global silently loses the
conflict, and both backends involved end up with the floppy device
frontend attached, as demonstrated by iotest 172 (see commit before
previous).  This is wrong.

Desugar -drive if=floppy straight to floppy devices instead, with
helper fdctrl_init_drives().  The conflict now gets rejected cleanly:
first, fdctrl_connect_drives() creates the floppy for the controller's
property, then fdctrl_init_drives() attempts to create the floppy for
-drive if=floppy, but fails because the unit is already in use.

Output of iotest 172 changes in three ways:

1. The clash gets rejected.

2. In one test case, "info qtree" has the floppy devices swapped, and
   "info block" has their QOM paths swapped.  This is because the
   floppy device for -fda now gets created after the one for -global
   isa-fdc.driveB.

3. The error message for -global floppy.drive=floppy0 changes.  Before
   the patch, we set isa-fdc.driveA to -fda's block backend, then
   create the floppy device for it, then move the backend from
   isa-fdc.driveA to floppy.drive.  Floppy creation fails when
   applying -global floppy.drive=floppy0, because floppy0 is still
   attached to isa-fdc.  After the patch, we create the floppy for
   -fda, then set its drive property to floppy0.  Now floppy creation
   succeeds, but setting the drive property fails, because -global
   already set it.  Yes, this is exasperatingly complicated.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200622094227.1271650-5-armbru@redhat.com>
2020-06-23 16:07:07 +02:00
..
apm.c hw/isa/apm: Convert debug printf()s to trace events 2020-06-09 19:05:20 +02:00
i82378.c hw/isa/i82378: Remove dead assignment 2020-05-04 14:43:24 +02:00
isa-bus.c sysbus: Convert to sysbus_realize() etc. with Coccinelle 2020-06-15 22:05:28 +02:00
isa-superio.c fdc: Reject clash between -drive if=floppy and -global isa-fdc 2020-06-23 16:07:07 +02:00
Kconfig hw/input: Do not enable CONFIG_PCKBD by default 2020-02-04 09:01:31 +01:00
lpc_ich9.c Drop more @errp parameters after previous commit 2020-05-15 07:08:14 +02:00
Makefile.objs hw/pci-host/piix: Extract PIIX3 functions to hw/isa/piix3.c 2019-11-05 23:33:12 +01:00
pc87312.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
piix3.c accel: Move Xen accelerator code under accel/xen/ 2020-06-10 12:09:56 -04:00
piix4.c qdev: Convert uses of qdev_set_parent_bus() with Coccinelle 2020-06-15 22:05:08 +02:00
smc37c669-superio.c hw/isa/superio: Correct the license text 2020-04-01 19:00:16 +02:00
trace-events hw/isa/apm: Convert debug printf()s to trace events 2020-06-09 19:05:20 +02:00
vt82c686.c pci: Convert uses of pci_create() etc. with Coccinelle 2020-06-15 22:05:28 +02:00