* [Qemu-devel] [PATCH] scsi-generic: fix get_stream_blocksize
@ 2011-09-09 14:47 Paolo Bonzini
0 siblings, 0 replies; only message in thread
From: Paolo Bonzini @ 2011-09-09 14:47 UTC (permalink / raw)
To: qemu-devel
The computation of the block size is completely broken; mode page 0
is vendor specific. Use the right SCSI command instead.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi-generic.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index cb5d4f1..3202e5a 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -343,7 +343,7 @@ static int get_blocksize(BlockDriverState *bdrv)
if (ret < 0)
return -1;
- return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
+ return ldl_be_p(&buf[4]);
}
static int get_stream_blocksize(BlockDriverState *bdrv)
@@ -356,8 +356,7 @@ static int get_stream_blocksize(BlockDriverState *bdrv)
memset(cmd, 0, sizeof(cmd));
memset(buf, 0, sizeof(buf));
- cmd[0] = MODE_SENSE;
- cmd[4] = sizeof(buf);
+ cmd[0] = READ_BLOCK_LIMITS;
memset(&io_header, 0, sizeof(io_header));
io_header.interface_id = 'S';
@@ -374,7 +373,7 @@ static int get_stream_blocksize(BlockDriverState *bdrv)
if (ret < 0)
return -1;
- return (buf[9] << 16) | (buf[10] << 8) | buf[11];
+ return ldl_be_p(&buf[0]) & 0xffffff;
}
static void scsi_generic_reset(DeviceState *dev)
--
1.7.6
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-09 14:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-09 14:47 [Qemu-devel] [PATCH] scsi-generic: fix get_stream_blocksize Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).