[PATCH v7 08/10] qapi: Use 'if': { 'any': ... } where appropriate

marcandre.lureau@redhat.com posted 10 patches 4 years, 6 months ago
[PATCH v7 08/10] qapi: Use 'if': { 'any': ... } where appropriate
Posted by marcandre.lureau@redhat.com 4 years, 6 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/machine-target.json | 20 ++++++++++++++++----
 qapi/misc-target.json    | 12 +++++++++++-
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index e7811654b7..9b56b81bea 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -213,7 +213,9 @@
 ##
 { 'struct': 'CpuModelExpansionInfo',
   'data': { 'model': 'CpuModelInfo' },
-  'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' }
+  'if': { 'any': [ 'defined(TARGET_S390X)',
+                   'defined(TARGET_I386)',
+                   'defined(TARGET_ARM)'] } }
 
 ##
 # @query-cpu-model-expansion:
@@ -252,7 +254,9 @@
   'data': { 'type': 'CpuModelExpansionType',
             'model': 'CpuModelInfo' },
   'returns': 'CpuModelExpansionInfo',
-  'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' }
+  'if': { 'any': [ 'defined(TARGET_S390X)',
+                   'defined(TARGET_I386)',
+                   'defined(TARGET_ARM)' ] } }
 
 ##
 # @CpuDefinitionInfo:
@@ -316,7 +320,11 @@
             'typename': 'str',
             '*alias-of' : 'str',
             'deprecated' : 'bool' },
-  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
+  'if': { 'any': [ 'defined(TARGET_PPC)',
+                   'defined(TARGET_ARM)',
+                   'defined(TARGET_I386)',
+                   'defined(TARGET_S390X)',
+                   'defined(TARGET_MIPS)' ] } }
 
 ##
 # @query-cpu-definitions:
@@ -328,4 +336,8 @@
 # Since: 1.2
 ##
 { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
-  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
+  'if': { 'any': [ 'defined(TARGET_PPC)',
+                   'defined(TARGET_ARM)',
+                   'defined(TARGET_I386)',
+                   'defined(TARGET_S390X)',
+                   'defined(TARGET_MIPS)' ] } }
diff --git a/qapi/misc-target.json b/qapi/misc-target.json
index 5573dcf8f0..9e2ea4a04a 100644
--- a/qapi/misc-target.json
+++ b/qapi/misc-target.json
@@ -23,7 +23,17 @@
 ##
 { 'event': 'RTC_CHANGE',
   'data': { 'offset': 'int' },
-  'if': 'defined(TARGET_ALPHA) || defined(TARGET_ARM) || defined(TARGET_HPPA) || defined(TARGET_I386) || defined(TARGET_MIPS) || defined(TARGET_MIPS64) || defined(TARGET_PPC) || defined(TARGET_PPC64) || defined(TARGET_S390X) || defined(TARGET_SH4) || defined(TARGET_SPARC)' }
+  'if': { 'any': [ 'defined(TARGET_ALPHA)',
+                   'defined(TARGET_ARM)',
+                   'defined(TARGET_HPPA)',
+                   'defined(TARGET_I386)',
+                   'defined(TARGET_MIPS)',
+                   'defined(TARGET_MIPS64)',
+                   'defined(TARGET_PPC)',
+                   'defined(TARGET_PPC64)',
+                   'defined(TARGET_S390X)',
+                   'defined(TARGET_SH4)',
+                   'defined(TARGET_SPARC)' ] } }
 
 ##
 # @rtc-reset-reinjection:
-- 
2.32.0.264.g75ae10bc75


Re: [PATCH v7 08/10] qapi: Use 'if': { 'any': ... } where appropriate
Posted by Markus Armbruster 4 years, 6 months ago
marcandre.lureau@redhat.com writes:

> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Tested-by: John Snow <jsnow@redhat.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---
>  qapi/machine-target.json | 20 ++++++++++++++++----
>  qapi/misc-target.json    | 12 +++++++++++-
>  2 files changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
> index e7811654b7..9b56b81bea 100644
> --- a/qapi/machine-target.json
> +++ b/qapi/machine-target.json
> @@ -213,7 +213,9 @@
>  ##
>  { 'struct': 'CpuModelExpansionInfo',
>    'data': { 'model': 'CpuModelInfo' },
> -  'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' }
> +  'if': { 'any': [ 'defined(TARGET_S390X)',
> +                   'defined(TARGET_I386)',
> +                   'defined(TARGET_ARM)'] } }
>  
>  ##
>  # @query-cpu-model-expansion:
> @@ -252,7 +254,9 @@
>    'data': { 'type': 'CpuModelExpansionType',
>              'model': 'CpuModelInfo' },
>    'returns': 'CpuModelExpansionInfo',
> -  'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' }
> +  'if': { 'any': [ 'defined(TARGET_S390X)',
> +                   'defined(TARGET_I386)',
> +                   'defined(TARGET_ARM)' ] } }
>  
>  ##
>  # @CpuDefinitionInfo:
> @@ -316,7 +320,11 @@
>              'typename': 'str',
>              '*alias-of' : 'str',
>              'deprecated' : 'bool' },
> -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> +  'if': { 'any': [ 'defined(TARGET_PPC)',
> +                   'defined(TARGET_ARM)',
> +                   'defined(TARGET_I386)',
> +                   'defined(TARGET_S390X)',
> +                   'defined(TARGET_MIPS)' ] } }
>  
>  ##
>  # @query-cpu-definitions:
> @@ -328,4 +336,8 @@
>  # Since: 1.2
>  ##
>  { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
> -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> +  'if': { 'any': [ 'defined(TARGET_PPC)',
> +                   'defined(TARGET_ARM)',
> +                   'defined(TARGET_I386)',
> +                   'defined(TARGET_S390X)',
> +                   'defined(TARGET_MIPS)' ] } }
> diff --git a/qapi/misc-target.json b/qapi/misc-target.json
> index 5573dcf8f0..9e2ea4a04a 100644
> --- a/qapi/misc-target.json
> +++ b/qapi/misc-target.json
> @@ -23,7 +23,17 @@
>  ##
>  { 'event': 'RTC_CHANGE',
>    'data': { 'offset': 'int' },
> -  'if': 'defined(TARGET_ALPHA) || defined(TARGET_ARM) || defined(TARGET_HPPA) || defined(TARGET_I386) || defined(TARGET_MIPS) || defined(TARGET_MIPS64) || defined(TARGET_PPC) || defined(TARGET_PPC64) || defined(TARGET_S390X) || defined(TARGET_SH4) || defined(TARGET_SPARC)' }
> +  'if': { 'any': [ 'defined(TARGET_ALPHA)',
> +                   'defined(TARGET_ARM)',
> +                   'defined(TARGET_HPPA)',
> +                   'defined(TARGET_I386)',
> +                   'defined(TARGET_MIPS)',
> +                   'defined(TARGET_MIPS64)',
> +                   'defined(TARGET_PPC)',
> +                   'defined(TARGET_PPC64)',
> +                   'defined(TARGET_S390X)',
> +                   'defined(TARGET_SH4)',
> +                   'defined(TARGET_SPARC)' ] } }
>  
>  ##
>  # @rtc-reset-reinjection:

Missing:

  diff --git a/qapi/ui.json b/qapi/ui.json
  index fd9677d48e..aed2bec4ab 100644
  --- a/qapi/ui.json
  +++ b/qapi/ui.json
  @@ -1136,7 +1136,8 @@
       { 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' },
       { 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' },
       { 'name': 'egl-headless',
  -              'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' },
  +              'if': { 'all': [ 'defined(CONFIG_OPENGL)',
  +                               'defined(CONFIG_GBM)' ] } },
       { 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' },
       { 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' },
       { 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] }
  @@ -1167,7 +1168,8 @@
         'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' },
         'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' },
         'egl-headless': { 'type': 'DisplayEGLHeadless',
  -                        'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' }
  +                        'if': { 'all': [ 'defined(CONFIG_OPENGL)',
  +                                         'defined(CONFIG_GBM)' ] } }
     }
   }


You make up for it in PATCH 10.  Can tidy up in my tree.


Re: [PATCH v7 08/10] qapi: Use 'if': { 'any': ... } where appropriate
Posted by Marc-André Lureau 4 years, 6 months ago
Hi

On Thu, Aug 5, 2021 at 5:57 PM Markus Armbruster <armbru@redhat.com> wrote:

> marcandre.lureau@redhat.com writes:
>
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> > Tested-by: John Snow <jsnow@redhat.com>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > ---
> >  qapi/machine-target.json | 20 ++++++++++++++++----
> >  qapi/misc-target.json    | 12 +++++++++++-
> >  2 files changed, 27 insertions(+), 5 deletions(-)
> >
> > diff --git a/qapi/machine-target.json b/qapi/machine-target.json
> > index e7811654b7..9b56b81bea 100644
> > --- a/qapi/machine-target.json
> > +++ b/qapi/machine-target.json
> > @@ -213,7 +213,9 @@
> >  ##
> >  { 'struct': 'CpuModelExpansionInfo',
> >    'data': { 'model': 'CpuModelInfo' },
> > -  'if': 'defined(TARGET_S390X) || defined(TARGET_I386) ||
> defined(TARGET_ARM)' }
> > +  'if': { 'any': [ 'defined(TARGET_S390X)',
> > +                   'defined(TARGET_I386)',
> > +                   'defined(TARGET_ARM)'] } }
> >
> >  ##
> >  # @query-cpu-model-expansion:
> > @@ -252,7 +254,9 @@
> >    'data': { 'type': 'CpuModelExpansionType',
> >              'model': 'CpuModelInfo' },
> >    'returns': 'CpuModelExpansionInfo',
> > -  'if': 'defined(TARGET_S390X) || defined(TARGET_I386) ||
> defined(TARGET_ARM)' }
> > +  'if': { 'any': [ 'defined(TARGET_S390X)',
> > +                   'defined(TARGET_I386)',
> > +                   'defined(TARGET_ARM)' ] } }
> >
> >  ##
> >  # @CpuDefinitionInfo:
> > @@ -316,7 +320,11 @@
> >              'typename': 'str',
> >              '*alias-of' : 'str',
> >              'deprecated' : 'bool' },
> > -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
> defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> > +  'if': { 'any': [ 'defined(TARGET_PPC)',
> > +                   'defined(TARGET_ARM)',
> > +                   'defined(TARGET_I386)',
> > +                   'defined(TARGET_S390X)',
> > +                   'defined(TARGET_MIPS)' ] } }
> >
> >  ##
> >  # @query-cpu-definitions:
> > @@ -328,4 +336,8 @@
> >  # Since: 1.2
> >  ##
> >  { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
> > -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) ||
> defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> > +  'if': { 'any': [ 'defined(TARGET_PPC)',
> > +                   'defined(TARGET_ARM)',
> > +                   'defined(TARGET_I386)',
> > +                   'defined(TARGET_S390X)',
> > +                   'defined(TARGET_MIPS)' ] } }
> > diff --git a/qapi/misc-target.json b/qapi/misc-target.json
> > index 5573dcf8f0..9e2ea4a04a 100644
> > --- a/qapi/misc-target.json
> > +++ b/qapi/misc-target.json
> > @@ -23,7 +23,17 @@
> >  ##
> >  { 'event': 'RTC_CHANGE',
> >    'data': { 'offset': 'int' },
> > -  'if': 'defined(TARGET_ALPHA) || defined(TARGET_ARM) ||
> defined(TARGET_HPPA) || defined(TARGET_I386) || defined(TARGET_MIPS) ||
> defined(TARGET_MIPS64) || defined(TARGET_PPC) || defined(TARGET_PPC64) ||
> defined(TARGET_S390X) || defined(TARGET_SH4) || defined(TARGET_SPARC)' }
> > +  'if': { 'any': [ 'defined(TARGET_ALPHA)',
> > +                   'defined(TARGET_ARM)',
> > +                   'defined(TARGET_HPPA)',
> > +                   'defined(TARGET_I386)',
> > +                   'defined(TARGET_MIPS)',
> > +                   'defined(TARGET_MIPS64)',
> > +                   'defined(TARGET_PPC)',
> > +                   'defined(TARGET_PPC64)',
> > +                   'defined(TARGET_S390X)',
> > +                   'defined(TARGET_SH4)',
> > +                   'defined(TARGET_SPARC)' ] } }
> >
> >  ##
> >  # @rtc-reset-reinjection:
>
> Missing:
>
>   diff --git a/qapi/ui.json b/qapi/ui.json
>   index fd9677d48e..aed2bec4ab 100644
>   --- a/qapi/ui.json
>   +++ b/qapi/ui.json
>   @@ -1136,7 +1136,8 @@
>        { 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' },
>        { 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' },
>        { 'name': 'egl-headless',
>   -              'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' },
>   +              'if': { 'all': [ 'defined(CONFIG_OPENGL)',
>   +                               'defined(CONFIG_GBM)' ] } },
>        { 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' },
>        { 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' },
>        { 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] }
>   @@ -1167,7 +1168,8 @@
>          'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' },
>          'curses': { 'type': 'DisplayCurses', 'if':
> 'defined(CONFIG_CURSES)' },
>          'egl-headless': { 'type': 'DisplayEGLHeadless',
>   -                        'if': 'defined(CONFIG_OPENGL) &&
> defined(CONFIG_GBM)' }
>   +                        'if': { 'all': [ 'defined(CONFIG_OPENGL)',
>   +                                         'defined(CONFIG_GBM)' ] } }
>      }
>    }
>
>
> You make up for it in PATCH 10.  Can tidy up in my tree.
>
>
Ah yes, those are new in the rebase. I think they could either be squashed
in this patch (with update title), or a new patch. Leaving to the last
patch isn't really a big issue either I suppose.

Thanks in advance for cleaning it up if you take it :)


-- 
Marc-André Lureau
Re: [PATCH v7 08/10] qapi: Use 'if': { 'any': ... } where appropriate
Posted by Markus Armbruster 4 years, 6 months ago
Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
> On Thu, Aug 5, 2021 at 5:57 PM Markus Armbruster <armbru@redhat.com> wrote:
>
>> marcandre.lureau@redhat.com writes:
>>
>> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
>> >
>> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>> > Tested-by: John Snow <jsnow@redhat.com>
>> > Reviewed-by: Markus Armbruster <armbru@redhat.com>

[...]

>> Missing:
>>
>>   diff --git a/qapi/ui.json b/qapi/ui.json
>>   index fd9677d48e..aed2bec4ab 100644
>>   --- a/qapi/ui.json
>>   +++ b/qapi/ui.json
>>   @@ -1136,7 +1136,8 @@
>>        { 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' },
>>        { 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' },
>>        { 'name': 'egl-headless',
>>   -              'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' },
>>   +              'if': { 'all': [ 'defined(CONFIG_OPENGL)',
>>   +                               'defined(CONFIG_GBM)' ] } },
>>        { 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' },
>>        { 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' },
>>        { 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] }
>>   @@ -1167,7 +1168,8 @@
>>          'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' },
>>          'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' },
>>          'egl-headless': { 'type': 'DisplayEGLHeadless',
>>   -                        'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' }
>>   +                        'if': { 'all': [ 'defined(CONFIG_OPENGL)',
>>   +                                         'defined(CONFIG_GBM)' ] } }
>>      }
>>    }
>>
>>
>> You make up for it in PATCH 10.  Can tidy up in my tree.
>>
>>
> Ah yes, those are new in the rebase. I think they could either be squashed
> in this patch (with update title), or a new patch. Leaving to the last
> patch isn't really a big issue either I suppose.
>
> Thanks in advance for cleaning it up if you take it :)

I'm squashing it into PATCH 06, which already has similar changes to
tests/qapi-schema/qapi-schema-test.json.