Commit 6959e508 authored by Jarkko Lavinen's avatar Jarkko Lavinen Committed by Paolo Bonzini
Browse files

scsi-bus: Use longer sense buffer with scanners



Scanners can provide additional sense bytes beyond 18 bytes.
VueScan uses 32 bytes alloc length with Request Sense command.

Signed-off-by: default avatarJarkko Lavinen <jarkko.lavinen@iki.fi>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 297b044a
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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);
+4 −3
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@

#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;