In a recent discussion on the mailing list regarding the introduction of
the BLOCK_TRAY_OPEN and BLOCK_TRAY_CLOSE events[1], it was mentioned that
we need to fix the eject command and maybe introduce new commands first.

Here's a my proposal.

This series introduces three new commands:

 o blockdev-tray-open: opens the drive tray. Also Supports removing the inserted
   media. The BLOCK_TRAY_OPEN event is emitted if this command succeeds.
 o blockdev-tray-close: closes a drive tray. The BLOCK_TRAY_CLOSE event is
   emitted.
 o blockdev-media-insert: Inserts a media in the tray. The tray must empty
   and already opened. No event is emitted.

The existing 'eject' and 'change' commands are completely rewriten in terms
of the new commands. Besides fixing some bad behaviors, this also makes it
possible for the events to be automtically emitted.

Ejecting a device inside the guest (or closing its tray) also causes the
events to be emitted.

Everything which applies for the virtual tray seems to work as expected for
the host's tray. But more testing is needed.

 QMP/qmp-events.txt |   30 ++++++++++
 block.c            |   36 +++++++++++-
 block.h            |    6 +-
 block/raw.c        |    2 +-
 blockdev.c         |  157 ++++++++++++++++++++++++++++++++++++++++------------
 blockdev.h         |    3 +
 hw/ide/atapi.c     |    2 +-
 hw/ide/core.c      |    6 +-
 hw/scsi-disk.c     |    8 +-
 hw/virtio-blk.c    |    6 +-
 monitor.c          |    6 ++
 monitor.h          |    2 +
 qmp-commands.hx    |   84 ++++++++++++++++++++++++++++
 13 files changed, 294 insertions(+), 54 deletions(-)

Reply via email to