Revision 7877903a hw/scsi-disk.c
b/hw/scsi-disk.c | ||
---|---|---|
66 | 66 |
{ |
67 | 67 |
SCSIDevice qdev; |
68 | 68 |
uint32_t removable; |
69 |
uint64_t max_lba; |
|
70 | 69 |
bool media_changed; |
71 | 70 |
bool media_event; |
72 | 71 |
QEMUBH *bh; |
... | ... | |
1175 | 1174 |
/* Returned value is the address of the last sector. */ |
1176 | 1175 |
nb_sectors--; |
1177 | 1176 |
/* Remember the new size for read/write sanity checking. */ |
1178 |
s->max_lba = nb_sectors; |
|
1177 |
s->qdev.max_lba = nb_sectors;
|
|
1179 | 1178 |
/* Clip to 2TB, instead of returning capacity modulo 2TB. */ |
1180 | 1179 |
if (nb_sectors > UINT32_MAX) { |
1181 | 1180 |
nb_sectors = UINT32_MAX; |
... | ... | |
1230 | 1229 |
/* Returned value is the address of the last sector. */ |
1231 | 1230 |
nb_sectors--; |
1232 | 1231 |
/* Remember the new size for read/write sanity checking. */ |
1233 |
s->max_lba = nb_sectors; |
|
1232 |
s->qdev.max_lba = nb_sectors;
|
|
1234 | 1233 |
outbuf[0] = (nb_sectors >> 56) & 0xff; |
1235 | 1234 |
outbuf[1] = (nb_sectors >> 48) & 0xff; |
1236 | 1235 |
outbuf[2] = (nb_sectors >> 40) & 0xff; |
... | ... | |
1345 | 1344 |
case READ_16: |
1346 | 1345 |
len = r->req.cmd.xfer / s->qdev.blocksize; |
1347 | 1346 |
DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len); |
1348 |
if (r->req.cmd.lba > s->max_lba) { |
|
1347 |
if (r->req.cmd.lba > s->qdev.max_lba) {
|
|
1349 | 1348 |
goto illegal_lba; |
1350 | 1349 |
} |
1351 | 1350 |
r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512); |
... | ... | |
1362 | 1361 |
DPRINTF("Write %s(sector %" PRId64 ", count %d)\n", |
1363 | 1362 |
(command & 0xe) == 0xe ? "And Verify " : "", |
1364 | 1363 |
r->req.cmd.lba, len); |
1365 |
if (r->req.cmd.lba > s->max_lba) { |
|
1364 |
if (r->req.cmd.lba > s->qdev.max_lba) {
|
|
1366 | 1365 |
goto illegal_lba; |
1367 | 1366 |
} |
1368 | 1367 |
r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512); |
... | ... | |
1388 | 1387 |
case SEEK_10: |
1389 | 1388 |
DPRINTF("Seek(%d) (sector %" PRId64 ")\n", command == SEEK_6 ? 6 : 10, |
1390 | 1389 |
r->req.cmd.lba); |
1391 |
if (r->req.cmd.lba > s->max_lba) { |
|
1390 |
if (r->req.cmd.lba > s->qdev.max_lba) {
|
|
1392 | 1391 |
goto illegal_lba; |
1393 | 1392 |
} |
1394 | 1393 |
break; |
... | ... | |
1398 | 1397 |
DPRINTF("WRITE SAME(16) (sector %" PRId64 ", count %d)\n", |
1399 | 1398 |
r->req.cmd.lba, len); |
1400 | 1399 |
|
1401 |
if (r->req.cmd.lba > s->max_lba) { |
|
1400 |
if (r->req.cmd.lba > s->qdev.max_lba) {
|
|
1402 | 1401 |
goto illegal_lba; |
1403 | 1402 |
} |
1404 | 1403 |
|
... | ... | |
1457 | 1456 |
if (nb_sectors) { |
1458 | 1457 |
nb_sectors--; |
1459 | 1458 |
} |
1460 |
s->max_lba = nb_sectors; |
|
1459 |
s->qdev.max_lba = nb_sectors;
|
|
1461 | 1460 |
} |
1462 | 1461 |
|
1463 | 1462 |
static void scsi_destroy(SCSIDevice *dev) |
Also available in: Unified diff