Revision 314a3299 hw/scsi-disk.c
b/hw/scsi-disk.c | ||
---|---|---|
343 | 343 |
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); |
344 | 344 |
bool first; |
345 | 345 |
|
346 |
if (r->sector_count == (uint32_t)-1) { |
|
347 |
DPRINTF("Read buf_len=%zd\n", r->iov.iov_len); |
|
348 |
r->sector_count = 0; |
|
349 |
r->started = true; |
|
350 |
scsi_req_data(&r->req, r->iov.iov_len); |
|
351 |
return; |
|
352 |
} |
|
353 | 346 |
DPRINTF("Read sector_count=%d\n", r->sector_count); |
354 | 347 |
if (r->sector_count == 0) { |
355 | 348 |
/* This also clears the sense buffer for REQUEST SENSE. */ |
... | ... | |
1262 | 1255 |
return 0; |
1263 | 1256 |
} |
1264 | 1257 |
|
1258 |
static void scsi_disk_emulate_read_data(SCSIRequest *req) |
|
1259 |
{ |
|
1260 |
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req); |
|
1261 |
int buflen = r->iov.iov_len; |
|
1262 |
|
|
1263 |
if (buflen) { |
|
1264 |
DPRINTF("Read buf_len=%zd\n", buflen); |
|
1265 |
r->iov.iov_len = 0; |
|
1266 |
r->started = true; |
|
1267 |
scsi_req_data(&r->req, buflen); |
|
1268 |
return; |
|
1269 |
} |
|
1270 |
|
|
1271 |
/* This also clears the sense buffer for REQUEST SENSE. */ |
|
1272 |
scsi_req_complete(&r->req, GOOD); |
|
1273 |
} |
|
1274 |
|
|
1275 |
static void scsi_disk_emulate_write_data(SCSIRequest *req) |
|
1276 |
{ |
|
1277 |
abort(); |
|
1278 |
} |
|
1279 |
|
|
1265 | 1280 |
static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf) |
1266 | 1281 |
{ |
1267 | 1282 |
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req); |
... | ... | |
1532 | 1547 |
scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); |
1533 | 1548 |
return 0; |
1534 | 1549 |
} |
1535 |
assert(!r->req.aiocb && r->sector_count == 0);
|
|
1550 |
assert(!r->req.aiocb); |
|
1536 | 1551 |
r->iov.iov_len = MIN(buflen, req->cmd.xfer); |
1537 |
r->sector_count = -1; |
|
1538 | 1552 |
if (r->iov.iov_len == 0) { |
1539 | 1553 |
scsi_req_complete(&r->req, GOOD); |
1540 | 1554 |
} |
... | ... | |
1785 | 1799 |
.size = sizeof(SCSIDiskReq), |
1786 | 1800 |
.free_req = scsi_free_request, |
1787 | 1801 |
.send_command = scsi_disk_emulate_command, |
1788 |
.read_data = scsi_read_data, |
|
1789 |
.write_data = scsi_write_data, |
|
1802 |
.read_data = scsi_disk_emulate_read_data,
|
|
1803 |
.write_data = scsi_disk_emulate_write_data,
|
|
1790 | 1804 |
.get_buf = scsi_get_buf, |
1791 | 1805 |
}; |
1792 | 1806 |
|
Also available in: Unified diff