From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS7Pu-0004KP-Rw for qemu-devel@nongnu.org; Thu, 02 Jun 2011 08:54:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QS7Ps-0008KR-4m for qemu-devel@nongnu.org; Thu, 02 Jun 2011 08:54:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS7Pr-0008K8-J4 for qemu-devel@nongnu.org; Thu, 02 Jun 2011 08:54:23 -0400 Date: Thu, 2 Jun 2011 15:54:41 +0300 From: "Michael S. Tsirkin" Message-ID: <20110602125441.GG7141@redhat.com> References: <4DD6246F.4080802@gnu.org> <20110601084922.GA5863@redhat.com> <4DE62992.9070705@redhat.com> <20110601125124.GB12294@redhat.com> <4DE63F3E.6040805@redhat.com> <20110601143619.GB14626@redhat.com> <4DE661E0.6080709@redhat.com> <20110602114148.GA7141@redhat.com> <4DE77BEC.1050707@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DE77BEC.1050707@redhat.com> Subject: Re: [Qemu-devel] virtio scsi host draft specification, v2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel , Stefan Hajnoczi On Thu, Jun 02, 2011 at 02:02:52PM +0200, Paolo Bonzini wrote: > On 06/02/2011 01:41 PM, Michael S. Tsirkin wrote: > >Now to our problem: > >As far as I can tell there are two input buffers in each request: sense > >and data. Right? > > > >If sense is fixed length, we can simply put it first, have device write > >sense then data. This does not seem too limiting, if you want a lot of > >flexibility sense length can be in device config. If we don't want to > >limit ourselves to fixed length sense, we would have driver use two > >heads for a request. This is possible but one needs to be careful in > >the driver to make sure there's enough space for both requests. Maybe > >add_bufs API to add multiple bufs might be a good idea here. > > I should be on holiday today so I'll answer this quickly. Sounds > like we can converge, I'll put data at the end and define the length > of sense in the config: the device writes a default (defined by the > spec to be always 96) and the driver can modify it. The _single_ > head would contain: > > - read-only: command etc. > > followed by: > > - write-only: sense, status etc. > > followed by: > > - read-only: data to device > - write-only: data from device Yes, this works. > IIUC, qemu only sees a bunch of read-only and write-only buffers. > It doesn't see the relative ordering of read-only vs. write-only. In virtio write is always before read. > But it knows the sizes of read-only and write-only data, so it can > figure out datain_size and dataout_size. sense_size is in the > config, so neither of the three needs to be in the request. > > sense_len needs to stay, since any number of bytes can be written in > the sense buffer. I think this means sense_len needs to go into the in buffer as well. As head is first it's an out buffer. > The used-length field should be usable for > uni-directional commands, but I'm not sure about commands that have > both datain and dataout. I'll read the SCSI spec about it tomorrow. used-length is the part of in buffer actually written. actual data len is thus used-length - 96 (sense is assumed to be fixed length by virtio ring, sense_len tells driver how many bytes are actually valid). > > Making qemu support arbitrarily partitioned buffers may require some > extra utility functions to work on iovecs, but nothing too complex. > If your patches already contain something like that, please dig them > up so I can avoid duplicate work! > > Paolo Yes. Will do. -- MST