From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PATCH v2 5/6] scsi: pass down REQUEST SENSE to the device when there is no stored sense
Date: Mon, 14 Nov 2011 14:31:51 +0100 [thread overview]
Message-ID: <1321277512-9414-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1321277512-9414-1-git-send-email-pbonzini@redhat.com>
This will let scsi-block/scsi-generic report progress on long
operations.
Reported-by: Thomas Schmitt <scdbackup@gmxbackup.net>
Tested-by: Thomas Schmitt <scdbackup@gmxbackup.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi-bus.c | 4 +---
hw/scsi-disk.c | 8 ++++++--
hw/scsi.h | 2 ++
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 736dcbb..33bafbb 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -10,8 +10,6 @@
static char *scsibus_get_fw_dev_path(DeviceState *dev);
static int scsi_req_parse(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf);
static void scsi_req_dequeue(SCSIRequest *req);
-static int scsi_build_sense(uint8_t *in_buf, int in_len,
- uint8_t *buf, int len, bool fixed);
static struct BusInfo scsi_bus_info = {
.name = "SCSI",
@@ -504,7 +502,7 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
hba_private);
} else if (lun != d->lun ||
buf[0] == REPORT_LUNS ||
- buf[0] == REQUEST_SENSE) {
+ (buf[0] == REQUEST_SENSE && (d->sense_len || cmd.xfer < 4))) {
req = scsi_req_alloc(&reqops_target_command, d, tag, lun,
hba_private);
} else {
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 9224b04..c2a3864 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1210,6 +1210,11 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
outbuf[7] = 0;
buflen = 8;
break;
+ case REQUEST_SENSE:
+ /* Just return "NO SENSE". */
+ buflen = scsi_build_sense(NULL, 0, outbuf, r->buflen,
+ (req->cmd.buf[1] & 1) == 0);
+ break;
case MECHANISM_STATUS:
buflen = scsi_emulate_mechanism_status(s, outbuf);
if (buflen < 0) {
@@ -1344,6 +1349,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
case GET_EVENT_STATUS_NOTIFICATION:
case MECHANISM_STATUS:
case SERVICE_ACTION_IN_16:
+ case REQUEST_SENSE:
case VERIFY_10:
rc = scsi_disk_emulate_command(r);
if (rc < 0) {
@@ -1435,8 +1441,6 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
}
break;
- case REQUEST_SENSE:
- abort();
default:
DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]);
scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE));
diff --git a/hw/scsi.h b/hw/scsi.h
index 796ecf1..c790acc 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -182,6 +182,8 @@ extern const struct SCSISense sense_code_DEVICE_INTERNAL_RESET;
#define SENSE_CODE(x) sense_code_ ## x
int scsi_sense_valid(SCSISense sense);
+int scsi_build_sense(uint8_t *in_buf, int in_len,
+ uint8_t *buf, int len, bool fixed);
SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
uint32_t tag, uint32_t lun, void *hba_private);
--
1.7.7.1
next prev parent reply other threads:[~2011-11-14 13:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 13:31 [Qemu-devel] [PATCH v2 0/6] scsi/atapi: MMC fixes Paolo Bonzini
2011-11-14 13:31 ` [Qemu-devel] [PATCH v2 1/6] atapi: kill MODE SENSE(6), fix MODE SENSE(10) Paolo Bonzini
2011-11-14 13:31 ` [Qemu-devel] [PATCH v2 2/6] scsi: update list of commands Paolo Bonzini
2011-11-14 13:31 ` [Qemu-devel] [PATCH v2 3/6] scsi: fix parsing of allocation length field Paolo Bonzini
2011-11-18 13:07 ` Kevin Wolf
2011-11-18 13:51 ` Paolo Bonzini
2011-11-14 13:31 ` [Qemu-devel] [PATCH v2 4/6] scsi: remove block descriptors from CDs Paolo Bonzini
2011-11-14 13:31 ` Paolo Bonzini [this message]
2011-11-14 13:31 ` [Qemu-devel] [PATCH v2 6/6] scsi-block: always use SG_IO for MMC devices Paolo Bonzini
2011-11-18 13:15 ` [Qemu-devel] [PATCH v2 0/6] scsi/atapi: MMC fixes Kevin Wolf
-- strict thread matches above, loose matches on Subject: below --
2011-11-14 9:40 Paolo Bonzini
2011-11-14 9:40 ` [Qemu-devel] [PATCH v2 5/6] scsi: pass down REQUEST SENSE to the device when there is no stored sense Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321277512-9414-6-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).