diff options
author | Eric Blake <eblake@redhat.com> | 2016-07-13 21:50:23 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-07-19 20:18:02 +0200 |
commit | f394b2e20d9a666fb194fb692179a0eeaca5daea (patch) | |
tree | 4d01037fde0500c9bfa746ef852ae32e04b7dbb8 /qapi-schema.json | |
parent | faecd40a592dbd8f12d2b3b4783fa05ae22364ea (diff) |
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qapi-schema.json')
-rw-r--r-- | qapi-schema.json | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/qapi-schema.json b/qapi-schema.json index d2d650673b..5658723b37 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2809,16 +2809,32 @@ '*queues': 'int' } } ## -# @NetClientOptions +# @NetClientDriver # -# A discriminated record of network device traits. +# Available netdev drivers. +# +# Since 2.7 +## +{ 'enum': 'NetClientDriver', + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump', + 'bridge', 'hubport', 'netmap', 'vhost-user' ] } + +## +# @Netdev +# +# Captures the configuration of a network device. +# +# @id: identifier for monitor commands. +# +# @type: Specify the driver used for interpreting remaining arguments. # # Since 1.2 # # 'l2tpv3' - since 2.1 -# ## -{ 'union': 'NetClientOptions', +{ 'union': 'Netdev', + 'base': { 'id': 'str', 'type': 'NetClientDriver' }, + 'discriminator': 'type', 'data': { 'none': 'NetdevNoneOptions', 'nic': 'NetLegacyNicOptions', @@ -2853,23 +2869,28 @@ '*vlan': 'int32', '*id': 'str', '*name': 'str', - 'opts': 'NetClientOptions' } } + 'opts': 'NetLegacyOptions' } } ## -# @Netdev +# @NetLegacyOptions # -# Captures the configuration of a network device. -# -# @id: identifier for monitor commands. -# -# @opts: device type specific properties +# Like Netdev, but for use only by the legacy command line options # # Since 1.2 ## -{ 'struct': 'Netdev', +{ 'union': 'NetLegacyOptions', 'data': { - 'id': 'str', - 'opts': 'NetClientOptions' } } + 'none': 'NetdevNoneOptions', + 'nic': 'NetLegacyNicOptions', + 'user': 'NetdevUserOptions', + 'tap': 'NetdevTapOptions', + 'l2tpv3': 'NetdevL2TPv3Options', + 'socket': 'NetdevSocketOptions', + 'vde': 'NetdevVdeOptions', + 'dump': 'NetdevDumpOptions', + 'bridge': 'NetdevBridgeOptions', + 'netmap': 'NetdevNetmapOptions', + 'vhost-user': 'NetdevVhostUserOptions' } } ## # @NetFilterDirection |