[PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file

Philippe Mathieu-Daudé posted 69 patches 5 months, 2 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, Paul Durrant <paul@xen.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Dr. David Alan Gilbert" <dave@treblig.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Reinoud Zandijk <reinoud@netbsd.org>, Sunil Muthuswamy <sunilmut@microsoft.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Alexander Graf <agraf@csgraf.de>
There is a newer version of this series
[PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file
Posted by Philippe Mathieu-Daudé 5 months, 2 weeks ago
Extract TCG and KVM definitions from machine.json to accelerator.json.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
---
 MAINTAINERS                |  1 +
 qapi/accelerator.json      | 57 ++++++++++++++++++++++++++++++++++++++
 qapi/machine.json          | 47 -------------------------------
 qapi/qapi-schema.json      |  1 +
 accel/tcg/monitor.c        |  2 +-
 hw/core/machine-hmp-cmds.c |  1 +
 hw/core/machine-qmp-cmds.c |  1 +
 qapi/meson.build           |  1 +
 8 files changed, 63 insertions(+), 48 deletions(-)
 create mode 100644 qapi/accelerator.json

diff --git a/MAINTAINERS b/MAINTAINERS
index b1cbfe115bc..c3ce0d37779 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -507,6 +507,7 @@ F: accel/Makefile.objs
 F: accel/stubs/Makefile.objs
 F: cpu-common.c
 F: cpu-target.c
+F: qapi/accelerator.json
 F: system/cpus.c
 
 Apple Silicon HVF CPUs
diff --git a/qapi/accelerator.json b/qapi/accelerator.json
new file mode 100644
index 00000000000..00d25427059
--- /dev/null
+++ b/qapi/accelerator.json
@@ -0,0 +1,57 @@
+# -*- Mode: Python -*-
+# vim: filetype=python
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+##
+# = Accelerators
+##
+
+{ 'include': 'common.json' }
+
+##
+# @KvmInfo:
+#
+# Information about support for KVM acceleration
+#
+# @enabled: true if KVM acceleration is active
+#
+# @present: true if KVM acceleration is built into this executable
+#
+# Since: 0.14
+##
+{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
+
+##
+# @query-kvm:
+#
+# Return information about KVM acceleration
+#
+# Returns: @KvmInfo
+#
+# Since: 0.14
+#
+# .. qmp-example::
+#
+#     -> { "execute": "query-kvm" }
+#     <- { "return": { "enabled": true, "present": true } }
+##
+{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
+
+##
+# @x-query-jit:
+#
+# Query TCG compiler statistics
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: TCG compiler statistics
+#
+# Since: 6.2
+##
+{ 'command': 'x-query-jit',
+  'returns': 'HumanReadableText',
+  'if': 'CONFIG_TCG',
+  'features': [ 'unstable' ] }
diff --git a/qapi/machine.json b/qapi/machine.json
index acf6610efa5..e4713c405e8 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -454,35 +454,6 @@
 ##
 { 'command': 'inject-nmi' }
 
-##
-# @KvmInfo:
-#
-# Information about support for KVM acceleration
-#
-# @enabled: true if KVM acceleration is active
-#
-# @present: true if KVM acceleration is built into this executable
-#
-# Since: 0.14
-##
-{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
-
-##
-# @query-kvm:
-#
-# Return information about KVM acceleration
-#
-# Returns: @KvmInfo
-#
-# Since: 0.14
-#
-# .. qmp-example::
-#
-#     -> { "execute": "query-kvm" }
-#     <- { "return": { "enabled": true, "present": true } }
-##
-{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
-
 ##
 # @NumaOptionsType:
 #
@@ -1729,24 +1700,6 @@
   'returns': 'HumanReadableText',
   'features': [ 'unstable' ] }
 
-##
-# @x-query-jit:
-#
-# Query TCG compiler statistics
-#
-# Features:
-#
-# @unstable: This command is meant for debugging.
-#
-# Returns: TCG compiler statistics
-#
-# Since: 6.2
-##
-{ 'command': 'x-query-jit',
-  'returns': 'HumanReadableText',
-  'if': 'CONFIG_TCG',
-  'features': [ 'unstable' ] }
-
 ##
 # @x-query-numa:
 #
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index a8f66163cb7..616e04970ef 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -55,6 +55,7 @@
 { 'include': 'introspect.json' }
 { 'include': 'qom.json' }
 { 'include': 'qdev.json' }
+{ 'include': 'accelerator.json' }
 { 'include': 'machine-common.json' }
 { 'include': 'machine.json' }
 { 'include': 'machine-s390x.json' }
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index adb9de5a1c6..d5dd677f2a4 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -9,7 +9,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qapi/type-helpers.h"
-#include "qapi/qapi-commands-machine.h"
+#include "qapi/qapi-commands-accelerator.h"
 #include "monitor/monitor.h"
 #include "system/tcg.h"
 #include "internal-common.h"
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 65eeb5e9cc2..15ae5864d16 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -18,6 +18,7 @@
 #include "monitor/monitor.h"
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
+#include "qapi/qapi-commands-accelerator.h"
 #include "qapi/qapi-commands-machine.h"
 #include "qobject/qdict.h"
 #include "qapi/string-output-visitor.h"
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index ab4fd1ec08a..f37fd220c2d 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -14,6 +14,7 @@
 #include "hw/mem/memory-device.h"
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
+#include "qapi/qapi-commands-accelerator.h"
 #include "qapi/qapi-commands-machine.h"
 #include "qobject/qobject.h"
 #include "qapi/qobject-input-visitor.h"
diff --git a/qapi/meson.build b/qapi/meson.build
index 3b035aea339..ca6b61a608d 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -57,6 +57,7 @@ qapi_all_modules = [
 ]
 if have_system
   qapi_all_modules += [
+    'accelerator',
     'acpi',
     'audio',
     'cryptodev',
-- 
2.49.0


Re: [PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file
Posted by Philippe Mathieu-Daudé 5 months, 2 weeks ago
Hi Markus,

On 3/7/25 12:54, Philippe Mathieu-Daudé wrote:
> Extract TCG and KVM definitions from machine.json to accelerator.json.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> ---
>   MAINTAINERS                |  1 +
>   qapi/accelerator.json      | 57 ++++++++++++++++++++++++++++++++++++++
>   qapi/machine.json          | 47 -------------------------------
>   qapi/qapi-schema.json      |  1 +
>   accel/tcg/monitor.c        |  2 +-
>   hw/core/machine-hmp-cmds.c |  1 +
>   hw/core/machine-qmp-cmds.c |  1 +
>   qapi/meson.build           |  1 +
>   8 files changed, 63 insertions(+), 48 deletions(-)
>   create mode 100644 qapi/accelerator.json
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index b1cbfe115bc..c3ce0d37779 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -507,6 +507,7 @@ F: accel/Makefile.objs
>   F: accel/stubs/Makefile.objs
>   F: cpu-common.c
>   F: cpu-target.c
> +F: qapi/accelerator.json
>   F: system/cpus.c
>   
>   Apple Silicon HVF CPUs
> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
> new file mode 100644
> index 00000000000..00d25427059
> --- /dev/null
> +++ b/qapi/accelerator.json
> @@ -0,0 +1,57 @@
> +# -*- Mode: Python -*-
> +# vim: filetype=python
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +##
> +# = Accelerators
> +##
> +
> +{ 'include': 'common.json' }

common.json defines @HumanReadableText, ...

[...]

> +##
> +# @x-query-jit:
> +#
> +# Query TCG compiler statistics
> +#
> +# Features:
> +#
> +# @unstable: This command is meant for debugging.
> +#
> +# Returns: TCG compiler statistics
> +#
> +# Since: 6.2
> +##
> +{ 'command': 'x-query-jit',
> +  'returns': 'HumanReadableText',
> +  'if': 'CONFIG_TCG',

... which is *optionally* used here, triggering when
TCG is not built in:

qapi/qapi-commands-accelerator.c:85:13: error: 
‘qmp_marshal_output_HumanReadableText’ defined but not used 
[-Werror=unused-function]
    85 | static void 
qmp_marshal_output_HumanReadableText(HumanReadableText *ret_in,
       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

We previously discussed that issue:
https://mail.gnu.org/archive/html/qemu-devel/2021-06/msg02667.html

where you said:

"conditional commands returning an unconditional type is a bit
of a code smell". Is it however a "non-smelly instances of this pattern"?

Regards,

Phil.

Re: [PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file
Posted by Markus Armbruster 5 months ago
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> Hi Markus,

I missed this one, sorry!

> On 3/7/25 12:54, Philippe Mathieu-Daudé wrote:
>> Extract TCG and KVM definitions from machine.json to accelerator.json.
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>

[...]

>> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
>> new file mode 100644
>> index 00000000000..00d25427059
>> --- /dev/null
>> +++ b/qapi/accelerator.json
>> @@ -0,0 +1,57 @@
>> +# -*- Mode: Python -*-
>> +# vim: filetype=python
>> +#
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +##
>> +# = Accelerators
>> +##
>> +
>> +{ 'include': 'common.json' }
>
> common.json defines @HumanReadableText, ...
>
> [...]
>
>> +##
>> +# @x-query-jit:
>> +#
>> +# Query TCG compiler statistics
>> +#
>> +# Features:
>> +#
>> +# @unstable: This command is meant for debugging.
>> +#
>> +# Returns: TCG compiler statistics
>> +#
>> +# Since: 6.2
>> +##
>> +{ 'command': 'x-query-jit',
>> +  'returns': 'HumanReadableText',
>> +  'if': 'CONFIG_TCG',
>
> ... which is *optionally* used here, triggering when
> TCG is not built in:
>
> qapi/qapi-commands-accelerator.c:85:13: error: ‘qmp_marshal_output_HumanReadableText’ defined but not used [-Werror=unused-function]
>    85 | static void qmp_marshal_output_HumanReadableText(HumanReadableText *ret_in,
>       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors

This is a defect in the QAPI code generator.  More below.

> We previously discussed that issue:
> https://mail.gnu.org/archive/html/qemu-devel/2021-06/msg02667.html
>
> where you said:
>
> "conditional commands returning an unconditional type is a bit
> of a code smell". Is it however a "non-smelly instances of this pattern"?

The instance discussed there wasn't.

You ran into it when you made TPM commands conditional on CONFIG_TPM
without also making the types they return conditional.  The proper
solution was to make the types conditional, too.  Avoided generating
dead code.  I told you "The user is responsible for making T's 'if' the
conjunction of the commands'."

Some of the commands returning HumanReadableText are unconditional, so
said conjunction is also unconditional.  So how do we end up with unused
qmp_marshal_output_HumanReadableText()?

A qmp_marshal_output_T() is only ever called by qmp_marshal_C() for a
command C that returns T.

We've always generated it as a static function on demand, i.e. when we
generate a call.

Since we split up monolithic generated code into modules, we do this on
per module.  This can result in identical (static)
qmp_marshal_output_T() in several modules.  Fine, but we haven't
considered conditionals, yet.

As long as all functions returning T are in the same module, "making T's
'if' the conjunction of the commands'" works.  This is the case for the
TPM commands.

However, it need not work when the functions returning T are in multiple
modules.  For each module, we need the conjunction of that module's
commands' conditions.  We can't make it T's condition unless they are
all the same.  They aren't for HumanReadableText, as you found out.

I need to ponder this to decide on a solution.

Thanks!
Re: [PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file
Posted by Daniel P. Berrangé 5 months ago
On Wed, Jul 16, 2025 at 10:23:26AM +0200, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 
> > Hi Markus,
> 
> I missed this one, sorry!
> 
> > On 3/7/25 12:54, Philippe Mathieu-Daudé wrote:
> >> Extract TCG and KVM definitions from machine.json to accelerator.json.
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> >> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> >> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> 
> [...]
> 
> >> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
> >> new file mode 100644
> >> index 00000000000..00d25427059
> >> --- /dev/null
> >> +++ b/qapi/accelerator.json
> >> @@ -0,0 +1,57 @@
> >> +# -*- Mode: Python -*-
> >> +# vim: filetype=python
> >> +#
> >> +# SPDX-License-Identifier: GPL-2.0-or-later
> >> +
> >> +##
> >> +# = Accelerators
> >> +##
> >> +
> >> +{ 'include': 'common.json' }
> >
> > common.json defines @HumanReadableText, ...
> >
> > [...]
> >
> >> +##
> >> +# @x-query-jit:
> >> +#
> >> +# Query TCG compiler statistics
> >> +#
> >> +# Features:
> >> +#
> >> +# @unstable: This command is meant for debugging.
> >> +#
> >> +# Returns: TCG compiler statistics
> >> +#
> >> +# Since: 6.2
> >> +##
> >> +{ 'command': 'x-query-jit',
> >> +  'returns': 'HumanReadableText',
> >> +  'if': 'CONFIG_TCG',
> >
> > ... which is *optionally* used here, triggering when
> > TCG is not built in:
> >
> > qapi/qapi-commands-accelerator.c:85:13: error: ‘qmp_marshal_output_HumanReadableText’ defined but not used [-Werror=unused-function]
> >    85 | static void qmp_marshal_output_HumanReadableText(HumanReadableText *ret_in,
> >       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> 
> This is a defect in the QAPI code generator.  More below.
> 
> > We previously discussed that issue:
> > https://mail.gnu.org/archive/html/qemu-devel/2021-06/msg02667.html
> >
> > where you said:
> >
> > "conditional commands returning an unconditional type is a bit
> > of a code smell". Is it however a "non-smelly instances of this pattern"?
> 
> The instance discussed there wasn't.
> 
> You ran into it when you made TPM commands conditional on CONFIG_TPM
> without also making the types they return conditional.  The proper
> solution was to make the types conditional, too.  Avoided generating
> dead code.  I told you "The user is responsible for making T's 'if' the
> conjunction of the commands'."
> 
> Some of the commands returning HumanReadableText are unconditional, so
> said conjunction is also unconditional.  So how do we end up with unused
> qmp_marshal_output_HumanReadableText()?
> 
> A qmp_marshal_output_T() is only ever called by qmp_marshal_C() for a
> command C that returns T.
> 
> We've always generated it as a static function on demand, i.e. when we
> generate a call.

..snip..

> I need to ponder this to decide on a solution.

Functionally the redundat function is harmless, so the least effort
option is to change the generated QAPI headers to look like

  #pragma GCC diagnostic push
  #pragma GCC ignored "-Wunused-function"

  ... rest of QAPI header...

  #pragma GCC diagnostic pop

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file
Posted by Philippe Mathieu-Daudé 5 months ago
On 16/7/25 11:24, Daniel P. Berrangé wrote:
> On Wed, Jul 16, 2025 at 10:23:26AM +0200, Markus Armbruster wrote:
>> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>>
>>> Hi Markus,
>>
>> I missed this one, sorry!
>>
>>> On 3/7/25 12:54, Philippe Mathieu-Daudé wrote:
>>>> Extract TCG and KVM definitions from machine.json to accelerator.json.
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>>> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>>
>> [...]
>>
>>>> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
>>>> new file mode 100644
>>>> index 00000000000..00d25427059
>>>> --- /dev/null
>>>> +++ b/qapi/accelerator.json
>>>> @@ -0,0 +1,57 @@
>>>> +# -*- Mode: Python -*-
>>>> +# vim: filetype=python
>>>> +#
>>>> +# SPDX-License-Identifier: GPL-2.0-or-later
>>>> +
>>>> +##
>>>> +# = Accelerators
>>>> +##
>>>> +
>>>> +{ 'include': 'common.json' }
>>>
>>> common.json defines @HumanReadableText, ...
>>>
>>> [...]
>>>
>>>> +##
>>>> +# @x-query-jit:
>>>> +#
>>>> +# Query TCG compiler statistics
>>>> +#
>>>> +# Features:
>>>> +#
>>>> +# @unstable: This command is meant for debugging.
>>>> +#
>>>> +# Returns: TCG compiler statistics
>>>> +#
>>>> +# Since: 6.2
>>>> +##
>>>> +{ 'command': 'x-query-jit',
>>>> +  'returns': 'HumanReadableText',
>>>> +  'if': 'CONFIG_TCG',
>>>
>>> ... which is *optionally* used here, triggering when
>>> TCG is not built in:
>>>
>>> qapi/qapi-commands-accelerator.c:85:13: error: ‘qmp_marshal_output_HumanReadableText’ defined but not used [-Werror=unused-function]
>>>     85 | static void qmp_marshal_output_HumanReadableText(HumanReadableText *ret_in,
>>>        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> cc1: all warnings being treated as errors
>>
>> This is a defect in the QAPI code generator.  More below.
>>
>>> We previously discussed that issue:
>>> https://mail.gnu.org/archive/html/qemu-devel/2021-06/msg02667.html
>>>
>>> where you said:
>>>
>>> "conditional commands returning an unconditional type is a bit
>>> of a code smell". Is it however a "non-smelly instances of this pattern"?
>>
>> The instance discussed there wasn't.
>>
>> You ran into it when you made TPM commands conditional on CONFIG_TPM
>> without also making the types they return conditional.

Indeed, I now remembered it:
https://lore.kernel.org/qemu-devel/87r1haasht.fsf@dusky.pond.sub.org/

>>  The proper
>> solution was to make the types conditional, too.  Avoided generating
>> dead code.  I told you "The user is responsible for making T's 'if' the
>> conjunction of the commands'."
>>
>> Some of the commands returning HumanReadableText are unconditional, so
>> said conjunction is also unconditional.  So how do we end up with unused
>> qmp_marshal_output_HumanReadableText()?
>>
>> A qmp_marshal_output_T() is only ever called by qmp_marshal_C() for a
>> command C that returns T.
>>
>> We've always generated it as a static function on demand, i.e. when we
>> generate a call.
> 
> ..snip..
> 
>> I need to ponder this to decide on a solution.
> 
> Functionally the redundat function is harmless, so the least effort
> option is to change the generated QAPI headers to look like
> 
>    #pragma GCC diagnostic push
>    #pragma GCC ignored "-Wunused-function"
> 
>    ... rest of QAPI header...
> 
>    #pragma GCC diagnostic pop

I agree, the same was suggested as comment in my previous patch
https://lore.kernel.org/qemu-devel/20210609184955.1193081-2-philmd@redhat.com/

Markus, WDYT?

Regards,

Phil.

Re: [PATCH v5 28/69] qapi: Move definitions related to accelerators in their own file
Posted by Philippe Mathieu-Daudé 5 months ago
On 3/7/25 18:42, Philippe Mathieu-Daudé wrote:
> Hi Markus,
> 
> On 3/7/25 12:54, Philippe Mathieu-Daudé wrote:
>> Extract TCG and KVM definitions from machine.json to accelerator.json.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>> ---
>>   MAINTAINERS                |  1 +
>>   qapi/accelerator.json      | 57 ++++++++++++++++++++++++++++++++++++++
>>   qapi/machine.json          | 47 -------------------------------
>>   qapi/qapi-schema.json      |  1 +
>>   accel/tcg/monitor.c        |  2 +-
>>   hw/core/machine-hmp-cmds.c |  1 +
>>   hw/core/machine-qmp-cmds.c |  1 +
>>   qapi/meson.build           |  1 +
>>   8 files changed, 63 insertions(+), 48 deletions(-)
>>   create mode 100644 qapi/accelerator.json
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index b1cbfe115bc..c3ce0d37779 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -507,6 +507,7 @@ F: accel/Makefile.objs
>>   F: accel/stubs/Makefile.objs
>>   F: cpu-common.c
>>   F: cpu-target.c
>> +F: qapi/accelerator.json
>>   F: system/cpus.c
>>   Apple Silicon HVF CPUs
>> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
>> new file mode 100644
>> index 00000000000..00d25427059
>> --- /dev/null
>> +++ b/qapi/accelerator.json
>> @@ -0,0 +1,57 @@
>> +# -*- Mode: Python -*-
>> +# vim: filetype=python
>> +#
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +
>> +##
>> +# = Accelerators
>> +##
>> +
>> +{ 'include': 'common.json' }
> 
> common.json defines @HumanReadableText, ...
> 
> [...]
> 
>> +##
>> +# @x-query-jit:
>> +#
>> +# Query TCG compiler statistics
>> +#
>> +# Features:
>> +#
>> +# @unstable: This command is meant for debugging.
>> +#
>> +# Returns: TCG compiler statistics
>> +#
>> +# Since: 6.2
>> +##
>> +{ 'command': 'x-query-jit',
>> +  'returns': 'HumanReadableText',
>> +  'if': 'CONFIG_TCG',
> 
> ... which is *optionally* used here, triggering when
> TCG is not built in:
> 
> qapi/qapi-commands-accelerator.c:85:13: error: 
> ‘qmp_marshal_output_HumanReadableText’ defined but not used [- 
> Werror=unused-function]
>     85 | static void 
> qmp_marshal_output_HumanReadableText(HumanReadableText *ret_in,
>        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> We previously discussed that issue:
> https://mail.gnu.org/archive/html/qemu-devel/2021-06/msg02667.html
> 
> where you said:
> 
> "conditional commands returning an unconditional type is a bit
> of a code smell". Is it however a "non-smelly instances of this pattern"?

For now I'm queuing this patch moving only KVM definitions,
not the conditional TCG one.

Regards,

Phil.