From a07eb677ae7c6a28e74507537ad029c89525f006 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 22 Feb 2012 14:12:33 +0100 Subject: [PATCH 077/109] scsi: pass down REQUEST SENSE to the device when there is no stored sense RH-Author: Paolo Bonzini Message-id: <1329919979-20948-77-git-send-email-pbonzini@redhat.com> Patchwork-id: 37554 O-Subject: [RHEL 6.3 qemu-kvm PATCH v2 076/102] scsi: pass down REQUEST SENSE to the device when there is no stored sense Bugzilla: 782029 RH-Acked-by: Laszlo Ersek RH-Acked-by: Orit Wasserman RH-Acked-by: Gerd Hoffmann This will let scsi-block/scsi-generic report progress on long operations. Reported-by: Thomas Schmitt Tested-by: Thomas Schmitt Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf (cherry picked from f3b338ef4afaba105357f62143491e51d35c5b42) --- hw/scsi-bus.c | 4 +--- hw/scsi-disk.c | 8 ++++++-- hw/scsi.h | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) Signed-off-by: Michal Novotny --- 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 ed37c50..80e5bbe 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -9,8 +9,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", @@ -505,7 +503,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 289de5a..f93aad2 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1177,6 +1177,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) { @@ -1312,6 +1317,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) { @@ -1406,8 +1412,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 801e36d..2a7a7e4 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -180,6 +180,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.6