aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2011-09-06 18:58:39 +0200
committerKevin Wolf <kwolf@redhat.com>2011-09-12 15:17:20 +0200
commitbfd52647adc17ec05b708e2a061f85707cbe4dcc (patch)
treea7299e2eba43e4bb82fcddba589b52dad3528dc2 /hw/scsi-disk.c
parentdd063333929f2e2a44dc900aa4f75f11dea7cb28 (diff)
scsi-disk: Factor out scsi_disk_emulate_start_stop()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 9724d0fe9a..c8ad2e7d03 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -814,6 +814,18 @@ static int scsi_disk_emulate_read_toc(SCSIRequest *req, uint8_t *outbuf)
return toclen;
}
+static void scsi_disk_emulate_start_stop(SCSIDiskReq *r)
+{
+ SCSIRequest *req = &r->req;
+ SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
+ bool start = req->cmd.buf[4] & 1;
+ bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */
+
+ if (s->qdev.type == TYPE_ROM && loej) {
+ bdrv_eject(s->bs, !start);
+ }
+}
+
static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf)
{
SCSIRequest *req = &r->req;
@@ -859,10 +871,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf)
goto illegal_request;
break;
case START_STOP:
- if (s->qdev.type == TYPE_ROM && (req->cmd.buf[4] & 2)) {
- /* load/eject medium */
- bdrv_eject(s->bs, !(req->cmd.buf[4] & 1));
- }
+ scsi_disk_emulate_start_stop(r);
break;
case ALLOW_MEDIUM_REMOVAL:
bdrv_set_locked(s->bs, req->cmd.buf[4] & 1);