qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] scsi-generic: fix get_stream_blocksize
Date: Fri,  9 Sep 2011 16:47:45 +0200	[thread overview]
Message-ID: <1315579665-6935-1-git-send-email-pbonzini@redhat.com> (raw)

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

                 reply	other threads:[~2011-09-09 14:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1315579665-6935-1-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).