qapi: Convert simple union SocketAddressLegacy to flat one
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 SocketAddressLegacy
to an equivalent flat one, with existing enum SocketAddressType
replacing implicit enum type SocketAddressLegacyKind. Adds some
boilerplate to the schema, which is a bit ugly, but a lot easier to
maintain than the simple union feature.
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210917143134.412106-9-armbru@redhat.com>
diff --git a/qapi/sockets.json b/qapi/sockets.json
index 7866dc2..ef4b16d 100644
--- a/qapi/sockets.json
+++ b/qapi/sockets.json
@@ -111,24 +111,56 @@
'port': 'str' } }
##
+# @InetSocketAddressWrapper:
+#
+# Since: 1.3
+##
+{ 'struct': 'InetSocketAddressWrapper',
+ 'data': { 'data': 'InetSocketAddress' } }
+
+##
+# @UnixSocketAddressWrapper:
+#
+# Since: 1.3
+##
+{ 'struct': 'UnixSocketAddressWrapper',
+ 'data': { 'data': 'UnixSocketAddress' } }
+
+##
+# @VsockSocketAddressWrapper:
+#
+# Since: 2.8
+##
+{ 'struct': 'VsockSocketAddressWrapper',
+ 'data': { 'data': 'VsockSocketAddress' } }
+
+##
+# @StringWrapper:
+#
+# Since: 1.3
+##
+{ 'struct': 'StringWrapper',
+ 'data': { 'data': 'String' } }
+
+##
# @SocketAddressLegacy:
#
# Captures the address of a socket, which could also be a named file descriptor
#
# Note: This type is deprecated in favor of SocketAddress. The
# difference between SocketAddressLegacy and SocketAddress is that the
-# latter is a flat union rather than a simple union. Flat is nicer
-# because it avoids nesting on the wire, i.e. that form has fewer {}.
-
+# latter is has fewer {} on the wire.
#
# Since: 1.3
##
{ 'union': 'SocketAddressLegacy',
+ 'base': { 'type': 'SocketAddressType' },
+ 'discriminator': 'type',
'data': {
- 'inet': 'InetSocketAddress',
- 'unix': 'UnixSocketAddress',
- 'vsock': 'VsockSocketAddress',
- 'fd': 'String' } }
+ 'inet': 'InetSocketAddressWrapper',
+ 'unix': 'UnixSocketAddressWrapper',
+ 'vsock': 'VsockSocketAddressWrapper',
+ 'fd': 'StringWrapper' } }
##
# @SocketAddressType: