Commit c1c0438c800df9579c9ed5385e3cf198ed03d562
1 parent
86106e59
SCSI divide capacity by s->cluster_size (Rik van Riel)
Paul Brook pointed out that the number of sectors reported by the SCSI read capacity commands needs to be divided by s->cluster_size, because bdrv_get_geometry reports the number of 512 byte sectors, while emulated CDROMs report 2048 byte sectors back to the guest. This has no consequences for emulated hard disks, which use a cluster size of 1. aliguori: fixed typo Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6469 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
2 additions
and
0 deletions
hw/scsi-disk.c
@@ -734,6 +734,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, | @@ -734,6 +734,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, | ||
734 | /* The normal LEN field for this command is zero. */ | 734 | /* The normal LEN field for this command is zero. */ |
735 | memset(outbuf, 0, 8); | 735 | memset(outbuf, 0, 8); |
736 | bdrv_get_geometry(s->bdrv, &nb_sectors); | 736 | bdrv_get_geometry(s->bdrv, &nb_sectors); |
737 | + nb_sectors /= s->cluster_size; | ||
737 | /* Returned value is the address of the last sector. */ | 738 | /* Returned value is the address of the last sector. */ |
738 | if (nb_sectors) { | 739 | if (nb_sectors) { |
739 | nb_sectors--; | 740 | nb_sectors--; |
@@ -834,6 +835,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, | @@ -834,6 +835,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, | ||
834 | DPRINTF("SAI READ CAPACITY(16)\n"); | 835 | DPRINTF("SAI READ CAPACITY(16)\n"); |
835 | memset(outbuf, 0, len); | 836 | memset(outbuf, 0, len); |
836 | bdrv_get_geometry(s->bdrv, &nb_sectors); | 837 | bdrv_get_geometry(s->bdrv, &nb_sectors); |
838 | + nb_sectors /= s->cluster_size; | ||
837 | /* Returned value is the address of the last sector. */ | 839 | /* Returned value is the address of the last sector. */ |
838 | if (nb_sectors) { | 840 | if (nb_sectors) { |
839 | nb_sectors--; | 841 | nb_sectors--; |