From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: Hannes Reinecke <hare@suse.de>
Cc: zwanp@cn.ibm.com, linuxram@us.ibm.com, qemu-devel@nongnu.org,
"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
virtualization@lists.linux-foundation.org,
Cong Meng <mc@linux.vnet.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [Qemu-devel] [PATCH 1/2 v1] blkdrv: Add queue limits parameters for sg block drive
Date: Fri, 24 Aug 2012 10:05:07 +0100 [thread overview]
Message-ID: <20120824090507.GA5391@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <50375AD6.8060203@suse.de>
On Fri, Aug 24, 2012 at 12:43:34PM +0200, Hannes Reinecke wrote:
> On 08/24/2012 09:56 AM, Paolo Bonzini wrote:
> >Il 24/08/2012 02:45, Nicholas A. Bellinger ha scritto:
> >>So up until very recently, TCM would accept an I/O request for an DATA
> >>I/O type CDB with a max_sectors larger than the reported max_sectors for
> >>it's TCM backend (regardless of backend type), and silently generate N
> >>backend 'tasks' to complete the single initiator generated command.
> >
> >This is what QEMU does if you use scsi-block, except for MMC devices
> >(because of the insanity of the commands used for burning).
> >
> >>Also FYI for Paolo, for control type CDBs I've never actually seen an
> >>allocation length exceed max_sectors, so in practice AFAIK this only
> >>happens for DATA I/O type CDBs.
> >
> >Yes, that was my impression as well.
> >
> >>This was historically required by the pSCSI backend driver (using a
> >>number of old SCSI passthrough interfaces) in order to support this very
> >>type of case described above, but over the years the logic ended up
> >>creeping into various other non-passthrough backend drivers like IBLOCK
> >>+FILEIO. So for v3.6-rc1 code, hch ended up removing the 'task' logic
> >>thus allowing backends (and the layers below) to the I/O sectors >
> >>max_sectors handling work, allowing modern pSCSI using struct request to
> >>do the same. (hch assured me this works now for pSCSI)
> >
> >So now LIO and QEMU work the same. (Did he test tapes too?)
> >
> >>Anyways, I think having the guest limit virtio-scsi DATA I/O to
> >>max_sectors based upon the host accessible block limits is reasonable
> >>approach to consider. Reducing this value even further based upon the
> >>lowest max_sectors available amongst possible migration hosts would be a
> >>good idea here to avoid having to reject any I/O's exceeding a new
> >>host's device block queue limits.
> >
> >Yeah, it's reasonable _assuming it is needed at all_. For disks, it is
> >not needed. For CD-ROMs it is, but right now we have only one report
> >and it is using USB so we don't know if the problem is in the drive or
> >rather in the USB bridge (whose quality usually leaves much to be desired).
> >
> >So in the only observed case, the fix would really be a workaround; the
> >right thing to do with USB devices is to use USB passthrough.
> >
>
> Hehe. So finally someone else stumbled across this one.
>
> All is fine and dandy as long as you're able to use scsi-disk.
> As soon as you're forced to use scsi-generic we're in trouble.
>
> With scsi-generic we actually have two problems:
> 1) scsi-generic just acts as a pass-through and passes the commands
> as-is, including the scatter-gather information as formatted by
> the guest. So the guest could easily format an SG_IO comand
> which will not be compatible with the host.
> 2) The host is not able to differentiate between a malformed
> SG_IO command and a real I/O error; in both cases it'll return
> -EIO.
>
> So we can fix this by either
> a) ignore (as we do nowadays :-)
> b) Fixup scsi-generic to inspect and modify SG_IO information
> to ensure the host-limits are respected
> c) Fixup the host to differentiate between a malformed SG_IO
> and a real I/O error.
>
> c) would only be feasible for Linux et al. _personally_ I would
> prefer that approach, as I fail to see why we cannot return a proper
> error code here.
> But I already can hear the outraged cry 'POSIX! POSIX!', so I guess
> it's not going to happen anytime soon.
> So I would vote for b).
> Yes, it's painful. But in the long run we'll have to do an SG_IO
> inspection anyway, otherwise we'll always be susceptible to
> malicious SG_IO attacks.
Are you suggesting we do not expose host block queue limits to the
guest. Instead we should inspect and reformat SG_IO requests in QEMU?
Reformatting seems hard because there are many possible SCSI
commands/sub-commands and we would have to whitelist them on a
case-by-case basis.
That sounds like more work than exposing the block queue limits using
Cong Meng's patches.
On a side-note, are you thinking of blacklisting/whitelisting certain
commands that don't make sense or would have an unintended effect if
sent from a guest (e.g. reservations)? That would be an interesting
topic for another email thread, I'd love to learn what weird things we
need to protect against.
Stefan
next prev parent reply other threads:[~2012-08-24 9:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-21 8:23 [Qemu-devel] [PATCH 1/2 v1] blkdrv: Add queue limits parameters for sg block drive Cong Meng
2012-08-21 8:23 ` [Qemu-devel] [PATCH 2/2 v1] virtio-scsi: set per-LUN queue limits for sg devices Cong Meng
2012-08-21 9:56 ` Stefan Hajnoczi
2012-08-21 8:48 ` [Qemu-devel] [PATCH 1/2 v1] blkdrv: Add queue limits parameters for sg block drive Paolo Bonzini
2012-08-21 9:41 ` Cong Meng
2012-08-21 9:52 ` Stefan Hajnoczi
2012-08-21 10:14 ` Paolo Bonzini
2012-08-22 11:04 ` Cong Meng
2012-08-22 12:09 ` Paolo Bonzini
2012-08-22 13:13 ` Stefan Hajnoczi
2012-08-22 14:13 ` Paolo Bonzini
2012-08-23 9:31 ` Cong Meng
2012-08-23 10:03 ` Paolo Bonzini
2012-08-23 10:08 ` Stefan Hajnoczi
2012-08-23 10:52 ` Paolo Bonzini
2012-08-23 12:08 ` Stefan Hajnoczi
2012-08-24 0:45 ` Nicholas A. Bellinger
2012-08-24 7:56 ` Paolo Bonzini
2012-08-24 10:43 ` Hannes Reinecke
2012-08-24 9:05 ` Stefan Hajnoczi [this message]
2012-08-24 9:14 ` Paolo Bonzini
2012-08-21 9:49 ` Stefan Hajnoczi
2012-08-21 18:31 ` Blue Swirl
2012-08-22 8:25 ` Stefan Hajnoczi
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=20120824090507.GA5391@stefanha-thinkpad.localdomain \
--to=stefanha@linux.vnet.ibm.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linuxram@us.ibm.com \
--cc=mc@linux.vnet.ibm.com \
--cc=nab@linux-iscsi.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=zwanp@cn.ibm.com \
/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).