]> git.proxmox.com Git - mirror_qemu.git/commitdiff
ide/atapi: Track tray open/close state
authorMarkus Armbruster <armbru@redhat.com>
Tue, 6 Sep 2011 16:58:38 +0000 (18:58 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 12 Sep 2011 13:17:20 +0000 (15:17 +0200)
We already track it in BlockDriverState since commit 4be9762a.  As
discussed in that commit's message, we should track it in the device
device models instead, because it's device state.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/ide/atapi.c
hw/ide/internal.h

index cb0cdac42eb5d88d37db8d5759c90d20ead7d010..713b1fd1e50c6228a72f533ae72cc71cf1dc2d10 100644 (file)
@@ -521,7 +521,7 @@ static unsigned int event_status_media(IDEState *s,
     uint8_t event_code, media_status;
 
     media_status = 0;
-    if (s->bs->tray_open) {
+    if (s->tray_open) {
         media_status = MS_TRAY_OPEN;
     } else if (bdrv_is_inserted(s->bs)) {
         media_status = MS_MEDIA_PRESENT;
@@ -926,6 +926,10 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
         ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
         break;
     }
+
+    if (loej && !err) {
+        s->tray_open = !start;
+    }
 }
 
 static void cmd_mechanism_status(IDEState *s, uint8_t* buf)
index 111785294dcab78ced20c32ddd9e7ce6352c769b..8a9052ea53bf78504bef62e1405f17ae97d56bce 100644 (file)
@@ -442,6 +442,7 @@ struct IDEState {
     struct unreported_events events;
     uint8_t sense_key;
     uint8_t asc;
+    bool tray_open;
     uint8_t cdrom_changed;
     int packet_transfer_size;
     int elementary_transfer_size;