Received: from eggs.gnu.org ([2001:4830:134:3::10]:52172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKBW-0001qb-9C for qemu-devel@nongnu.org; Wed, 13 Jul 2016 09:26:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNKBR-00039C-98 for qemu-devel@nongnu.org; Wed, 13 Jul 2016 09:26:42 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKBR-000397-2E for qemu-devel@nongnu.org; Wed, 13 Jul 2016 09:26:37 -0400 Received: by mail-wm0-x244.google.com with SMTP id q128so1458188wma.1 for ; Wed, 13 Jul 2016 06:26:36 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 13 Jul 2016 15:26:20 +0200 Message-Id: <1468416392-120170-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1468416392-120170-1-git-send-email-pbonzini@redhat.com> References: <1468416392-120170-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 02/14] scsi-bus: Use longer sense buffer with scanners List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jarkko Lavinen From: Jarkko Lavinen Scanners can provide additional sense bytes beyond 18 bytes. VueScan uses 32 bytes alloc length with Request Sense command. Signed-off-by: Jarkko Lavinen Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 10 +++++++++- include/hw/scsi/scsi.h | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 14c0aa5..297216d 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -461,6 +461,14 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r) return true; } +static size_t scsi_sense_len(SCSIRequest *req) +{ + if (req->dev->type == TYPE_SCANNER) + return SCSI_SENSE_LEN_SCANNER; + else + return SCSI_SENSE_LEN; +} + static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf) { SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req); @@ -477,7 +485,7 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf) } break; case REQUEST_SENSE: - scsi_target_alloc_buf(&r->req, SCSI_SENSE_LEN); + scsi_target_alloc_buf(&r->req, scsi_sense_len(req)); r->len = scsi_device_get_sense(r->req.dev, r->buf, MIN(req->cmd.xfer, r->buf_len), (req->cmd.buf[1] & 1) == 0); diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 8acd3fa..94d7868 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -8,9 +8,10 @@ #define MAX_SCSI_DEVS 255 -#define SCSI_CMD_BUF_SIZE 16 -#define SCSI_SENSE_LEN 18 -#define SCSI_INQUIRY_LEN 36 +#define SCSI_CMD_BUF_SIZE 16 +#define SCSI_SENSE_LEN 18 +#define SCSI_SENSE_LEN_SCANNER 32 +#define SCSI_INQUIRY_LEN 36 typedef struct SCSIBus SCSIBus; typedef struct SCSIBusInfo SCSIBusInfo; -- 1.8.3.1