]> xenbits.xensource.com Git - qemu-xen-3.3-testing.git/commitdiff
Send unit_attention on cd-rom not_ready to ready transition
authorIan Jackson <iwj@mariner.uk.xensource.com>
Mon, 19 May 2008 15:21:52 +0000 (16:21 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 19 May 2008 15:21:52 +0000 (16:21 +0100)
Patch sends a UNIT_ATTENTION(6), MEDIUM_MAY_HAVE_CHANGED(0x28) sense
when cdrom transitions from not ready to ready.

I used the following documentation:
 ATA Packet interface for CD-ROMS, SFF8020i.pdf. See state diagram Figure
 12, page 82 and Table 44 -recommended Sense Key, ASC

With patch in place HVM win2008 server guest sees the CD/DVD contents
have changed when the media is switched.

Signed-off-by: Pat Campbell <plc@novell.com>
hw/ide.c

index 8b86f71b877634ad7a4e6e3a00ca8613dfa2bd66..5420e0e2bc616a92bce06e0bc58a6e81c87e4a6a 100644 (file)
--- a/hw/ide.c
+++ b/hw/ide.c
 #define ASC_ILLEGAL_OPCODE                   0x20
 #define ASC_LOGICAL_BLOCK_OOR                0x21
 #define ASC_INV_FIELD_IN_CMD_PACKET          0x24
+#define ASC_MEDIUM_MAY_HAVE_CHANGED          0x28
 #define ASC_MEDIUM_NOT_PRESENT               0x3a
 #define ASC_SAVING_PARAMETERS_NOT_SUPPORTED  0x39
 
@@ -1474,6 +1475,11 @@ static void ide_atapi_cmd(IDEState *s)
     switch(s->io_buffer[0]) {
     case GPCMD_TEST_UNIT_READY:
         if (bdrv_is_inserted(s->bs)) {
+            if (s->is_cdrom && s->sense_key == SENSE_NOT_READY) {
+                ide_atapi_cmd_error(s, SENSE_UNIT_ATTENTION,
+                                    ASC_MEDIUM_MAY_HAVE_CHANGED);
+                break;
+            }
             ide_atapi_cmd_ok(s);
         } else {
             ide_atapi_cmd_error(s, SENSE_NOT_READY,