From patchwork Mon May 31 01:43:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 54010 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 3293FB7D5C for ; Mon, 31 May 2010 12:06:57 +1000 (EST) Received: from localhost ([127.0.0.1]:42659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OIu59-0006o9-0q for incoming@patchwork.ozlabs.org; Sun, 30 May 2010 21:46:23 -0400 Received: from [140.186.70.92] (port=46860 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OIu1l-0004qo-HI for qemu-devel@nongnu.org; Sun, 30 May 2010 21:42:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OIu1k-0000kt-Bn for qemu-devel@nongnu.org; Sun, 30 May 2010 21:42:53 -0400 Received: from smtp110.sbc.mail.gq1.yahoo.com ([67.195.14.95]:29374) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OIu1k-0000kn-2d for qemu-devel@nongnu.org; Sun, 30 May 2010 21:42:52 -0400 Received: (qmail 74897 invoked from network); 31 May 2010 01:42:50 -0000 Received: from adsl-70-231-238-2.dsl.snfc21.sbcglobal.net (nab@70.231.238.2 with login) by smtp110.sbc.mail.gq1.yahoo.com with SMTP; 30 May 2010 18:42:50 -0700 PDT X-Yahoo-SMTP: fzDSGlOswBCWnIOrNw7KwwK1j9PqyNbe5PtLKiS4dDU.UNl_t6bdEZu9tTLW X-YMail-OSG: RktwnbMVM1ny5HCBAiWFbKafBBbDkMwjr.ReR3RGnZcWQltNkMNL8aBJl_UycmtJpqC_fGDxrZx93dfEK6t5t7D5piYhdXVhN3gkaoFvSkJeIKDk_TSxcRjujWa6RvneWEhkBknCyN87WHCZQX_i8S6BsWD.87ReGE0I78DmlcM9oulht6WJ7_ytDCguxLKdeK1Lct.Gq_RhJ1vHZlF0HdtqZGNgIkfcMIEqDjWzW5Z.r6zriM9kqwLEeEvpxodGRX50rmwSCjeeSfpEaRR0VuwF_lmN6Q7Lug5AD6iNlVnNXfPw_rs6g_92t5ovfFa7D62Ml1lJNcNSgdFzIBdzXw_GPo9q7Qbq_Zbnl.2LCfgiFg-- X-Yahoo-Newman-Property: ymail-3 From: "Nicholas A. Bellinger" To: Kevin Wolf , Gerd Hoffmann Date: Sun, 30 May 2010 18:43:08 -0700 Message-Id: <1275270188-11011-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.5.6.5 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) Cc: kvm-devel , qemu-devel , Nicholas Bellinger , Paul Brook , Christoph Hellwig , Hannes Reinecke Subject: [Qemu-devel] [PATCH 2/2] [scsi-bus]: Add MAINTENANCE_IN and MAINTENANCE_OUT case for SCSIRequest xfer and xfer_mode setup 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 From: Nicholas Bellinger This patch updates hw/scsi-bus.c to add MAINTENANCE_IN and MAINTENANCE_OUT case in scsi_req_length() to extra the incoming buffer length into SCSIRequest->cmd.xfer, and adds a second MAINTENANCE_OUT case in scsi_req_xfer_mode() in order to properly set SCSI_XFER_TO_DEV for WRITE data. Tested with Linux KVM guests and Megasas 8708EM2 HBA emulation and TCM_Loop target ports. Signed-off-by: Nicholas A. Bellinger --- hw/scsi-bus.c | 14 ++++++++++++++ hw/scsi-defs.h | 2 ++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 75ec74e..7d80405 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -329,6 +329,17 @@ static int scsi_req_length(SCSIRequest *req, uint8_t *cmd) case PERSISTENT_RESERVE_IN: req->cmd.xfer = cmd[8] | (cmd[7] << 8); break; + case MAINTENANCE_OUT: + case MAINTENANCE_IN: + if (req->dev->type != TYPE_ROM) { + /* Used for MI_REPORT_TARGET_PGS, MO_SET_TARGET_PGS et al. */ + req->cmd.xfer = cmd[9] | (cmd[8] << 8) | + (cmd[7] << 16) | (cmd[6] << 24); + } else { + /* GPCMD_REPORT_KEY and GPCMD_SEND_KEY from multi media commands */ + req->cmd.xfer = cmd[9] | (cmd[8] << 8); + } + break; } return 0; } @@ -394,6 +405,7 @@ static void scsi_req_xfer_mode(SCSIRequest *req) case SEND_VOLUME_TAG: case WRITE_LONG_2: case PERSISTENT_RESERVE_OUT: + case MAINTENANCE_OUT: req->cmd.mode = SCSI_XFER_TO_DEV; break; default: @@ -539,6 +551,8 @@ const char *scsi_command_name(uint8_t cmd) [ SPACE ] = "SPACE", [ INQUIRY ] = "INQUIRY", [ RECOVER_BUFFERED_DATA ] = "RECOVER_BUFFERED_DATA", + [ MAINTENANCE_IN ] = "MAINTENANCE_IN", + [ MAINTENANCE_OUT ] = "MAINTENANCE_OUT", [ MODE_SELECT ] = "MODE_SELECT", [ RESERVE ] = "RESERVE", [ RELEASE ] = "RELEASE", diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h index 5890094..a4a3518 100644 --- a/hw/scsi-defs.h +++ b/hw/scsi-defs.h @@ -84,6 +84,8 @@ #define MODE_SENSE_10 0x5a #define PERSISTENT_RESERVE_IN 0x5e #define PERSISTENT_RESERVE_OUT 0x5f +#define MAINTENANCE_IN 0xa3 +#define MAINTENANCE_OUT 0xa4 #define MOVE_MEDIUM 0xa5 #define READ_12 0xa8 #define WRITE_12 0xaa