]> Git Repo - qemu.git/commitdiff
block: Don't call bdrv_eject() if the tray state didn't change
authorLuiz Capitulino <[email protected]>
Fri, 17 Feb 2012 13:05:21 +0000 (11:05 -0200)
committerLuiz Capitulino <[email protected]>
Wed, 22 Feb 2012 19:23:21 +0000 (17:23 -0200)
It's not needed. Besides we can then assume that bdrv_eject() is
only called when there's a tray state change, which is useful to
the DEVICE_TRAY_MOVED event (going to be added in a future
commit).

Signed-off-by: Luiz Capitulino <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Acked-by: Kevin Wolf <[email protected]>
hw/ide/atapi.c
hw/scsi-disk.c

index 0adb27b799c20ae902fc8d46e1eaf6a9ca507b95..5919cf52d8482b95590eb2cc446aa465fad3e551 100644 (file)
@@ -883,8 +883,11 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
             ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
             return;
         }
-        bdrv_eject(s->bs, !start);
-        s->tray_open = !start;
+
+        if (s->tray_open != !start) {
+            bdrv_eject(s->bs, !start);
+            s->tray_open = !start;
+        }
     }
 
     ide_atapi_cmd_ok(s);
index a5d2fd1d34cf4f4dbd3c29c53f766f7658de4c2f..091ecdcc87b9a3411c8254eb8eecb8b45169600e 100644 (file)
@@ -1050,8 +1050,11 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)
                                  : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED));
             return -1;
         }
-        bdrv_eject(s->qdev.conf.bs, !start);
-        s->tray_open = !start;
+
+        if (s->tray_open != !start) {
+            bdrv_eject(s->qdev.conf.bs, !start);
+            s->tray_open = !start;
+        }
     }
     return 0;
 }
This page took 0.032711 seconds and 4 git commands to generate.