diff mbox

uapi/virtio_scsi: allow overriding CDB/SENSE size

Message ID 20150311141903-mutt-send-email-mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin March 11, 2015, 1:19 p.m. UTC
QEMU wants to use virtio scsi structures with
a different VIRTIO_SCSI_CDB_SIZE/VIRTIO_SCSI_SENSE_SIZE,
let's add ifdefs to allow overriding them.

Keep the old defines under new names:
VIRTIO_SCSI_CDB_DEFAULT_SIZE/VIRTIO_SCSI_SENSE_DEFAULT_SIZE,
since that's what these values really are:
defaults for cdb/sense size fields.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/uapi/linux/virtio_scsi.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini March 11, 2015, 1:31 p.m. UTC | #1
On 11/03/2015 14:19, Michael S. Tsirkin wrote:
> QEMU wants to use virtio scsi structures with
> a different VIRTIO_SCSI_CDB_SIZE/VIRTIO_SCSI_SENSE_SIZE,
> let's add ifdefs to allow overriding them.
> 
> Keep the old defines under new names:
> VIRTIO_SCSI_CDB_DEFAULT_SIZE/VIRTIO_SCSI_SENSE_DEFAULT_SIZE,
> since that's what these values really are:
> defaults for cdb/sense size fields.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

QEMU will then use a zero-element array instead of a flexible array
member.  That's okay.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

> ---
>  include/uapi/linux/virtio_scsi.h | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h
> index 42b9370..cc18ef8 100644
> --- a/include/uapi/linux/virtio_scsi.h
> +++ b/include/uapi/linux/virtio_scsi.h
> @@ -29,8 +29,16 @@
>  
>  #include <linux/virtio_types.h>
>  
> -#define VIRTIO_SCSI_CDB_SIZE   32
> -#define VIRTIO_SCSI_SENSE_SIZE 96
> +/* Default values of the CDB and sense data size configuration fields */
> +#define VIRTIO_SCSI_CDB_DEFAULT_SIZE   32
> +#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96
> +
> +#ifndef VIRTIO_SCSI_CDB_SIZE
> +#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE
> +#endif
> +#ifndef VIRTIO_SCSI_SENSE_SIZE
> +#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE
> +#endif
>  
>  /* SCSI command request, followed by data-out */
>  struct virtio_scsi_cmd_req {
>
Michael S. Tsirkin March 11, 2015, 1:49 p.m. UTC | #2
On Wed, Mar 11, 2015 at 02:31:51PM +0100, Paolo Bonzini wrote:
> 
> 
> On 11/03/2015 14:19, Michael S. Tsirkin wrote:
> > QEMU wants to use virtio scsi structures with
> > a different VIRTIO_SCSI_CDB_SIZE/VIRTIO_SCSI_SENSE_SIZE,
> > let's add ifdefs to allow overriding them.
> > 
> > Keep the old defines under new names:
> > VIRTIO_SCSI_CDB_DEFAULT_SIZE/VIRTIO_SCSI_SENSE_DEFAULT_SIZE,
> > since that's what these values really are:
> > defaults for cdb/sense size fields.
> > 
> > Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> QEMU will then use a zero-element array instead of a flexible array
> member.  That's okay.

Or a flex array member: just do
#define VIRTIO_SCSI_CDB_SIZE 
#define VIRTIO_SCSI_SENSE_SIZE 
before including this header.


> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> Paolo
> 
> > ---
> >  include/uapi/linux/virtio_scsi.h | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h
> > index 42b9370..cc18ef8 100644
> > --- a/include/uapi/linux/virtio_scsi.h
> > +++ b/include/uapi/linux/virtio_scsi.h
> > @@ -29,8 +29,16 @@
> >  
> >  #include <linux/virtio_types.h>
> >  
> > -#define VIRTIO_SCSI_CDB_SIZE   32
> > -#define VIRTIO_SCSI_SENSE_SIZE 96
> > +/* Default values of the CDB and sense data size configuration fields */
> > +#define VIRTIO_SCSI_CDB_DEFAULT_SIZE   32
> > +#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96
> > +
> > +#ifndef VIRTIO_SCSI_CDB_SIZE
> > +#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE
> > +#endif
> > +#ifndef VIRTIO_SCSI_SENSE_SIZE
> > +#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE
> > +#endif
> >  
> >  /* SCSI command request, followed by data-out */
> >  struct virtio_scsi_cmd_req {
> >
Michael S. Tsirkin March 12, 2015, 11:06 a.m. UTC | #3
On Wed, Mar 11, 2015 at 02:19:03PM +0100, Michael S. Tsirkin wrote:
> QEMU wants to use virtio scsi structures with
> a different VIRTIO_SCSI_CDB_SIZE/VIRTIO_SCSI_SENSE_SIZE,
> let's add ifdefs to allow overriding them.
> 
> Keep the old defines under new names:
> VIRTIO_SCSI_CDB_DEFAULT_SIZE/VIRTIO_SCSI_SENSE_DEFAULT_SIZE,
> since that's what these values really are:
> defaults for cdb/sense size fields.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---

Rusty, pls note, if possible I'd like this one
merged for 4.0 because it's important for QEMU
(which now imports linux headers).


>  include/uapi/linux/virtio_scsi.h | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h
> index 42b9370..cc18ef8 100644
> --- a/include/uapi/linux/virtio_scsi.h
> +++ b/include/uapi/linux/virtio_scsi.h
> @@ -29,8 +29,16 @@
>  
>  #include <linux/virtio_types.h>
>  
> -#define VIRTIO_SCSI_CDB_SIZE   32
> -#define VIRTIO_SCSI_SENSE_SIZE 96
> +/* Default values of the CDB and sense data size configuration fields */
> +#define VIRTIO_SCSI_CDB_DEFAULT_SIZE   32
> +#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96
> +
> +#ifndef VIRTIO_SCSI_CDB_SIZE
> +#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE
> +#endif
> +#ifndef VIRTIO_SCSI_SENSE_SIZE
> +#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE
> +#endif
>  
>  /* SCSI command request, followed by data-out */
>  struct virtio_scsi_cmd_req {
> -- 
> MST
Rusty Russell March 13, 2015, 1:29 a.m. UTC | #4
"Michael S. Tsirkin" <mst@redhat.com> writes:
> On Wed, Mar 11, 2015 at 02:19:03PM +0100, Michael S. Tsirkin wrote:
>> QEMU wants to use virtio scsi structures with
>> a different VIRTIO_SCSI_CDB_SIZE/VIRTIO_SCSI_SENSE_SIZE,
>> let's add ifdefs to allow overriding them.
>> 
>> Keep the old defines under new names:
>> VIRTIO_SCSI_CDB_DEFAULT_SIZE/VIRTIO_SCSI_SENSE_DEFAULT_SIZE,
>> since that's what these values really are:
>> defaults for cdb/sense size fields.
>> 
>> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>
> Rusty, pls note, if possible I'd like this one
> merged for 4.0 because it's important for QEMU
> (which now imports linux headers).

OK, applied.

Thanks,
Rusty.


>
>
>>  include/uapi/linux/virtio_scsi.h | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>> 
>> diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h
>> index 42b9370..cc18ef8 100644
>> --- a/include/uapi/linux/virtio_scsi.h
>> +++ b/include/uapi/linux/virtio_scsi.h
>> @@ -29,8 +29,16 @@
>>  
>>  #include <linux/virtio_types.h>
>>  
>> -#define VIRTIO_SCSI_CDB_SIZE   32
>> -#define VIRTIO_SCSI_SENSE_SIZE 96
>> +/* Default values of the CDB and sense data size configuration fields */
>> +#define VIRTIO_SCSI_CDB_DEFAULT_SIZE   32
>> +#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96
>> +
>> +#ifndef VIRTIO_SCSI_CDB_SIZE
>> +#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE
>> +#endif
>> +#ifndef VIRTIO_SCSI_SENSE_SIZE
>> +#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE
>> +#endif
>>  
>>  /* SCSI command request, followed by data-out */
>>  struct virtio_scsi_cmd_req {
>> -- 
>> MST
diff mbox

Patch

diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h
index 42b9370..cc18ef8 100644
--- a/include/uapi/linux/virtio_scsi.h
+++ b/include/uapi/linux/virtio_scsi.h
@@ -29,8 +29,16 @@ 
 
 #include <linux/virtio_types.h>
 
-#define VIRTIO_SCSI_CDB_SIZE   32
-#define VIRTIO_SCSI_SENSE_SIZE 96
+/* Default values of the CDB and sense data size configuration fields */
+#define VIRTIO_SCSI_CDB_DEFAULT_SIZE   32
+#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96
+
+#ifndef VIRTIO_SCSI_CDB_SIZE
+#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE
+#endif
+#ifndef VIRTIO_SCSI_SENSE_SIZE
+#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE
+#endif
 
 /* SCSI command request, followed by data-out */
 struct virtio_scsi_cmd_req {