From d88b1819dd6c6ba4b2270c98bf52ce67a315066d Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Fri, 17 Feb 2012 11:05:21 -0200 Subject: block: Don't call bdrv_eject() if the tray state didn't change 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 Reviewed-by: Markus Armbruster Acked-by: Kevin Wolf --- hw/scsi-disk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'hw/scsi-disk.c') diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index a5d2fd1d34..091ecdcc87 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -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; } -- cgit v1.2.3