aboutsummaryrefslogtreecommitdiff
path: root/hw/ide/atapi.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2011-09-06 18:58:45 +0200
committerKevin Wolf <kwolf@redhat.com>2011-09-12 15:17:20 +0200
commitfdec4404ddfaf9e121bef84eac1303a8a0e47d75 (patch)
treeea7637b6abf1510c1ff22baf1b495536f71a5b40 /hw/ide/atapi.c
parent81b1008d50829fdcbe79aa67fa1113bb00a787d6 (diff)
downloadqemu-fdec4404ddfaf9e121bef84eac1303a8a0e47d75.zip
qemu-fdec4404ddfaf9e121bef84eac1303a8a0e47d75.tar.gz
qemu-fdec4404ddfaf9e121bef84eac1303a8a0e47d75.tar.bz2
block: Leave enforcing tray lock to device models
The device model knows best when to accept the guest's eject command. No need to detour through the block layer. bdrv_eject() can't fail anymore. Make it void. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/ide/atapi.c')
-rw-r--r--hw/ide/atapi.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index d9db6de..afb27c6 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)