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 <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a5d2fd1..091ecdc 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1050,8 +1050,11 @@
: 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;
}