Skip to contentSkip to conversation

scsi-generic: fix get_stream_blocksize

PATCH New Paolo Bonzini 1 participant 1 message Sep 9, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi-generic: fix get_stream_blocksize

The computation of the block size is completely broken; mode page 0 is vendor specific. Use the right SCSI command instead.

---
 hw/scsi-generic.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
hw/scsi-generic.c +3 -4
index cb5d4f1..3202e5a 100644
@@ -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)
Signature · 1 line
1.7.6