From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5qCY-00036a-1B for qemu-devel@nongnu.org; Thu, 26 May 2016 03:59:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5qCW-0006wO-4x for qemu-devel@nongnu.org; Thu, 26 May 2016 03:59:29 -0400 Sender: Paolo Bonzini References: <1464243305-10661-1-git-send-email-famz@redhat.com> <1464243305-10661-3-git-send-email-famz@redhat.com> From: Paolo Bonzini Message-ID: <3d76e871-a13f-412c-5cfa-df5e3b0aaef2@redhat.com> Date: Thu, 26 May 2016 09:59:18 +0200 MIME-Version: 1.0 In-Reply-To: <1464243305-10661-3-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] scsi-generic: Merge block max xfer len in INQUIRY response List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz On 26/05/2016 08:15, Fam Zheng wrote: > The rationale is similar to the above mode sense response interception: > this is practically the only channel to communicate restraints from > elsewhere such as host and block driver. > > The scsi bus we attach onto can have a larger max xfer len than what is > accepted by the host file system (guarding between the host scsi LUN and > QEMU), in which case the SG_IO we generate would get -EINVAL. > > Signed-off-by: Fam Zheng The two patches are pretty much separate, so I'm queuing this myself. Thanks, Paolo > --- > hw/scsi/scsi-generic.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c > index 7459465..71372a8 100644 > --- a/hw/scsi/scsi-generic.c > +++ b/hw/scsi/scsi-generic.c > @@ -222,6 +222,18 @@ static void scsi_read_complete(void * opaque, int ret) > r->buf[3] |= 0x80; > } > } > + if (s->type == TYPE_DISK && > + r->req.cmd.buf[0] == INQUIRY && > + r->req.cmd.buf[2] == 0xb0) { > + uint32_t max_xfer_len = blk_get_max_transfer_length(s->conf.blk); > + if (max_xfer_len) { > + stl_be_p(&r->buf[8], max_xfer_len); > + /* Also take care of the opt xfer len. */ > + if (ldl_be_p(&r->buf[12]) > max_xfer_len) { > + stl_be_p(&r->buf[12], max_xfer_len); > + } > + } > + } > scsi_req_data(&r->req, len); > scsi_req_unref(&r->req); > } >