This patch series looks bigger than it is. All the patches are small and hopefully easy to review.
Objectives: * Push BlockDriverState members locked, tray_open, media_changed into device models, where they belong. * BlockDriverState member removable is a confusing mess, replace it. * Improve eject -f. Also clean up minor messes as they get in the way. Part I: Preliminaries PATCH 01-09: Assorted block layer fixes and cleanup Part II: Move tray state to device models PATCH 10-18: IDE tray open/closed PATCH 19-22: SCSI tray open/closed PATCH 23-25: block layer kill tray_open PATCH 26-27: IDE tray lock PATCH 28-29: SCSI tray lock PATCH 30-32: block layer kill locked PATCH 33-35: IDE & SCSI synchronize physical tray on init PATCH 36-38: IDE & SCSI migrate tray state PATCH 39-41: block layer & fdc media_changed Part III: Replace removable PATCH 42-44 clean up inappopriate uses of removable PATCH 45-46 replace remaining users Part IV: Reduce unclean use of block_int.h PATCH 47-53 PART V: Improve eject -f PATCH 54-55 Naturally, I want all parts applied. But I did my best to make applying only a prefix workable, too. Review invited from: * Kevin, of course. * Amit, you might be interested in the ATAPI stuff. * Luiz, the following patches affect QMP's query-block: PATCH 23 "block: Show whether the guest ejected the medium in info block" and PATCH 45 "block: Clean up remaining users of "removable". * Juan, please review PATCH 37 "ide/atapi: Preserve tray state on migration", PATCH 38 "scsi-disk: Preserve tray state on migration", and PATCH 43 "savevm: Include writable devices with removable media". * Dimitry, have a look at PATCH 44 "spitz tosa: Simplify "drive is suitable for microdrive" test". * Stefano, have a look at PATCH 45, it affects "-drive if=xen". Testing * Linux boots, both from HD and CD. * For both IDE and SCSI: - info block reports tray state correctly - Guest locking the tray stops eject (without -f) and change - eject -f; change works even while tray is locked by guest - Physical tray state tracks the virtual one (file=/dev/sr0) - Reading /dev/sr0 with tray open behaves as before: IDE closes the tray and reads (matches bare metal), SCSI reports no medium - Tray state is migrated correctly (tested with savevm/loadvm) * Guest still notices CD media change (IDE only, SCSI doesn't work before or after my patches because GESN isn't implemented) * Migrating ide-cd to older version works when tray is closed and unlocked, else fails (tested with savevm/loadvm) * Migrating scsi-cd to older version fails * Linux detects fdc media change (from monitor) * savevm and loadvm snapshot read/write floppy * spitz and tosa initialize their microdrive as before (PATCH 44; tested with -S -M {spitz,tosa}, didn't actually try to boot) Not tested: * BlockDriver "host_floppy" Lack the hardware. Like pretty much everybody not running a computer museum. Is keeping BlockDriver "host_floppy" around still worth our while? If the answer is no, I'm happy to respin with PATCH 39-41 replaced by a single patch to remove it, and simplify block.c and hw/fdc.c. Markus Armbruster (55): blockdev: Make eject fail for non-removable drives even with -f block: Reset device model callbacks on detach block: Attach non-qdev devices as well block: Generalize change_cb() to BlockDevOps block: Split change_cb() into change_media_cb(), resize_cb() block/raw-win32: Drop disabled code for removable host devices block: Make BlockDriver method bdrv_set_locked() return void block: Make BlockDriver method bdrv_eject() return void block: Don't let locked flag prevent medium load ide: Update command code definitions as per ACS-2 Table B.2 ide: Clean up case label indentation in ide_exec_cmd() ide: Fix ATA command READ to set ATAPI signature for CD-ROM ide: Use a table to declare which drive kinds accept each command ide: Reject ATA commands specific to drive kinds ide/atapi: Clean up misleading name in cmd_start_stop_unit() ide/atapi: Track tray open/close state ide/atapi: Switch from BlockDriverState's tray_open to own scsi-disk: Reject CD-specific SCSI commands to disks scsi-disk: Factor out scsi_disk_emulate_start_stop() scsi-disk: Track tray open/close state block: Revert entanglement of bdrv_is_inserted() with tray status block: Drop tray status tracking, no longer used block: Show whether the guest ejected the medium in info block ide/atapi: Track tray locked state ide/atapi: Switch from BlockDriverState's locked to own tray_locked scsi-disk: Track tray locked state scsi-disk: Switch from BlockDriverState's locked to own tray_locked block: Leave enforcing tray lock to device models block: Drop medium lock tracking, ask device models instead block: Rename bdrv_set_locked() to bdrv_lock_medium() ide: Provide IDEDeviceInfo method exit() ide/atapi: Don't fail eject when tray is already open ide/atapi: Avoid physical/virtual tray state mismatch scsi-disk: Fix START_STOP to fail when it can't eject scsi-disk: Avoid physical/virtual tray state mismatch ide: Give vmstate structs internal linkage where possible ide/atapi: Preserve tray state on migration scsi-disk: Preserve tray state on migration block/raw: Fix to forward method bdrv_media_changed() block: Leave tracking media change to device models fdc: Make media change detection more robust block: Clean up bdrv_flush_all() savevm: Include writable devices with removable media spitz tosa: Simplify "drive is suitable for microdrive" test block: Clean up remaining users of "removable" block: Drop BlockDriverState member removable block: Move BlockConf & friends from block_int.h to block.h hw: Trim superfluous #include "block_int.h" block: Declare qemu_blockalign() in block.h, not block_int.h block: New bdrv_set_buffer_alignment() block: Reset buffer alignment on detach block: Move BlockDriverAIOCB & friends from block_int.h to block.h nbd: Clean up use of block_int.h block: New change_media_cb() parameter load ide/atapi scsi-disk: Make monitor eject -f, then change work block.c | 205 ++++++++++++++++++++++++++------------------------ block.h | 104 +++++++++++++++++++++++--- block/nbd.c | 1 + block/raw-posix.c | 30 +++----- block/raw-win32.c | 35 --------- block/raw.c | 18 +++-- block_int.h | 74 ++----------------- blockdev.c | 28 +++----- hw/fdc.c | 48 ++++++------ hw/ide/atapi.c | 58 +++++++-------- hw/ide/cmd646.c | 1 - hw/ide/core.c | 195 ++++++++++++++++++++++++++++++++++++----------- hw/ide/ich.c | 1 - hw/ide/internal.h | 199 +++++++++++++++++++++++++----------------------- hw/ide/isa.c | 1 - hw/ide/macio.c | 1 - hw/ide/microdrive.c | 1 - hw/ide/mmio.c | 1 - hw/ide/pci.c | 1 - hw/ide/piix.c | 1 - hw/ide/qdev.c | 30 +++++++ hw/ide/via.c | 1 - hw/lsi53c895a.c | 1 - hw/nand.c | 4 +- hw/onenand.c | 6 +- hw/pflash_cfi01.c | 1 + hw/pflash_cfi02.c | 1 + hw/qdev-properties.c | 6 +- hw/scsi-bus.c | 10 +++ hw/scsi-disk.c | 175 ++++++++++++++++++++++++++++++++++++++++--- hw/scsi-generic.c | 1 - hw/scsi.h | 5 +- hw/sd.c | 14 ++-- hw/spitz.c | 10 +-- hw/tosa.c | 10 +-- hw/usb-msd.c | 2 +- hw/virtio-blk.c | 15 ++-- hw/virtio.h | 2 +- hw/xen_disk.c | 1 + nbd.c | 1 + nbd.h | 2 - qmp-commands.hx | 1 + savevm.c | 4 +- trace-events | 2 +- 44 files changed, 792 insertions(+), 516 deletions(-) -- 1.7.2.3