All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] virtio scsi host draft specification, v2
Date: Wed, 1 Jun 2011 15:51:24 +0300	[thread overview]
Message-ID: <20110601125124.GB12294@redhat.com> (raw)
In-Reply-To: <4DE62992.9070705@redhat.com>

On Wed, Jun 01, 2011 at 01:59:14PM +0200, Paolo Bonzini wrote:
> >>Device initialization
> >>---------------------
> >>
> >>The initialization routine should first of all discover the device's
> >>control virtqueues.
> >>
> >>The driver should then place at least a buffer in the control receiveq.
> >
> >Size of the buffer?
> 
> Good catch.  I'll add this to the configuration information.
> 
> >>     The cdb, data and sense fields must reside in separate buffers.
> >>     The cdb field is always read-only.  The data buffers may be either
> >>     read-only or write-only, depending on the request, with the read-only
> >>     buffers coming first.  The sense buffer is always write-only.
> >>
> >>     The request shall have num_dataout read-only data buffers and
> >>     num_datain write-only data buffers.  One of these two values must be
> >>     zero if the VIRTIO_SCSI_F_INOUT has not been negotiated.
> >
> >Why do num_datain/num_dataout need to be there?
> >We can just look at the number of io/out bufs in
> >virtio descriptors, no?
> 
> This depends on having a single variable-sized datum per direction.
> I'd rather avoid this assumption.

I think it's a sane assumption: does scsi ever give you more?  If you
have many how do you know the size of each?

> >Also, from experience, it's better not to have any layout
> >assumptions - let the guest stick everything in a single
> >in + single out buffer if it desires.
> 
> Ok, changed.
> 
> >>     Remaining fields are filled in by the device.  The sense_len field
> >>     indicates the number of bytes actually written to the sense buffer,
> >>     while the residual field indicates the residual size, calculated as
> >>     data_length - number_of_transferred_bytes.
> >
> >Again virtio gives you total number of written bytes in the used len
> >field.  So just one of these fields will be enough.
> 
> The two fields give completely different information (sense vs. real
> data), and the math has to be done anyway in either the driver or
> the device.  The device is going to be written just once and
> actually it already has the separate information, so I put it in the
> struct and spared some annoyance to driver writers.

Yes but this way you get duplicate information which means
it can get out of sync. Go figure who's right then ...
Further less data->less cache pressure ...

> >>The control receiveq is used by the device to report information on
> >>logical units that are attached to it.  The driver should always
> >>leave a few (?) buffers ready in the control receiveq.  The device may
> >>end up dropping events if it finds no buffer ready.
> >
> >[...] It looks like there's a finite number of possible events.
> 
> If you keep opening and closing the tray from the guest, you could
> fire a possibly unbounded number of events.

In that case only the last one is really interesting.

> >If this mechanism is unreliable, how is it useful?
> 
> Events alone are unreliable, but the combination of events+sense is
> reliable.  And events+sense are still useful because:
> 
> 1) sense codes only provide information when the driver next
> accesses the unit or, at best, the target.  Until then, the driver
> has no clue that the event happened.  Events can be reported at the
> time they happen.  This is important for example when the host
> requests a clean hot-unplug of a disk: if the disk is idle in the
> guest, the driver may never see the event and acknowledge the
> hot-unplug!

right. But if you then drop this because you don't have a buffer,
you get the same problem.

> 2) for this reason, unit attention has no way to signal events on a
> target that is unknown to the driver (because it has just been
> hotplugged).
> 
> Events and sense codes together are reliable because the driver is
> aware of dropped events.

It is?  How is it notified of dropped events?

>  The driver can react to it by rescanning
> the bus (which will let the driver see the unit attention
> conditions) and polling CD-ROM units for events it had subscribed
> to.
> 
> I'll add a short version of the above text to the spec, and I'll
> also add the following dummy event:
> 
> - No event
> 
>     #define VIRTIO_SCSI_T_NO_EVENT         0
> 
>     This event is fired in the following cases:
> 
>     1) When the device detects in the eventq a buffer that is shorter
>     than what is indicated in the configuration field, it will use
>     it immediately and put this dummy value in the event field.
>     A well-written driver will never observe this situation.
> 
>     2) When events are dropped, the device may signal this event as
>     soon as the drivers makes a buffer available, in order to request
>     action from the driver.  In this case, of course, this event will
>     be reported with the VIRTIO_SCSI_T_EVENTS_MISSED flag.

For 2, you don't have a buffer - so how is this event reported?

> This will make it even clearer that no queuing is needed.
> 
> >>- Asynchronous notification
> >>
> >>     #define VIRTIO_SCSI_T_ASYNC_NOTIFY     1
> >>
> >>     struct virtio_scsi_an_event {
> >>         u8  lun[8];
> >>         u32 event;
> >>     }
> >>
> >>     #define VIRTIO_SCSI_EVT_ASYNC_MEDIA_CHANGE        16
> >>
> >>     By sending this event, the device signals that an event was
> >>     fired from a physical interface.  The device only sends events
> >>     that the driver has subscribed to via the "Asynchronous notification
> >>     subscription" command.
> >>
> >>     All fields are written by the device.  The event field is set to
> >>     VIRTIO_SCSI_T_ASYNC_NOTIFY.
> >
> >We'll have to define events, right?
> 
> They are defined in terms of annex A of the MMC spec (see the
> "Asynchronous notification query" command).  Media change is the
> only supported event for now, but others are already defined by the
> MMC spec.
> 
> Paolo

  reply	other threads:[~2011-06-01 12:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20  8:21 [Qemu-devel] virtio scsi host draft specification, v2 Paolo Bonzini
2011-05-28 19:33 ` Stefan Hajnoczi
2011-05-30  9:22   ` Paolo Bonzini
2011-06-01  4:44     ` Stefan Hajnoczi
2011-06-01  8:49 ` Michael S. Tsirkin
2011-06-01 11:59   ` Paolo Bonzini
2011-06-01 12:51     ` Michael S. Tsirkin [this message]
2011-06-01 13:31       ` Paolo Bonzini
2011-06-01 14:36         ` Michael S. Tsirkin
2011-06-01 14:51           ` Avi Kivity
2011-06-02 10:42             ` Michael S. Tsirkin
2011-06-02 11:42               ` Avi Kivity
2011-06-02 11:56                 ` Michael S. Tsirkin
2011-06-02 12:18                   ` Avi Kivity
2011-06-01 15:59           ` Paolo Bonzini
2011-06-02 11:41             ` Michael S. Tsirkin
2011-06-02 12:02               ` Paolo Bonzini
2011-06-02 12:54                 ` Michael S. Tsirkin
2011-06-01 13:46 ` Avi Kivity
2011-06-01 16:25   ` Paolo Bonzini
2011-06-01 16:29     ` Avi Kivity

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=20110601125124.GB12294@redhat.com \
    --to=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.