aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/ide/atapi.c29
-rw-r--r--hw/scsi-disk.c3
2 files changed, 12 insertions, 20 deletions
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index d9db6de3d6..afb27c60a2 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -905,33 +905,22 @@ static void cmd_seek(IDEState *s, uint8_t* buf)
static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
{
- int sense, err = 0;
+ int sense;
bool start = buf[4] & 1;
bool loej = buf[4] & 2; /* load on start, eject on !start */
if (loej) {
- err = bdrv_eject(s->bs, !start);
- }
-
- switch (err) {
- case 0:
- ide_atapi_cmd_ok(s);
- break;
- case -EBUSY:
- sense = SENSE_NOT_READY;
- if (bdrv_is_inserted(s->bs)) {
- sense = SENSE_ILLEGAL_REQUEST;
+ if (!start && s->tray_locked) {
+ sense = bdrv_is_inserted(s->bs)
+ ? SENSE_NOT_READY : SENSE_ILLEGAL_REQUEST;
+ ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
+ return;
}
- ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
- break;
- default:
- ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
- break;
- }
-
- if (loej && !err) {
+ bdrv_eject(s->bs, !start);
s->tray_open = !start;
}
+
+ ide_atapi_cmd_ok(s);
}
static void cmd_mechanism_status(IDEState *s, uint8_t* buf)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index e7358e3c4d..65783a73e6 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -830,6 +830,9 @@ static void scsi_disk_emulate_start_stop(SCSIDiskReq *r)
bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */
if (s->qdev.type == TYPE_ROM && loej) {
+ if (!start && s->tray_locked) {
+ return;
+ }
bdrv_eject(s->bs, !start);
s->tray_open = !start;
}