atapi: Explain why we need a 'media not present' state
authorAmit Shah <amit.shah@redhat.com>
Thu, 28 Apr 2011 14:34:41 +0000 (20:04 +0530)
committerKevin Wolf <kwolf@redhat.com>
Tue, 3 May 2011 09:29:21 +0000 (11:29 +0200)
After the re-org of the atapi code, it might not be intuitive for a
reader of the code to understand why we're inserting a 'media not
present' state between cd changes.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/ide/atapi.c

index 86b18d894cde345ca06451f42ae40b0c9ec710f7..58febc02859cacbcedb72e8875ec5d8a4e47383e 100644 (file)
@@ -1106,7 +1106,13 @@ void ide_atapi_cmd(IDEState *s)
         ide_atapi_cmd_check_status(s);
         return;
     }
-
+    /*
+     * When a CD gets changed, we have to report an ejected state and
+     * then a loaded state to guests so that they detect tray
+     * open/close and media change events.  Guests that do not use
+     * GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close
+     * states rely on this behavior.
+     */
     if (bdrv_is_inserted(s->bs) && s->cdrom_changed) {
         ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);