Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 56

kvm-83-270.el5_11.src.rpm

From 44834a9ed123f368e76f141d92f1017b167ede71 Mon Sep 17 00:00:00 2001
From: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Date: Wed, 28 Jan 2009 21:58:29 +0000
Subject: [PATCH 51/54] 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>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Upstream-status: applied(qemu), pending(kvm/maint/2.6.29)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6469 c046a42c-6fe2-441c-8c8c-71466251a162

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/hw/scsi-disk.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/scsi-disk.c b/qemu/hw/scsi-disk.c
index 7d5c851..fe8a419 100644
--- a/qemu/hw/scsi-disk.c
+++ b/qemu/hw/scsi-disk.c
@@ -683,6 +683,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--;
@@ -783,6 +784,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--;
-- 
1.6.1