This makes some changes to the virtio-scsi event specification, so that it is now possible to use virtio-scsi events in the implementation of the QEMU "block_resize" command. Thanks to Cong Meng for finally implementing virtio-scsi hotplug, which made me look at block_resize again! Paolo Bonzini (2): virtio-scsi spec: unify event structs virtio-scsi spec: add configuration change event virtio-spec.lyx | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 4 deletions(-) -- 1.7.10.4
All currently defined event structs have the same fields. Simplify the driver by enforcing this also for future structs. Signed-off-by: Paolo Bonzini <pbonzini at redhat.com> --- virtio-spec.lyx | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/virtio-spec.lyx b/virtio-spec.lyx index 905e619..f8b214b 100644 --- a/virtio-spec.lyx +++ b/virtio-spec.lyx @@ -8207,7 +8207,20 @@ struct virtio_scsi_event { \begin_layout Plain Layout +\change_deleted 1531152142 1342440791 + ... +\change_inserted 1531152142 1342440791 +u8 lun[8]; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 1531152142 1342440791 + + u32 reason; +\change_unchanged + \end_layout \begin_layout Plain Layout @@ -8221,16 +8234,32 @@ struct virtio_scsi_event { \end_layout \begin_layout Standard -If bit 31 is set in the event field, the device failed to report an event - due to missing buffers. +If bit 31 is set in the +\series bold +event +\series default + field, the device failed to report an event due to missing buffers. In this case, the driver should poll the logical units for unit attention conditions, and/or do whatever form of bus scan is appropriate for the guest operating system. \end_layout \begin_layout Standard -Other data that the device writes to the buffer depends on the contents - of the event field. + +\change_deleted 1531152142 1342440830 +Other data that the device writes to the buffer +\change_inserted 1531152142 1342440839 +The meaning of the +\series bold +reason +\series default + field +\change_unchanged + depends on the contents of the +\series bold +event +\series default + field. The following events are defined: \end_layout @@ -8312,36 +8341,50 @@ status open \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + struct virtio_scsi_event_reset { \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + // Write-only part \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + u32 event; \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + u8 lun[8]; \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + u32 reason; \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + } \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440799 + \end_layout \begin_layout Plain Layout @@ -8542,40 +8585,58 @@ status open \begin_layout Plain Layout #define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 +\change_deleted 1531152142 1342440854 + \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + struct virtio_scsi_event_an { \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + // Write-only part \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + u32 event; \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + u8 lun[8]; \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + u32 reason; \end_layout \begin_layout Plain Layout +\change_deleted 1531152142 1342440854 + } +\change_unchanged + \end_layout \end_inset -- 1.7.10.4
Paolo Bonzini
2012-Jul-16 14:24 UTC
[PATCH 2/2] virtio-scsi spec: add configuration change event
This adds an event for changes to LUN parameters, for example capacity. These are reported in virtio-blk via configuration changes, and we want a similar functionality in virtio-scsi too. There is no list of supported parameter changes, instead we just refer to the list of sense codes in the SCSI specification. This event will usually be serviced in one of three ways: 1) call an OS service to revalidate the disk, either always or only for some specific sense codes; 2) somehow pass the sense directly to the upper-level driver; 3) inject a TEST UNIT READY command into the upper-level device, so that the OS will see the unit attention code and react. Of course a mix of the three is also possible, depending on how the driver writer prefers to have his layering violations served. Signed-off-by: Paolo Bonzini <pbonzini at redhat.com> --- virtio-spec.lyx | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/virtio-spec.lyx b/virtio-spec.lyx index f8b214b..8d2ac9a 100644 --- a/virtio-spec.lyx +++ b/virtio-spec.lyx @@ -6995,6 +6995,21 @@ VIRTIO_SCSI_F_HOTPLUG (1) The host should enable hot-plug/hot-unplug of new LUNs and targets on the SCSI bus. +\change_inserted 1531152142 1342440342 + +\end_layout + +\begin_layout Description + +\change_inserted 1531152142 1342440768 +VIRTIO_SCSI_F_CHANGE +\begin_inset space ~ +\end_inset + +(2) The host will report changes to LUN parameters via a VIRTIO_SCSI_T_PARAM_CHA +NGE event. +\change_unchanged + \end_layout \end_deeper @@ -8673,6 +8688,86 @@ reason \begin_layout Standard When dropped events are reported, the driver should poll for asynchronous events manually using SCSI commands. +\change_inserted 1531152142 1342439104 + +\end_layout + +\end_deeper +\begin_layout Description + +\change_inserted 1531152142 1342440778 +LUN +\begin_inset space ~ +\end_inset + +parameter +\begin_inset space ~ +\end_inset + +change +\begin_inset space ~ +\end_inset + + +\begin_inset Newline newline +\end_inset + + +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +\change_inserted 1531152142 1342440783 + +#define VIRTIO_SCSI_T_PARAM_CHANGE 3 +\end_layout + +\end_inset + + +\end_layout + +\begin_deeper +\begin_layout Standard + +\change_inserted 1531152142 1342440882 +By sending this event, the device signals that the configuration parameters + (for example the capacity) of a logical unit have changed. + The +\series bold +event +\series default + field is set to VIRTIO_SCSI_T_PARAM_CHANGE. + The +\series bold +lun +\series default + field addresses a logical unit in the SCSI host. +\end_layout + +\begin_layout Standard + +\change_inserted 1531152142 1342440916 +The same event is also reported as a unit attention condition. + The +\series bold +reason +\series default + field contains the additional sense code and additional sense code qualifier, + respectively in bits 0..7 and 8..15. + For example, a change in capacity will be reported as asc 0x2a, ascq 0x09 + (CAPACITY DATA HAS CHANGED). +\end_layout + +\begin_layout Standard + +\change_inserted 1531152142 1342442803 +For MMC devices (inquiry type 5) there would be some overlap between this + event and the asynchronous notification event. + For simplicity, as of this version of the specification the host must + never report this event for MMC devices. \end_layout \end_deeper -- 1.7.10.4
Rusty Russell
2012-Jul-17 00:21 UTC
[PATCH 2/2] virtio-scsi spec: add configuration change event
On Mon, 16 Jul 2012 16:24:37 +0200, Paolo Bonzini <pbonzini at redhat.com> wrote:> This adds an event for changes to LUN parameters, for example capacity. These > are reported in virtio-blk via configuration changes, and we want a similar > functionality in virtio-scsi too.Both applied. Thanks! Rusty.