[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/30] scsi-disk: restruct emulation: REQUEST_SENSE
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 17/30] scsi-disk: restruct emulation: REQUEST_SENSE |
Date: |
Thu, 26 Nov 2009 15:34:03 +0100 |
Move REQUEST_SENSE emulation from scsi_send_command() to
scsi_disk_emulate_command().
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/scsi-disk.c | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index f851694..7597b52 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -316,6 +316,24 @@ static int scsi_disk_emulate_command(SCSIRequest *req,
uint8_t *outbuf)
if (!bdrv_is_inserted(bdrv))
goto not_ready;
break;
+ case REQUEST_SENSE:
+ if (req->cmd.xfer < 4)
+ goto illegal_request;
+ memset(outbuf, 0, 4);
+ buflen = 4;
+ if (req->dev->sense.key == NOT_READY && req->cmd.xfer >= 18) {
+ memset(outbuf, 0, 18);
+ buflen = 18;
+ outbuf[7] = 10;
+ /* asc 0x3a, ascq 0: Medium not present */
+ outbuf[12] = 0x3a;
+ outbuf[13] = 0;
+ }
+ outbuf[0] = 0xf0;
+ outbuf[1] = 0;
+ outbuf[2] = req->dev->sense.key;
+ scsi_dev_clear_sense(req->dev);
+ break;
default:
goto illegal_request;
}
@@ -419,6 +437,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t
tag,
}
switch (command) {
case TEST_UNIT_READY:
+ case REQUEST_SENSE:
rc = scsi_disk_emulate_command(&r->req, outbuf);
if (rc > 0) {
r->iov.iov_len = rc;
@@ -427,25 +446,6 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t
tag,
scsi_remove_request(r);
}
return rc;
- case REQUEST_SENSE:
- DPRINTF("Request Sense (len %d)\n", len);
- if (len < 4)
- goto fail;
- memset(outbuf, 0, 4);
- r->iov.iov_len = 4;
- if (s->qdev.sense.key == NOT_READY && len >= 18) {
- memset(outbuf, 0, 18);
- r->iov.iov_len = 18;
- outbuf[7] = 10;
- /* asc 0x3a, ascq 0: Medium not present */
- outbuf[12] = 0x3a;
- outbuf[13] = 0;
- }
- outbuf[0] = 0xf0;
- outbuf[1] = 0;
- outbuf[2] = s->qdev.sense.key;
- scsi_dev_clear_sense(&s->qdev);
- break;
case INQUIRY:
DPRINTF("Inquiry (len %d)\n", len);
if (buf[1] & 0x2) {
--
1.6.2.5
- [Qemu-devel] [PATCH 02/30] scsi: create common SCSIRequest structure., (continued)
- [Qemu-devel] [PATCH 02/30] scsi: create common SCSIRequest structure., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 08/30] scsi: move type from SCSIGenericState to SCSIDevice, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 05/30] scsi: move scsi command buffer from SCSIGenericReq to SCSIRequest., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 12/30] scsi: move sense to SCSIDevice, create SCSISense struct., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 11/30] scsi: add xfer mode, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 14/30] scsi: move status to SCSIRequest., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 10/30] scsi: use command defines in scsi-disk.c, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 06/30] scsi: move blocksize from SCSIGenericState to SCSIDevice, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 09/30] scsi: add request parsing helpers to common code., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 13/30] scsi: move dinfo to SCSIDevice, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 17/30] scsi-disk: restruct emulation: REQUEST_SENSE,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 07/30] scsi: add scsi-defs.h, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 15/30] scsi: add scsi_req_print(), Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 19/30] scsi-disk: restruct emulation: RESERVE+RELEASE, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 27/30] scsi-disk: restruct emulation: SERVICE_ACTION_IN, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 18/30] scsi-disk: restruct emulation: INQUIRY, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 21/30] scsi-disk: restruct emulation: START_STOP, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 26/30] scsi-disk: restruct emulation: GET_CONFIGURATION, Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 30/30] scsi: add read/write 16 commands., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 16/30] scsi-disk: restruct emulation: core + TEST_UNIT_READY., Gerd Hoffmann, 2009/11/26
- [Qemu-devel] [PATCH 22/30] scsi-disk: restruct emulation: ALLOW_MEDIUM_REMOVAL, Gerd Hoffmann, 2009/11/26