From patchwork Fri Nov 18 14:03:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 126428 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DAA72B71D0 for ; Sat, 19 Nov 2011 02:09:39 +1100 (EST) Received: from localhost ([::1]:35739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RROzu-0000W3-0P for incoming@patchwork.ozlabs.org; Fri, 18 Nov 2011 09:00:54 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RROzS-0007zY-FW for qemu-devel@nongnu.org; Fri, 18 Nov 2011 09:00:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RROzN-0002ZI-Vt for qemu-devel@nongnu.org; Fri, 18 Nov 2011 09:00:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RROzN-0002Z3-N5 for qemu-devel@nongnu.org; Fri, 18 Nov 2011 09:00:21 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAIE0Joq015892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Nov 2011 09:00:19 -0500 Received: from dhcp-5-188.str.redhat.com (vpn1-6-61.ams2.redhat.com [10.36.6.61]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pAIE04Pf006395; Fri, 18 Nov 2011 09:00:18 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 18 Nov 2011 15:03:12 +0100 Message-Id: <1321624993-19033-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1321624993-19033-1-git-send-email-kwolf@redhat.com> References: <1321624993-19033-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 8/9] scsi: pass down REQUEST SENSE to the device when there is no stored sense X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini 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 --- 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 4d9ff35..3a2a7bb 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", @@ -502,7 +500,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 9dd2be8..e3690ec 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1179,6 +1179,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) { @@ -1313,6 +1318,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) { @@ -1407,8 +1413,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 ff8fdd0..61c64d5 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -179,6 +179,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);