[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/14] scsi-bus: Use longer sense buffer with scanner
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 02/14] scsi-bus: Use longer sense buffer with scanners |
Date: |
Wed, 13 Jul 2016 15:26:20 +0200 |
From: Jarkko Lavinen <address@hidden>
Scanners can provide additional sense bytes beyond 18 bytes.
VueScan uses 32 bytes alloc length with Request Sense command.
Signed-off-by: Jarkko Lavinen <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
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
- [Qemu-devel] [PULL 00/14] SCSI, chardev, build fixes for 2016-07-13, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 04/14] main-loop: check return value before using pointer, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 03/14] Use "-s" instead of "--quiet" to resolve non-fatal build error on FreeBSD., Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 05/14] json-streamer: fix double-free on exiting during a parse, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 06/14] disas: avoid including everything in headers compiled from C++, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 08/14] util: Fix MIN_NON_ZERO, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 01/14] scsi-bus: Add SCSI scanner support, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 02/14] scsi-bus: Use longer sense buffer with scanners,
Paolo Bonzini <=
- [Qemu-devel] [PULL 09/14] tap: use an exit notifier to call down_script, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 07/14] qemu-sockets: use qapi_free_SocketAddress in cleanup, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 10/14] slirp: use exit notifier for slirp_smb_cleanup, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 11/14] net: do not use atexit for cleanup, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 13/14] hostmem: fix QEMU crash by 'info memdev', Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 12/14] char: do not use atexit cleanup handler, Paolo Bonzini, 2016/07/13
- [Qemu-devel] [PULL 14/14] hostmem: detect host backend memory is being used properly, Paolo Bonzini, 2016/07/13
- Re: [Qemu-devel] [PULL 00/14] SCSI, chardev, build fixes for 2016-07-13, Peter Maydell, 2016/07/14