From c1c0438c800df9579c9ed5385e3cf198ed03d562 Mon Sep 17 00:00:00 2001 From: aliguori Date: Wed, 28 Jan 2009 21:58:29 +0000 Subject: [PATCH] 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 Signed-off-by: Anthony Liguori git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6469 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/scsi-disk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 434c3cb367..bc12e3fc23 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -734,6 +734,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, /* The normal LEN field for this command is zero. */ memset(outbuf, 0, 8); bdrv_get_geometry(s->bdrv, &nb_sectors); + nb_sectors /= s->cluster_size; /* Returned value is the address of the last sector. */ if (nb_sectors) { nb_sectors--; @@ -834,6 +835,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, DPRINTF("SAI READ CAPACITY(16)\n"); memset(outbuf, 0, len); bdrv_get_geometry(s->bdrv, &nb_sectors); + nb_sectors /= s->cluster_size; /* Returned value is the address of the last sector. */ if (nb_sectors) { nb_sectors--; -- 2.11.4.GIT