From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9A4n-0000DQ-K4 for qemu-devel@nongnu.org; Sat, 06 Dec 2008 22:12:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9A4m-0000BR-7K for qemu-devel@nongnu.org; Sat, 06 Dec 2008 22:12:56 -0500 Received: from [199.232.76.173] (port=45787 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9A4m-0000BJ-3v for qemu-devel@nongnu.org; Sat, 06 Dec 2008 22:12:56 -0500 Received: from savannah.gnu.org ([199.232.41.3]:52885 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9A4l-0006F0-TC for qemu-devel@nongnu.org; Sat, 06 Dec 2008 22:12:55 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L9A4l-00047a-CR for qemu-devel@nongnu.org; Sun, 07 Dec 2008 03:12:55 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L9A4l-00047W-5Q for qemu-devel@nongnu.org; Sun, 07 Dec 2008 03:12:55 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Sun, 07 Dec 2008 03:12:55 +0000 Subject: [Qemu-devel] [5903] SCSI: Handle inquiry commands of varying length (Justin Chevrier). 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 Revision: 5903 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5903 Author: balrog Date: 2008-12-07 03:12:54 +0000 (Sun, 07 Dec 2008) Log Message: ----------- SCSI: Handle inquiry commands of varying length (Justin Chevrier). Openserver 5.0.5 sends an Inquiry command to the emulated SCSI disk expecting a response length of 40 bytes. Currently the response to an Inquiry command is hardcoded to 36 bytes. When receiving a response of length 36 instead of 40 Openserver panics. Modifications to original patch based on feedback from Ryan Harper and Paul Brook. Thanks guys. Signed-off-by: Justin Chevrier Signed-off-by: Andrzej Zaborowski Modified Paths: -------------- trunk/hw/scsi-disk.c Modified: trunk/hw/scsi-disk.c =================================================================== --- trunk/hw/scsi-disk.c 2008-12-07 03:07:51 UTC (rev 5902) +++ trunk/hw/scsi-disk.c 2008-12-07 03:12:54 UTC (rev 5903) @@ -38,6 +38,7 @@ #define STATUS_CHECK_CONDITION 2 #define SCSI_DMA_BUF_SIZE 131072 +#define SCSI_MAX_INQUIRY_LEN 256 typedef struct SCSIRequest { SCSIDeviceState *dev; @@ -492,8 +493,12 @@ "is less than 36 (TODO: only 5 required)\n", len); } } - memset(outbuf, 0, 36); + if(len > SCSI_MAX_INQUIRY_LEN) + len = SCSI_MAX_INQUIRY_LEN; + + memset(outbuf, 0, len); + if (lun || buf[1] >> 5) { outbuf[0] = 0x7f; /* LUN not supported */ } else if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) { @@ -510,10 +515,10 @@ Some later commands are also implemented. */ outbuf[2] = 3; outbuf[3] = 2; /* Format 2 */ - outbuf[4] = 31; + outbuf[4] = len - 5; /* Additional Length = (Len - 1) - 4 */ /* Sync data transfer and TCQ. */ outbuf[7] = 0x10 | (s->tcq ? 0x02 : 0); - r->buf_len = 36; + r->buf_len = len; break; case 0x16: DPRINTF("Reserve(6)\n");