From patchwork Thu Jun 14 13:55:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 164938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A298E1007D1 for ; Fri, 15 Jun 2012 00:18:59 +1000 (EST) Received: from localhost ([::1]:51097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfAXN-00067V-S4 for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2012 09:56:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfAWc-0003zB-Td for qemu-devel@nongnu.org; Thu, 14 Jun 2012 09:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfAWV-0002fX-1b for qemu-devel@nongnu.org; Thu, 14 Jun 2012 09:55:50 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:44150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfAWU-0002eW-NR for qemu-devel@nongnu.org; Thu, 14 Jun 2012 09:55:42 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Jun 2012 14:55:39 +0100 Received: from d06nrmr1407.portsmouth.uk.ibm.com (9.149.38.185) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 14 Jun 2012 14:55:36 +0100 Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by d06nrmr1407.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5EDtaJT2580572 for ; Thu, 14 Jun 2012 14:55:36 +0100 Received: from d06av12.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5EDtWLx012937 for ; Thu, 14 Jun 2012 07:55:33 -0600 Received: from localhost.localdomain (dyn-9-152-224-198.boeblingen.de.ibm.com [9.152.224.198]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5EDtVZG012790; Thu, 14 Jun 2012 07:55:32 -0600 From: Christian Borntraeger To: pbonzini@redhat.com Date: Thu, 14 Jun 2012 15:55:29 +0200 Message-Id: <1339682129-1497-6-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1339682129-1497-1-git-send-email-borntraeger@de.ibm.com> References: <1339682129-1497-1-git-send-email-borntraeger@de.ibm.com> x-cbid: 12061413-1948-0000-0000-0000021744A8 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.110 Cc: stefanha@gmail.com, Christian Hoff , qemu-devel@nongnu.org, Christian Borntraeger Subject: [Qemu-devel] [PATCH 5/5] scsi: Ensure command and transfer lengths are set for all SCSI stream commands. 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: Christian Hoff scsi-generic relies on those values to be correct, so it is important that those values are initialized properly prior to submitting the SCSI command. Signed-off-by: Christian Hoff Signed-off-by: Christian Borntraeger --- hw/scsi-bus.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 9854321..3c3f190 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -817,7 +817,11 @@ static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu switch (buf[0]) { /* stream commands */ case ERASE_12: + cmd->len = 12; + cmd->xfer = 0; + break; case ERASE_16: + cmd->len = 16; cmd->xfer = 0; break; case READ_6: @@ -836,9 +840,12 @@ static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu cmd->xfer = 0; break; case SPACE_16: + cmd->len = 16; cmd->xfer = buf[13] | (buf[12] << 8); break; case READ_POSITION: + cmd->len = 10; + switch (buf[1] & 0x1f) /* operation code */ { case SHORT_FORM_BLOCK_ID: case SHORT_FORM_VENDOR_SPECIFIC: @@ -856,6 +863,7 @@ static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu break; case FORMAT_UNIT: + cmd->len = 6; cmd->xfer = buf[4] | (buf[3] << 8); break; /* generic commands */