diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-03-14 18:17:25 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-03-14 18:17:25 +0000 |
commit | 03d51428e2da0188a0adea00cbd713cc1e967e7a (patch) | |
tree | 371bbd515032a5422f8580c0f1cd7f624b0f5c88 | |
parent | 5d92c74f8a1728a202ba9457872ab0f27ff15e81 (diff) | |
parent | aa7a6a399f8253d3831465b1db8544032b49f57a (diff) |
Merge remote-tracking branch 'remotes/bonzini/scsi-next' into staging
* remotes/bonzini/scsi-next:
virtio-scsi: actually honor sense_size from configuration space
scsi: Fix migration of scsi sense data
spapr-vscsi: fix CRQ status
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/scsi/scsi-bus.c | 30 | ||||
-rw-r--r-- | hw/scsi/spapr_vscsi.c | 4 | ||||
-rw-r--r-- | hw/scsi/virtio-scsi.c | 4 | ||||
-rw-r--r-- | include/hw/scsi/scsi.h | 1 | ||||
-rw-r--r-- | include/migration/vmstate.h | 3 |
5 files changed, 38 insertions, 4 deletions
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 50a0acf1fe..eaad925cbb 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1905,6 +1905,26 @@ static const VMStateInfo vmstate_info_scsi_requests = { .put = put_scsi_requests, }; +static bool scsi_sense_state_needed(void *opaque) +{ + SCSIDevice *s = opaque; + + return s->sense_len > SCSI_SENSE_BUF_SIZE_OLD; +} + +static const VMStateDescription vmstate_scsi_sense_state = { + .name = "SCSIDevice/sense", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice, + SCSI_SENSE_BUF_SIZE_OLD, + SCSI_SENSE_BUF_SIZE - SCSI_SENSE_BUF_SIZE_OLD), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_scsi_device = { .name = "SCSIDevice", .version_id = 1, @@ -1915,7 +1935,7 @@ const VMStateDescription vmstate_scsi_device = { VMSTATE_UINT8(unit_attention.asc, SCSIDevice), VMSTATE_UINT8(unit_attention.ascq, SCSIDevice), VMSTATE_BOOL(sense_is_ua, SCSIDevice), - VMSTATE_UINT8_ARRAY(sense, SCSIDevice, SCSI_SENSE_BUF_SIZE), + VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice, 0, SCSI_SENSE_BUF_SIZE_OLD), VMSTATE_UINT32(sense_len, SCSIDevice), { .name = "requests", @@ -1927,6 +1947,14 @@ const VMStateDescription vmstate_scsi_device = { .offset = 0, }, VMSTATE_END_OF_LIST() + }, + .subsections = (VMStateSubsection []) { + { + .vmsd = &vmstate_scsi_sense_state, + .needed = scsi_sense_state_needed, + }, { + /* empty */ + } } }; diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index b3835c821d..34478f0157 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -195,9 +195,9 @@ static int vscsi_send_iu(VSCSIState *s, vscsi_req *req, req->crq.s.IU_data_ptr = req->iu.srp.rsp.tag; /* right byte order */ if (rc == 0) { - req->crq.s.status = 0x99; /* Just needs to be non-zero */ + req->crq.s.status = VIOSRP_OK; } else { - req->crq.s.status = 0x00; + req->crq.s.status = VIOSRP_ADAPTER_FAIL; } rc1 = spapr_vio_send_crq(&s->vdev, req->crq.raw); diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 6610b3aab3..b0d7517cb1 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -304,6 +304,8 @@ static void virtio_scsi_command_complete(SCSIRequest *r, uint32_t status, size_t resid) { VirtIOSCSIReq *req = r->hba_private; + VirtIOSCSI *s = req->dev; + VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); uint32_t sense_len; if (r->io_canceled) { @@ -317,7 +319,7 @@ static void virtio_scsi_command_complete(SCSIRequest *r, uint32_t status, } else { req->resp.cmd->resid = 0; sense_len = scsi_req_get_sense(r, req->resp.cmd->sense, - VIRTIO_SCSI_SENSE_SIZE); + vs->sense_size); req->resp.cmd->sense_len = tswap32(sense_len); } virtio_scsi_complete_req(req); diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index e5fc39d504..1adb54906e 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -31,6 +31,7 @@ typedef struct SCSISense { uint8_t ascq; } SCSISense; +#define SCSI_SENSE_BUF_SIZE_OLD 96 #define SCSI_SENSE_BUF_SIZE 252 struct SCSICommand { diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index ded8e2302f..e7e170561d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -650,6 +650,9 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \ VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num) \ + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t) + #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0) |