diff mbox

[V4,8/9] qapi: convert BlockdevOptions to use enum discriminator

Message ID 1386740912-1655-9-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia Dec. 11, 2013, 5:48 a.m. UTC
After this patch, hidden enum type BlockdevOptionsKind will not
be generated, and other API can use enum BlockdevDriver.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qapi-schema.json |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

Comments

Eric Blake Dec. 13, 2013, 11:50 p.m. UTC | #1
On 12/10/2013 10:48 PM, Wenchao Xia wrote:
> After this patch, hidden enum type BlockdevOptionsKind will not
> be generated, and other API can use enum BlockdevDriver.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  qapi-schema.json |   14 +++++++++++++-
>  1 files changed, 13 insertions(+), 1 deletions(-)

You know, it might even be better if we just flat out require that ALL
discriminated unions use an enum type, and discontinue support for
open-coded string (with hidden enum generation).  The extra type safety
and potential for introspection that it buys us is worth the change.  I
don't know how much of your series that would affect, but it's food for
thought.
Wayne Xia Dec. 16, 2013, 2:41 a.m. UTC | #2
于 2013/12/14 7:50, Eric Blake 写道:
> On 12/10/2013 10:48 PM, Wenchao Xia wrote:
>> After this patch, hidden enum type BlockdevOptionsKind will not
>> be generated, and other API can use enum BlockdevDriver.
>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>   qapi-schema.json |   14 +++++++++++++-
>>   1 files changed, 13 insertions(+), 1 deletions(-)
>
> You know, it might even be better if we just flat out require that ALL
> discriminated unions use an enum type, and discontinue support for
> open-coded string (with hidden enum generation).  The extra type safety
> and potential for introspection that it buys us is worth the change.  I
> don't know how much of your series that would affect, but it's food for
> thought.
>

   I thought that before, and it is not hard to do, just need
people's confirm that, string discriminator is not needed any more.
Luiz Capitulino Dec. 16, 2013, 9:26 p.m. UTC | #3
On Mon, 16 Dec 2013 10:41:13 +0800
Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:

> 于 2013/12/14 7:50, Eric Blake 写道:
> > On 12/10/2013 10:48 PM, Wenchao Xia wrote:
> >> After this patch, hidden enum type BlockdevOptionsKind will not
> >> be generated, and other API can use enum BlockdevDriver.
> >>
> >> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> >> Reviewed-by: Eric Blake <eblake@redhat.com>
> >> ---
> >>   qapi-schema.json |   14 +++++++++++++-
> >>   1 files changed, 13 insertions(+), 1 deletions(-)
> >
> > You know, it might even be better if we just flat out require that ALL
> > discriminated unions use an enum type, and discontinue support for
> > open-coded string (with hidden enum generation).  The extra type safety
> > and potential for introspection that it buys us is worth the change.  I
> > don't know how much of your series that would affect, but it's food for
> > thought.
> >
> 
>    I thought that before, and it is not hard to do, just need
> people's confirm that, string discriminator is not needed any more.

I think this feature is mainly used by the block layer, so could
someone from the block layer confirm this?

Also, this series looks ok to me, but it would be good to get an
ACK from someone from the block layer before applying (at least to
this patch).
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index d6f8615..61249db 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4046,6 +4046,18 @@ 
             '*no-flush': 'bool' } }
 
 ##
+# @BlockdevDriver
+#
+# Drivers that are supported in block device operations.
+#
+# Since: 2.0
+##
+{ 'enum': 'BlockdevDriver',
+  'data': [ 'file', 'http', 'https', 'ftp', 'ftps', 'tftp', 'vvfat', 'bochs',
+            'cloop', 'cow', 'dmg', 'parallels', 'qcow', 'qcow2', 'qed', 'raw',
+            'vdi', 'vhdx', 'vmdk', 'vpc' ] }
+
+##
 # @BlockdevOptionsBase
 #
 # Options that are available for all block devices, independent of the block
@@ -4068,7 +4080,7 @@ 
 # Since: 1.7
 ##
 { 'type': 'BlockdevOptionsBase',
-  'data': { 'driver': 'str',
+  'data': { 'driver': 'BlockdevDriver',
             '*id': 'str',
             '*discard': 'BlockdevDiscardOptions',
             '*cache': 'BlockdevCacheOptions',