@@ -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)
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(-)