[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/25] qapi: Convert simple union ChardevBackend to flat one
From: |
Markus Armbruster |
Subject: |
[PULL 07/25] qapi: Convert simple union ChardevBackend to flat one |
Date: |
Sat, 25 Sep 2021 08:25:07 +0200 |
Simple unions predate flat unions. Having both complicates the QAPI
schema language and the QAPI generator. We haven't been using simple
unions in new code for a long time, because they are less flexible and
somewhat awkward on the wire.
To prepare for their removal, convert simple union ChardevBackend to
an equivalent flat one. Adds some boilerplate to the schema, which is
a bit ugly, but a lot easier to maintain than the simple union
feature.
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210917143134.412106-8-armbru@redhat.com>
---
qapi/char.json | 187 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 165 insertions(+), 22 deletions(-)
diff --git a/qapi/char.json b/qapi/char.json
index 9b18ee3305..cc1e455c87 100644
--- a/qapi/char.json
+++ b/qapi/char.json
@@ -407,39 +407,182 @@
'base': 'ChardevCommon',
'if': 'CONFIG_SPICE_PROTOCOL' }
+##
+# @ChardevBackendKind:
+#
+# @pipe: Since 1.5
+# @udp: Since 1.5
+# @mux: Since 1.5
+# @msmouse: Since 1.5
+# @wctablet: Since 2.9
+# @braille: Since 1.5
+# @testdev: Since 2.2
+# @stdio: Since 1.5
+# @console: Since 1.5
+# @spicevmc: Since 1.5
+# @spiceport: Since 1.5
+# @qemu-vdagent: Since 6.1
+# @vc: v1.5
+# @ringbuf: Since 1.6
+# @memory: Since 1.5
+#
+# Since: 1.4
+##
+{ 'enum': 'ChardevBackendKind',
+ 'data': [ 'file',
+ 'serial',
+ 'parallel',
+ 'pipe',
+ 'socket',
+ 'udp',
+ 'pty',
+ 'null',
+ 'mux',
+ 'msmouse',
+ 'wctablet',
+ 'braille',
+ 'testdev',
+ 'stdio',
+ 'console',
+ { 'name': 'spicevmc', 'if': 'CONFIG_SPICE' },
+ { 'name': 'spiceport', 'if': 'CONFIG_SPICE' },
+ { 'name': 'qemu-vdagent', 'if': 'CONFIG_SPICE_PROTOCOL' },
+ 'vc',
+ 'ringbuf',
+ # next one is just for compatibility
+ 'memory' ] }
+
+##
+# @ChardevFileWrapper:
+#
+# Since: 1.4
+##
+{ 'struct': 'ChardevFileWrapper',
+ 'data': { 'data': 'ChardevFile' } }
+
+##
+# @ChardevHostdevWrapper:
+#
+# Since: 1.4
+##
+{ 'struct': 'ChardevHostdevWrapper',
+ 'data': { 'data': 'ChardevHostdev' } }
+
+##
+# @ChardevSocketWrapper:
+#
+# Since: 1.4
+##
+{ 'struct': 'ChardevSocketWrapper',
+ 'data': { 'data': 'ChardevSocket' } }
+
+##
+# @ChardevUdpWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevUdpWrapper',
+ 'data': { 'data': 'ChardevUdp' } }
+
+##
+# @ChardevCommonWrapper:
+#
+# Since: 2.6
+##
+{ 'struct': 'ChardevCommonWrapper',
+ 'data': { 'data': 'ChardevCommon' } }
+
+##
+# @ChardevMuxWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevMuxWrapper',
+ 'data': { 'data': 'ChardevMux' } }
+
+##
+# @ChardevStdioWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevStdioWrapper',
+ 'data': { 'data': 'ChardevStdio' } }
+
+##
+# @ChardevSpiceChannelWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevSpiceChannelWrapper',
+ 'data': { 'data': 'ChardevSpiceChannel' } }
+
+##
+# @ChardevSpicePortWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevSpicePortWrapper',
+ 'data': { 'data': 'ChardevSpicePort' } }
+
+##
+# @ChardevQemuVDAgentWrapper:
+#
+# Since: 6.1
+##
+{ 'struct': 'ChardevQemuVDAgentWrapper',
+ 'data': { 'data': 'ChardevQemuVDAgent' } }
+
+##
+# @ChardevVCWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevVCWrapper',
+ 'data': { 'data': 'ChardevVC' } }
+
+##
+# @ChardevRingbufWrapper:
+#
+# Since: 1.5
+##
+{ 'struct': 'ChardevRingbufWrapper',
+ 'data': { 'data': 'ChardevRingbuf' } }
+
##
# @ChardevBackend:
#
# Configuration info for the new chardev backend.
#
-# Since: 1.4 (testdev since 2.2, wctablet since 2.9, vdagent since 6.1)
+# Since: 1.4
##
{ 'union': 'ChardevBackend',
- 'data': { 'file': 'ChardevFile',
- 'serial': 'ChardevHostdev',
- 'parallel': 'ChardevHostdev',
- 'pipe': 'ChardevHostdev',
- 'socket': 'ChardevSocket',
- 'udp': 'ChardevUdp',
- 'pty': 'ChardevCommon',
- 'null': 'ChardevCommon',
- 'mux': 'ChardevMux',
- 'msmouse': 'ChardevCommon',
- 'wctablet': 'ChardevCommon',
- 'braille': 'ChardevCommon',
- 'testdev': 'ChardevCommon',
- 'stdio': 'ChardevStdio',
- 'console': 'ChardevCommon',
- 'spicevmc': { 'type': 'ChardevSpiceChannel',
+ 'base': { 'type': 'ChardevBackendKind' },
+ 'discriminator': 'type',
+ 'data': { 'file': 'ChardevFileWrapper',
+ 'serial': 'ChardevHostdevWrapper',
+ 'parallel': 'ChardevHostdevWrapper',
+ 'pipe': 'ChardevHostdevWrapper',
+ 'socket': 'ChardevSocketWrapper',
+ 'udp': 'ChardevUdpWrapper',
+ 'pty': 'ChardevCommonWrapper',
+ 'null': 'ChardevCommonWrapper',
+ 'mux': 'ChardevMuxWrapper',
+ 'msmouse': 'ChardevCommonWrapper',
+ 'wctablet': 'ChardevCommonWrapper',
+ 'braille': 'ChardevCommonWrapper',
+ 'testdev': 'ChardevCommonWrapper',
+ 'stdio': 'ChardevStdioWrapper',
+ 'console': 'ChardevCommonWrapper',
+ 'spicevmc': { 'type': 'ChardevSpiceChannelWrapper',
'if': 'CONFIG_SPICE' },
- 'spiceport': { 'type': 'ChardevSpicePort',
+ 'spiceport': { 'type': 'ChardevSpicePortWrapper',
'if': 'CONFIG_SPICE' },
- 'qemu-vdagent': { 'type': 'ChardevQemuVDAgent',
+ 'qemu-vdagent': { 'type': 'ChardevQemuVDAgentWrapper',
'if': 'CONFIG_SPICE_PROTOCOL' },
- 'vc': 'ChardevVC',
- 'ringbuf': 'ChardevRingbuf',
+ 'vc': 'ChardevVCWrapper',
+ 'ringbuf': 'ChardevRingbufWrapper',
# next one is just for compatibility
- 'memory': 'ChardevRingbuf' } }
+ 'memory': 'ChardevRingbufWrapper' } }
##
# @ChardevReturn:
--
2.31.1
- [PULL 02/25] qapi: Stop enforcing "type name should not end in 'Kind', (continued)
- [PULL 02/25] qapi: Stop enforcing "type name should not end in 'Kind', Markus Armbruster, 2021/09/25
- [PULL 14/25] test-clone-visitor: Wean off UserDefListUnion, Markus Armbruster, 2021/09/25
- [PULL 24/25] tests/qapi-schema: Use Python OSError instead of outmoded IOError, Markus Armbruster, 2021/09/25
- [PULL 13/25] test-qobject-output-visitor: Wean off UserDefListUnion, Markus Armbruster, 2021/09/25
- [PULL 23/25] test-clone-visitor: Correct an accidental rename, Markus Armbruster, 2021/09/25
- [PULL 22/25] tests/qapi-schema: Rename flat-union-* test cases to union-*, Markus Armbruster, 2021/09/25
- [PULL 21/25] qapi: Drop simple unions, Markus Armbruster, 2021/09/25
- [PULL 17/25] tests/qapi-schema: Rewrite simple union TestIfUnion to be flat, Markus Armbruster, 2021/09/25
- [PULL 09/25] qapi: Convert simple union ImageInfoSpecific to flat one, Markus Armbruster, 2021/09/25
- [PULL 01/25] qapi: Tidy up unusual line breaks, Markus Armbruster, 2021/09/25
- [PULL 07/25] qapi: Convert simple union ChardevBackend to flat one,
Markus Armbruster <=
- [PULL 08/25] qapi: Convert simple union SocketAddressLegacy to flat one, Markus Armbruster, 2021/09/25
- [PULL 15/25] tests/qapi-schema: Wean off UserDefListUnion, Markus Armbruster, 2021/09/25
- [PULL 18/25] test-clone-visitor: Wean off __org.qemu_x-Union1, Markus Armbruster, 2021/09/25
- [PULL 25/25] tests/qapi-schema: Make test-qapi.py -u work when files are absent, Markus Armbruster, 2021/09/25
- [PULL 19/25] tests/qapi-schema: Drop simple union __org.qemu_x-Union1, Markus Armbruster, 2021/09/25
- Re: [PULL 00/25] QAPI patches patches for 2021-09-25, Peter Maydell, 2021/09/25