Revision 74382217 hw/scsi-generic.c

b/hw/scsi-generic.c
79 79
    s->driver_status = 0;
80 80
}
81 81

  
82
static int scsi_get_sense(SCSIRequest *req, uint8_t *outbuf, int len)
83
{
84
    SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, req->dev);
85
    int size = SCSI_SENSE_BUF_SIZE;
86

  
87
    if (!(s->driver_status & SG_ERR_DRIVER_SENSE)) {
88
        size = scsi_build_sense(SENSE_CODE(NO_SENSE), s->sensebuf,
89
                                SCSI_SENSE_BUF_SIZE, 0);
90
    }
91
    if (size > len) {
92
        size = len;
93
    }
94
    memcpy(outbuf, s->sensebuf, size);
95

  
96
    return size;
97
}
98

  
82 99
static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun)
83 100
{
84 101
    SCSIRequest *req;
......
535 552
    .write_data   = scsi_write_data,
536 553
    .cancel_io    = scsi_cancel_io,
537 554
    .get_buf      = scsi_get_buf,
555
    .get_sense    = scsi_get_sense,
538 556
    .qdev.props   = (Property[]) {
539 557
        DEFINE_BLOCK_PROPERTIES(SCSIGenericState, qdev.conf),
540 558
        DEFINE_PROP_END_OF_LIST(),

Also available in: Unified diff