]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
scsi-bus: Use longer sense buffer with scanners
authorJarkko Lavinen <jarkko.lavinen@iki.fi>
Wed, 29 Jun 2016 00:11:46 +0000 (03:11 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 12 Jul 2016 16:31:26 +0000 (18:31 +0200)
Scanners can provide additional sense bytes beyond 18 bytes.
VueScan uses 32 bytes alloc length with Request Sense command.

Signed-off-by: Jarkko Lavinen <jarkko.lavinen@iki.fi>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/scsi-bus.c
include/hw/scsi/scsi.h

index 14c0aa557fb97e70c7506abb6f138365e3124533..297216dfcb59005232d27101f45fdd8be6481cbf 100644 (file)
@@ -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);
index 8acd3fa998b779c15548acd4fd85f3592e99286e..94d78681058b0218b6566d11bd9fb7ff41a97e63 100644 (file)
@@ -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;