From patchwork Thu Nov 26 14:34:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 39539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 82BB91007D1 for ; Fri, 27 Nov 2009 02:37:10 +1100 (EST) Received: from localhost ([127.0.0.1]:60772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDgP4-0007uf-If for incoming@patchwork.ozlabs.org; Thu, 26 Nov 2009 10:37:06 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDfR6-0006x2-1g for qemu-devel@nongnu.org; Thu, 26 Nov 2009 09:35:08 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDfR0-0006nh-I3 for qemu-devel@nongnu.org; Thu, 26 Nov 2009 09:35:05 -0500 Received: from [199.232.76.173] (port=56167 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDfQw-0006m6-19 for qemu-devel@nongnu.org; Thu, 26 Nov 2009 09:34:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23947) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDfQv-0000Ha-GS for qemu-devel@nongnu.org; Thu, 26 Nov 2009 09:34:57 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAQEYuHR012326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 Nov 2009 09:34:56 -0500 Received: from zweiblum.home.kraxel.org (vpn2-8-164.ams2.redhat.com [10.36.8.164]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nAQEYdca029208; Thu, 26 Nov 2009 09:34:52 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 49B2370114; Thu, 26 Nov 2009 15:34:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 26 Nov 2009 15:34:03 +0100 Message-Id: <1259246056-5389-18-git-send-email-kraxel@redhat.com> In-Reply-To: <1259246056-5389-1-git-send-email-kraxel@redhat.com> References: <1259246056-5389-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 17/30] scsi-disk: restruct emulation: REQUEST_SENSE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move REQUEST_SENSE emulation from scsi_send_command() to scsi_disk_emulate_command(). Signed-off-by: Gerd Hoffmann --- 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) {