Skip to content

fdc: fix 2.88mb floppy diskette support

John Snow qemu-devel 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest12 patches 2 repliesIn review
  2. v412 patches 24 repliesSuperseded
  3. v311 patches 17 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v210 patches6 repliesSuperseded
v1 RFC10 patches16 repliesSuperseded

Changes in v5 from the cover letter

===

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12fdc: move pick_geometryhw/block/fdc.c+45 -450 replies
2/12fdc: reduce number of pick_geometry argumentshw/block/fdc.c+20 -300 replies
3/12fdc: add drive type qapi enumhw/block/fdc.c hw/i386/pc.c include/hw/block/fdc.h +1 more+66 -560 replies
4/12fdc: add disk fieldhw/block/fdc.c+3 -00 replies
5/12fdc: Throw an assertion on misconfigured fd_formats tablehw/block/fdc.c+3 -10 replies
6/12fdc: add pick_drivehw/block/fdc.c+46 -100 replies
7/12fdc: Add fallback optionhw/block/fdc.c hw/core/qdev-properties.c include/hw/qdev-properties.h+35 -20 replies
8/12fdc: add drive type optionhw/block/fdc.c+23 -30 replies
9/12fdc: add physical disk sizeshw/block/fdc.c+32 -80 replies
10/12fdc: rework pick_geometryhw/block/fdc.c+52 -202 replies
11/12qtest/fdc: Support for 2.88MB drivestests/fdc-test.c+1 -10 replies
12/12fdc: change auto fallback drive for ISA FDC to 288hw/block/fdc.c include/hw/compat.h+5 -10 replies

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/12R-b
2/12R-b
3/12R-b
4/12R-b
5/12R-b
6/12R-b
7/12R-b
8/12R-b
9/12R-b
10/12R-b
11/12R-b
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [Qemu-devel] [PATCH v5 00/12] fdc: fix 2.88mb floppy diskette support

Yes, it's been broken for ten years.
No, it's not a CVE.

The problem is that QEMU doesn't have a configuration option for the type of floppy drive you want. It determines that based on the type of diskette inserted at boot time.

If you don't insert one, it always chooses a 1.44MB type.

If you want to insert a 2.88MB floppy after boot, you simply cannot.

"Wow, who cares?"

Good question -- Unfortunately, the virtio-win floppy disk images that Red Hat/Fedora ship require a 2.88MB drive, so if you forgot to insert them at boot, you'd have to change your VM configuration and try again.

For a one-shot operation, that's kind of obnoxious -- it'd be nice to allow one to just insert the diskette on-demand.

"OK, What are you changing in this decades-old device?"

(1) Add a new property to allow users to specify what kind of drive they want without relying on magical guessing behavior. Choices are: 120, 144, 288, auto, and none.

120, 144 and 288 refer to 1.20MB, 1.44MB, and 2.88MB drives. auto refers to the auto-detect behavior QEMU currently has. none ... hides the drive. You probably don't want to use this, but it's there if you feel like creating a drive you can't use.

(2) Add a new "fallback" property for use with the "auto" drive type that allows us to specify the backup behavior, too. In most cases this property won't be needed, but it is provided for allowing QEMU to be fully backwards compatible.

(3) Add the concept of physical diskette size to QEMU, classifying 120-style diskettes as fundamentally different from 144 and 288 ones.

(4) Revamp the automatic guessing heuristic to understand that 2.88MB style drives can accept 1.44MB diskettes.

(5) Change the automatic fallback type for the automatic guessing heuristic from 1.44MB to 2.88MB for 2.6 machines and beyond, leaving 2.5- machines set to default to auto/144.

(6) A lot of code cleanup in general.

"Won't this break everything, you madman?"

No: I tested this in MS-DOS 6.22, Fedora 23 and Windows 8.1. All seemed perfectly happy with 2.88MB drives as the default for 1.44 or 2.88MB floppy diskette images.

And: Older machine types will happily still default to the 1.44
type just like they used to, so really nothing should change at all for most guests.

If there ARE any guests affected in 2.6+ machine types, you are urged to use an explicit drive type that matches your application if the automatic behavior is unsuitable.

===
v5:
===

Nearly identical to v4.

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/12:[----] [--] 'fdc: move pick_geometry'
002/12:[----] [--] 'fdc: reduce number of pick_geometry arguments' 003/12:[0002] [FC] 'fdc: add drive type qapi enum'
004/12:[----] [--] 'fdc: add disk field'
005/12:[----] [--] 'fdc: Throw an assertion on misconfigured fd_formats table' 006/12:[----] [--] 'fdc: add pick_drive'
007/12:[----] [--] 'fdc: Add fallback option'
008/12:[0002] [FC] 'fdc: add drive type option'
009/12:[0002] [FC] 'fdc: add physical disk sizes'
010/12:[0031] [FC] 'fdc: rework pick_geometry'
011/12:[----] [--] 'qtest/fdc: Support for 2.88MB drives' 012/12:[----] [--] 'fdc: change auto fallback drive for ISA FDC to 288'

03: Fixed 1.5MB typo to say 1.2MB.
08: Removed extraneous parentheses.
09: Fixed sector count comment to be 1440 instead of 1400. 10: Removed what was match type #3 and replaced it with a warning.
Updated some comments.

===
v4:
===

Hopefully a more logical patch order with smaller changes.

02: Kept both debug printfs in fd_revalidate.
03: New patch, QAPI enumeration change only.
04: Re-ordered FDrive fields
Fallout from 03.
05: New patch.
06: Almost completely re-done.
07: Added media_validated property
Fallout from patch re-ordering.
08: Re-ordered.
10: Changed return type of pick_geometry to int.
Changed one error pathway to abort, as it's not a run-time problem.
12: Rebased on top of current master.

===
v3:
===

04: Remove typeA/typeB members of FDCtrl. Store e.g. -fdtypeA options
directly into FDCtrl.drives[x].drive instead.
05: Add a new fallback= option that controls fdtype{A,B}=auto behavior. 07: replace get_default_drive_type which is no longer needed
add get_fallback_drive_type.
09: Reworked the auto/fallback section of pick_geometry.

________________________________________________________________________________

For convenience, this branch is available at:
https://github.com/jnsnow/qemu.git branch fdc-default
https://github.com/jnsnow/qemu/tree/fdc-default

This version is tagged fdc-default-v5:
https://github.com/jnsnow/qemu/releases/tag/fdc-default-v5

John Snow (12):
fdc: move pick_geometry
fdc: reduce number of pick_geometry arguments
fdc: add drive type qapi enum
fdc: add disk field
fdc: Throw an assertion on misconfigured fd_formats table
fdc: add pick_drive
fdc: Add fallback option
fdc: add drive type option
fdc: add physical disk sizes
fdc: rework pick_geometry
qtest/fdc: Support for 2.88MB drives
fdc: change auto fallback drive for ISA FDC to 288

 hw/block/fdc.c               | 326 ++++++++++++++++++++++++++++++-------------
 hw/core/qdev-properties.c    |  11 ++
 hw/i386/pc.c                 |  17 +--
 include/hw/block/fdc.h       |   9 +-
 include/hw/compat.h          |   4 +
 include/hw/qdev-properties.h |   1 +
 qapi/block.json              |  16 +++
 tests/fdc-test.c             |   2 +-
 8 files changed, 270 insertions(+), 116 deletions(-)
Signature · 1 line
2.4.3