提交 29362ebe 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

scsi: move scsi command buffer from SCSIGenericReq to SCSIRequest.

Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 89b08ae1
...@@ -42,7 +42,6 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0) ...@@ -42,7 +42,6 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
#define SET_CD_SPEED 0xbb #define SET_CD_SPEED 0xbb
#define BLANK 0xa1 #define BLANK 0xa1
#define SCSI_CMD_BUF_SIZE 16
#define SCSI_SENSE_BUF_SIZE 96 #define SCSI_SENSE_BUF_SIZE 96
#define SG_ERR_DRIVER_TIMEOUT 0x06 #define SG_ERR_DRIVER_TIMEOUT 0x06
...@@ -56,8 +55,6 @@ typedef struct SCSIGenericState SCSIGenericState; ...@@ -56,8 +55,6 @@ typedef struct SCSIGenericState SCSIGenericState;
typedef struct SCSIGenericReq { typedef struct SCSIGenericReq {
SCSIRequest req; SCSIRequest req;
uint8_t cmd[SCSI_CMD_BUF_SIZE];
int cmdlen;
uint8_t *buf; uint8_t *buf;
int buflen; int buflen;
int len; int len;
...@@ -153,8 +150,8 @@ static int execute_command(BlockDriverState *bdrv, ...@@ -153,8 +150,8 @@ static int execute_command(BlockDriverState *bdrv,
r->io_header.dxfer_direction = direction; r->io_header.dxfer_direction = direction;
r->io_header.dxferp = r->buf; r->io_header.dxferp = r->buf;
r->io_header.dxfer_len = r->buflen; r->io_header.dxfer_len = r->buflen;
r->io_header.cmdp = r->cmd; r->io_header.cmdp = r->req.cmd.buf;
r->io_header.cmd_len = r->cmdlen; r->io_header.cmd_len = r->req.cmd.len;
r->io_header.mx_sb_len = sizeof(s->sensebuf); r->io_header.mx_sb_len = sizeof(s->sensebuf);
r->io_header.sbp = s->sensebuf; r->io_header.sbp = s->sensebuf;
r->io_header.timeout = MAX_UINT; r->io_header.timeout = MAX_UINT;
...@@ -210,7 +207,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag) ...@@ -210,7 +207,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag)
return; return;
} }
if (r->cmd[0] == REQUEST_SENSE && s->driver_status & SG_ERR_DRIVER_SENSE) if (r->req.cmd.buf[0] == REQUEST_SENSE && s->driver_status & SG_ERR_DRIVER_SENSE)
{ {
s->senselen = MIN(r->len, s->senselen); s->senselen = MIN(r->len, s->senselen);
memcpy(r->buf, s->sensebuf, s->senselen); memcpy(r->buf, s->sensebuf, s->senselen);
...@@ -245,7 +242,7 @@ static void scsi_write_complete(void * opaque, int ret) ...@@ -245,7 +242,7 @@ static void scsi_write_complete(void * opaque, int ret)
return; return;
} }
if (r->cmd[0] == MODE_SELECT && r->cmd[4] == 12 && if (r->req.cmd.buf[0] == MODE_SELECT && r->req.cmd.buf[4] == 12 &&
s->type == TYPE_TAPE) { s->type == TYPE_TAPE) {
s->blocksize = (r->buf[9] << 16) | (r->buf[10] << 8) | r->buf[11]; s->blocksize = (r->buf[9] << 16) | (r->buf[10] << 8) | r->buf[11];
DPRINTF("block size %d\n", s->blocksize); DPRINTF("block size %d\n", s->blocksize);
...@@ -509,8 +506,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, ...@@ -509,8 +506,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
} }
r = scsi_new_request(d, tag, lun); r = scsi_new_request(d, tag, lun);
memcpy(r->cmd, cmd, cmdlen); memcpy(r->req.cmd.buf, cmd, cmdlen);
r->cmdlen = cmdlen; r->req.cmd.len = cmdlen;
if (len == 0) { if (len == 0) {
if (r->buf != NULL) if (r->buf != NULL)
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "qdev.h" #include "qdev.h"
#include "block.h" #include "block.h"
#define SCSI_CMD_BUF_SIZE 16
/* scsi-disk.c */ /* scsi-disk.c */
enum scsi_reason { enum scsi_reason {
SCSI_REASON_DONE, /* Command complete. */ SCSI_REASON_DONE, /* Command complete. */
...@@ -21,6 +23,10 @@ typedef struct SCSIRequest { ...@@ -21,6 +23,10 @@ typedef struct SCSIRequest {
SCSIDevice *dev; SCSIDevice *dev;
uint32_t tag; uint32_t tag;
uint32_t lun; uint32_t lun;
struct {
uint8_t buf[SCSI_CMD_BUF_SIZE];
int len;
} cmd;
BlockDriverAIOCB *aiocb; BlockDriverAIOCB *aiocb;
QTAILQ_ENTRY(SCSIRequest) next; QTAILQ_ENTRY(SCSIRequest) next;
} SCSIRequest; } SCSIRequest;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册