From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Khqz6-0005vq-9b for qemu-devel@nongnu.org; Mon, 22 Sep 2008 15:22:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Khqz3-0005vY-Ef for qemu-devel@nongnu.org; Mon, 22 Sep 2008 15:22:10 -0400 Received: from [199.232.76.173] (port=38344 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Khqz3-0005vV-BM for qemu-devel@nongnu.org; Mon, 22 Sep 2008 15:22:09 -0400 Received: from yw-out-1718.google.com ([74.125.46.152]:12673) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Khqz3-0001qN-2S for qemu-devel@nongnu.org; Mon, 22 Sep 2008 15:22:09 -0400 Received: by yw-out-1718.google.com with SMTP id 6so290186ywa.82 for ; Mon, 22 Sep 2008 12:22:07 -0700 (PDT) Message-ID: <48D7F021.5040102@codemonkey.ws> Date: Mon, 22 Sep 2008 14:21:05 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] scsi-generic: decode correctly SCSI tape commands References: <1222099458.4151.20.camel@frecb07144> In-Reply-To: <1222099458.4151.20.camel@frecb07144> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Laurent Vivier wrote: > This patch allows to use a "real" SCSI tape with qemu using > "-drive /dev/sgX,if=scsi". > > It allows to decode correctly transfer length when the type of the > device is a tape. > > Some issues subsist when the application reading the tape tries to go > beyond the end of the stream (but they must be corrected at the SCSI > controller level). > You have some tab/whitespace damage in this patch > @@ -75,6 +77,7 @@ struct SCSIDeviceState > { > SCSIRequest *requests; > BlockDriverState *bdrv; > + int type; > int blocksize; > int lun; > scsi_completionfn completion; > @@ -163,7 +166,7 @@ static void scsi_command_complete(void * > } else if ((s->driver_status & SG_ERR_DRIVER_SENSE) == 0) > sense = NO_SENSE; > else > - sense = s->sensebuf[2] & 0x0f; > + sense = s->sensebuf[2]; > } > > DPRINTF("Command complete 0x%p tag=0x%x sense=%d\n", r, r->tag, sense); > @@ -273,10 +276,15 @@ static void scsi_read_data(SCSIDevice *d > > if (r->cmd[0] == REQUEST_SENSE && s->driver_status & SG_ERR_DRIVER_SENSE) > { > - memcpy(r->buf, s->sensebuf, 16); > + int len; > Right here. > + len = r->len > SCSI_SENSE_BUF_SIZE ? SCSI_SENSE_BUF_SIZE : r->len; > Just use len = MIN(r->len, SCSI_SENSE_BUF_SIZE); The rest looks pretty straight forward. Regards, Anthony Liguori