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