mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-08 11:22:52 +00:00
Fix SCSI off-by-one device size.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2091 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
6eb5733a3c
commit
51c1ebb1bc
@ -348,6 +348,9 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
|
|||||||
/* The normal LEN field for this command is zero. */
|
/* The normal LEN field for this command is zero. */
|
||||||
memset(s->buf, 0, 8);
|
memset(s->buf, 0, 8);
|
||||||
bdrv_get_geometry(s->bdrv, &nb_sectors);
|
bdrv_get_geometry(s->bdrv, &nb_sectors);
|
||||||
|
/* Returned value is the address of the last sector. */
|
||||||
|
if (nb_sectors) {
|
||||||
|
nb_sectors--;
|
||||||
s->buf[0] = (nb_sectors >> 24) & 0xff;
|
s->buf[0] = (nb_sectors >> 24) & 0xff;
|
||||||
s->buf[1] = (nb_sectors >> 16) & 0xff;
|
s->buf[1] = (nb_sectors >> 16) & 0xff;
|
||||||
s->buf[2] = (nb_sectors >> 8) & 0xff;
|
s->buf[2] = (nb_sectors >> 8) & 0xff;
|
||||||
@ -357,6 +360,9 @@ int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)
|
|||||||
s->buf[6] = s->cluster_size * 2;
|
s->buf[6] = s->cluster_size * 2;
|
||||||
s->buf[7] = 0;
|
s->buf[7] = 0;
|
||||||
s->buf_len = 8;
|
s->buf_len = 8;
|
||||||
|
} else {
|
||||||
|
scsi_command_complete(s, SENSE_NOT_READY);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x08:
|
case 0x08:
|
||||||
case 0x28:
|
case 0x28:
|
||||||
|
Loading…
Reference in New Issue
Block a user