diff mbox

[2/7] qapi: convert NumaOptions into a flat union

Message ID 10d59855527f68bfaa90e74ec45b0da50ce5463a.1441627175.git.DirtY.iCE.hu@gmail.com
State New
Headers show

Commit Message

=?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Sept. 7, 2015, 12:08 p.m. UTC
Changes the NumaOptions to flat union from a simple one.  This is
required by my later OptsVisitor patch to preserve backward
compatibility.

Strictly speaking this would break QMP compatibility (as specified in
docs/qapi-code-gen.txt), but since no QMP command use this structure,
it's not an issue.  The -numa option syntax doesn't change.  There are
some changes in the C api, but this patch fixes them.

Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>

---

Changes from v2:
* renamed NumaDriver to NumaOptionType

 numa.c           |  4 ++--
 qapi-schema.json | 47 ++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 38 insertions(+), 13 deletions(-)

Comments

Eduardo Habkost Sept. 9, 2015, 3:42 p.m. UTC | #1
On Mon, Sep 07, 2015 at 02:08:07PM +0200, Kővágó, Zoltán wrote:
[...]
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 67fef37..9e4fe5d 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3550,17 +3550,6 @@
>    'data': { '*console':'int', 'events': [ 'InputEvent' ] } }
>  
>  ##
> -# @NumaOptions
> -#
> -# A discriminated record of NUMA options. (for OptsVisitor)
> -#
> -# Since 2.1
> -##
> -{ 'union': 'NumaOptions',
> -  'data': {
> -    'node': 'NumaNodeOptions' }}
> -
> -##
>  # @NumaNodeOptions
>  #
>  # Create a guest NUMA node. (for OptsVisitor)
> @@ -3587,6 +3576,42 @@
>     '*memdev': 'str' }}
>  
>  ##
> +# @NumaOptionType
> +#
> +# List of possible numa drivers.

There's no such thing as a "numa driver". The type name was fixed but
the documentation still doesn't make sense.

I suggest:

# NUMA command-line option type.
#
# @node: Create a guest NUMA node. See @NumaNodeOptions.

> +#
> +# Since: 2.5
> +##
> +{ 'enum': 'NumaOptionType',
> +  'data': [ 'node' ] }
> +
> +##
> +# @NumaCommonOptions
> +#
> +# Common set of numa options.
> +#
> +# @type: the numa driver to use

Suggestion:

# @type: NUMA command-line option type.
diff mbox

Patch

diff --git a/numa.c b/numa.c
index 402804b..e79620f 100644
--- a/numa.c
+++ b/numa.c
@@ -226,8 +226,8 @@  static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
         goto error;
     }
 
-    switch (object->kind) {
-    case NUMA_OPTIONS_KIND_NODE:
+    switch (object->type) {
+    case NUMA_OPTION_TYPE_NODE:
         numa_node_parse(object->node, opts, &err);
         if (err) {
             goto error;
diff --git a/qapi-schema.json b/qapi-schema.json
index 67fef37..9e4fe5d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3550,17 +3550,6 @@ 
   'data': { '*console':'int', 'events': [ 'InputEvent' ] } }
 
 ##
-# @NumaOptions
-#
-# A discriminated record of NUMA options. (for OptsVisitor)
-#
-# Since 2.1
-##
-{ 'union': 'NumaOptions',
-  'data': {
-    'node': 'NumaNodeOptions' }}
-
-##
 # @NumaNodeOptions
 #
 # Create a guest NUMA node. (for OptsVisitor)
@@ -3587,6 +3576,42 @@ 
    '*memdev': 'str' }}
 
 ##
+# @NumaOptionType
+#
+# List of possible numa drivers.
+#
+# Since: 2.5
+##
+{ 'enum': 'NumaOptionType',
+  'data': [ 'node' ] }
+
+##
+# @NumaCommonOptions
+#
+# Common set of numa options.
+#
+# @type: the numa driver to use
+#
+# Since: 2.5
+##
+{ 'struct': 'NumaCommonOptions',
+  'data': {
+    'type': 'NumaOptionType' } }
+
+##
+# @NumaOptions
+#
+# A discriminated record of NUMA options. (for OptsVisitor)
+#
+# Since 2.1
+##
+{ 'union': 'NumaOptions',
+  'base': 'NumaCommonOptions',
+  'discriminator': 'type',
+  'data': {
+    'node': 'NumaNodeOptions' }}
+
+##
 # @HostMemPolicy
 #
 # Host memory policy types