diff mbox series

[v2,2/4] qapi: Create module 'control'

Message ID 20200128175211.30007-3-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show
Series monitor: Refactoring in preparation for qemu-storage-daemon | expand

Commit Message

Kevin Wolf Jan. 28, 2020, 5:52 p.m. UTC
misc.json contains definitions that are related to the system emulator,
so it can't be used for other tools like the storage daemon. This patch
moves basic functionality that is shared between all tools (and mostly
related to the monitor itself) into a new control.json, which could be
used in tools as well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/control.json          | 218 +++++++++++++++++++++++++++++++++++++
 qapi/misc.json             | 212 ------------------------------------
 qapi/qapi-schema.json      |   1 +
 monitor/monitor-internal.h |   1 +
 monitor/hmp-cmds.c         |   1 +
 monitor/misc.c             |   1 +
 monitor/qmp-cmds.c         |   1 +
 monitor/qmp.c              |   2 +-
 tests/qtest/qmp-test.c     |   2 +-
 ui/gtk.c                   |   1 +
 qapi/Makefile.objs         |   6 +-
 11 files changed, 229 insertions(+), 217 deletions(-)
 create mode 100644 qapi/control.json

Comments

Markus Armbruster Jan. 29, 2020, 8:35 a.m. UTC | #1
Kevin Wolf <kwolf@redhat.com> writes:

> misc.json contains definitions that are related to the system emulator,
> so it can't be used for other tools like the storage daemon. This patch
> moves basic functionality that is shared between all tools (and mostly
> related to the monitor itself) into a new control.json, which could be
> used in tools as well.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qapi/control.json          | 218 +++++++++++++++++++++++++++++++++++++
>  qapi/misc.json             | 212 ------------------------------------
>  qapi/qapi-schema.json      |   1 +
>  monitor/monitor-internal.h |   1 +
>  monitor/hmp-cmds.c         |   1 +
>  monitor/misc.c             |   1 +
>  monitor/qmp-cmds.c         |   1 +
>  monitor/qmp.c              |   2 +-
>  tests/qtest/qmp-test.c     |   2 +-
>  ui/gtk.c                   |   1 +
>  qapi/Makefile.objs         |   6 +-
>  11 files changed, 229 insertions(+), 217 deletions(-)
>  create mode 100644 qapi/control.json
>
> diff --git a/qapi/control.json b/qapi/control.json
> new file mode 100644
> index 0000000000..a82a18da1a
> --- /dev/null
> +++ b/qapi/control.json
> @@ -0,0 +1,218 @@
> +# -*- Mode: Python -*-
> +#
> +

Let's add a copyright notice:

   # Copyright (C) 2011-2020 Red Hat, Inc.
   #
   # This work is licensed under the terms of the GNU GPL, version 2 or later.
   # See the COPYING file in the top-level directory.

> +##
> +# = Monitor definitions (shared between system emulator and tools)
> +##

This comment does double-duty: it's for readers of this source file, and
for readers of generated docs/interop/qemu-qmp-ref.*.  It's okay for
the former, but not the latter, as the resulting table of contents
shows:

    1 API Reference
      1.1 Introduction
      1.2 Stability Considerations
      1.3 QMP errors
      1.4 Common data types
      1.5 Socket data types
      1.6 VM run state
      1.7 Cryptography
      1.8 Block devices
        1.8.1 Block core (VM unrelated)
        1.8.2 Background jobs
        1.8.3 Additional block stuff (VM related)
      1.9 Character devices
      1.10 Dump guest memory
      1.11 Net devices
      1.12 RDMA device
      1.13 Rocker switch device
      1.14 TPM (trusted platform module) devices
      1.15 Remote desktop
        1.15.1 Spice
        1.15.2 VNC
      1.16 Input
      1.17 Migration
      1.18 Transactions
      1.19 Tracing
      1.20 QMP introspection
      1.21 QEMU Object Model (QOM)
      1.22 Device infrastructure (qdev)
      1.23 Machines
      1.24 Monitor definitions (shared between system emulator and tools)
      1.25 Miscellanea
    Commands and Events Index
    Data Types Index

Let's examine the file's contents to find a better description:

* qmp_capabilities
* QMPCapability

  QMP capabilities negotiation.  This is about the QMP monitor.  I
  figure few users of QMP need to know about it.  No need to complicate
  this patch to put it in the ideal spot (assuming there are ideal
  spots).

* query-version
* VersionInfo
* VersionTriple

  QMP query-version, QMP greeting, HMP info version

  Losely related to introspection, QMP capabilities negotiation (the
  greeting includes query-version output), and "process" below.

  The HMP use is an implementation detail.

* query-commands
* CommandInfo
* query-events
* EventInfo

  Legacy QMP introspection.  query-events is deprecated in favor of
  query-qmp-schema.  query-commands probably should be.

  Ideally, these go into or next to section 1.20 QMP introspection.
  Let's deprecate and put them wherever is easiest for the grace period.

* quit

  You move this here because like everything else you move here, you
  expect this to be present in any QMP monitor.  I expect that, too.

  It's not really about the QMP monitor, it's about controlling the
  process that provides the QMP monitor.

Proposed header:

    # = QMP monitor control

This files @quit under monitor control, which isn't quite right, but
it'll do.  Moving it away from @stop & friends is a bit unfortunate (see
patch to misc.json below).  If that bothers us, we need to split
control.json.  I'm not demanding such a split.

> +
> +##
> +# @qmp_capabilities:
> +#
> +# Enable QMP capabilities.
> +#
> +# Arguments:
> +#
> +# @enable:   An optional list of QMPCapability values to enable.  The
> +#            client must not enable any capability that is not
> +#            mentioned in the QMP greeting message.  If the field is not
> +#            provided, it means no QMP capabilities will be enabled.
> +#            (since 2.12)
> +#
> +# Example:
> +#
> +# -> { "execute": "qmp_capabilities",
> +#      "arguments": { "enable": [ "oob" ] } }
> +# <- { "return": {} }
> +#
> +# Notes: This command is valid exactly when first connecting: it must be
> +# issued before any other command will be accepted, and will fail once the
> +# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt)
> +#
> +# The QMP client needs to explicitly enable QMP capabilities, otherwise
> +# all the QMP capabilities will be turned off by default.
> +#
> +# Since: 0.13
> +#
> +##
> +{ 'command': 'qmp_capabilities',
> +  'data': { '*enable': [ 'QMPCapability' ] },
> +  'allow-preconfig': true }
> +
> +##
> +# @QMPCapability:
> +#
> +# Enumeration of capabilities to be advertised during initial client
> +# connection, used for agreeing on particular QMP extension behaviors.
> +#
> +# @oob:   QMP ability to support out-of-band requests.
> +#         (Please refer to qmp-spec.txt for more information on OOB)
> +#
> +# Since: 2.12
> +#
> +##
> +{ 'enum': 'QMPCapability',
> +  'data': [ 'oob' ] }
> +
> +##
> +# @VersionTriple:
> +#
> +# A three-part version number.
> +#
> +# @major:  The major version number.
> +#
> +# @minor:  The minor version number.
> +#
> +# @micro:  The micro version number.
> +#
> +# Since: 2.4
> +##
> +{ 'struct': 'VersionTriple',
> +  'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
> +
> +
> +##
> +# @VersionInfo:
> +#
> +# A description of QEMU's version.
> +#
> +# @qemu:        The version of QEMU.  By current convention, a micro
> +#               version of 50 signifies a development branch.  A micro version
> +#               greater than or equal to 90 signifies a release candidate for
> +#               the next minor version.  A micro version of less than 50
> +#               signifies a stable release.
> +#
> +# @package:     QEMU will always set this field to an empty string.  Downstream
> +#               versions of QEMU should set this to a non-empty string.  The
> +#               exact format depends on the downstream however it highly
> +#               recommended that a unique name is used.
> +#
> +# Since: 0.14.0
> +##
> +{ 'struct': 'VersionInfo',
> +  'data': {'qemu': 'VersionTriple', 'package': 'str'} }
> +
> +##
> +# @query-version:
> +#
> +# Returns the current version of QEMU.
> +#
> +# Returns:  A @VersionInfo object describing the current version of QEMU.
> +#
> +# Since: 0.14.0
> +#
> +# Example:
> +#
> +# -> { "execute": "query-version" }
> +# <- {
> +#       "return":{
> +#          "qemu":{
> +#             "major":0,
> +#             "minor":11,
> +#             "micro":5
> +#          },
> +#          "package":""
> +#       }
> +#    }
> +#
> +##
> +{ 'command': 'query-version', 'returns': 'VersionInfo',
> +  'allow-preconfig': true }
> +
> +##
> +# @CommandInfo:
> +#
> +# Information about a QMP command
> +#
> +# @name: The command name
> +#
> +# Since: 0.14.0
> +##
> +{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
> +
> +##
> +# @query-commands:
> +#
> +# Return a list of supported QMP commands by this server
> +#
> +# Returns: A list of @CommandInfo for all supported commands
> +#
> +# Since: 0.14.0
> +#
> +# Example:
> +#
> +# -> { "execute": "query-commands" }
> +# <- {
> +#      "return":[
> +#         {
> +#            "name":"query-balloon"
> +#         },
> +#         {
> +#            "name":"system_powerdown"
> +#         }
> +#      ]
> +#    }
> +#
> +# Note: This example has been shortened as the real response is too long.
> +#
> +##
> +{ 'command': 'query-commands', 'returns': ['CommandInfo'],
> +  'allow-preconfig': true }
> +
> +##
> +# @EventInfo:
> +#
> +# Information about a QMP event
> +#
> +# @name: The event name
> +#
> +# Since: 1.2.0
> +##
> +{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
> +
> +##
> +# @query-events:
> +#
> +# Return information on QMP events.
> +#
> +# Returns: A list of @EventInfo.
> +#
> +# Since: 1.2.0
> +#
> +# Note: This command is deprecated, because its output doesn't reflect
> +# compile-time configuration.  Use query-qmp-schema instead.
> +#
> +# Example:
> +#
> +# -> { "execute": "query-events" }
> +# <- {
> +#      "return": [
> +#          {
> +#             "name":"SHUTDOWN"
> +#          },
> +#          {
> +#             "name":"RESET"
> +#          }
> +#       ]
> +#    }
> +#
> +# Note: This example has been shortened as the real response is too long.
> +#
> +##
> +{ 'command': 'query-events', 'returns': ['EventInfo'] }
> +
> +##
> +# @quit:
> +#
> +# This command will cause the QEMU process to exit gracefully.  While every
> +# attempt is made to send the QMP response before terminating, this is not
> +# guaranteed.  When using this interface, a premature EOF would not be
> +# unexpected.
> +#
> +# Since: 0.14.0
> +#
> +# Example:
> +#
> +# -> { "execute": "quit" }
> +# <- { "return": {} }
> +##
> +{ 'command': 'quit' }
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 33b94e3589..cf656e9d4b 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -7,159 +7,6 @@
>  
>  { 'include': 'common.json' }
>  
> -##
> -# @qmp_capabilities:
> -#
> -# Enable QMP capabilities.
> -#
> -# Arguments:
> -#
> -# @enable:   An optional list of QMPCapability values to enable.  The
> -#            client must not enable any capability that is not
> -#            mentioned in the QMP greeting message.  If the field is not
> -#            provided, it means no QMP capabilities will be enabled.
> -#            (since 2.12)
> -#
> -# Example:
> -#
> -# -> { "execute": "qmp_capabilities",
> -#      "arguments": { "enable": [ "oob" ] } }
> -# <- { "return": {} }
> -#
> -# Notes: This command is valid exactly when first connecting: it must be
> -# issued before any other command will be accepted, and will fail once the
> -# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt)
> -#
> -# The QMP client needs to explicitly enable QMP capabilities, otherwise
> -# all the QMP capabilities will be turned off by default.
> -#
> -# Since: 0.13
> -#
> -##
> -{ 'command': 'qmp_capabilities',
> -  'data': { '*enable': [ 'QMPCapability' ] },
> -  'allow-preconfig': true }
> -
> -##
> -# @QMPCapability:
> -#
> -# Enumeration of capabilities to be advertised during initial client
> -# connection, used for agreeing on particular QMP extension behaviors.
> -#
> -# @oob:   QMP ability to support out-of-band requests.
> -#         (Please refer to qmp-spec.txt for more information on OOB)
> -#
> -# Since: 2.12
> -#
> -##
> -{ 'enum': 'QMPCapability',
> -  'data': [ 'oob' ] }
> -
> -##
> -# @VersionTriple:
> -#
> -# A three-part version number.
> -#
> -# @major:  The major version number.
> -#
> -# @minor:  The minor version number.
> -#
> -# @micro:  The micro version number.
> -#
> -# Since: 2.4
> -##
> -{ 'struct': 'VersionTriple',
> -  'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
> -
> -
> -##
> -# @VersionInfo:
> -#
> -# A description of QEMU's version.
> -#
> -# @qemu:        The version of QEMU.  By current convention, a micro
> -#               version of 50 signifies a development branch.  A micro version
> -#               greater than or equal to 90 signifies a release candidate for
> -#               the next minor version.  A micro version of less than 50
> -#               signifies a stable release.
> -#
> -# @package:     QEMU will always set this field to an empty string.  Downstream
> -#               versions of QEMU should set this to a non-empty string.  The
> -#               exact format depends on the downstream however it highly
> -#               recommended that a unique name is used.
> -#
> -# Since: 0.14.0
> -##
> -{ 'struct': 'VersionInfo',
> -  'data': {'qemu': 'VersionTriple', 'package': 'str'} }
> -
> -##
> -# @query-version:
> -#
> -# Returns the current version of QEMU.
> -#
> -# Returns:  A @VersionInfo object describing the current version of QEMU.
> -#
> -# Since: 0.14.0
> -#
> -# Example:
> -#
> -# -> { "execute": "query-version" }
> -# <- {
> -#       "return":{
> -#          "qemu":{
> -#             "major":0,
> -#             "minor":11,
> -#             "micro":5
> -#          },
> -#          "package":""
> -#       }
> -#    }
> -#
> -##
> -{ 'command': 'query-version', 'returns': 'VersionInfo',
> -  'allow-preconfig': true }
> -
> -##
> -# @CommandInfo:
> -#
> -# Information about a QMP command
> -#
> -# @name: The command name
> -#
> -# Since: 0.14.0
> -##
> -{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
> -
> -##
> -# @query-commands:
> -#
> -# Return a list of supported QMP commands by this server
> -#
> -# Returns: A list of @CommandInfo for all supported commands
> -#
> -# Since: 0.14.0
> -#
> -# Example:
> -#
> -# -> { "execute": "query-commands" }
> -# <- {
> -#      "return":[
> -#         {
> -#            "name":"query-balloon"
> -#         },
> -#         {
> -#            "name":"system_powerdown"
> -#         }
> -#      ]
> -#    }
> -#
> -# Note: This example has been shortened as the real response is too long.
> -#
> -##
> -{ 'command': 'query-commands', 'returns': ['CommandInfo'],
> -  'allow-preconfig': true }
> -
>  ##
>  # @LostTickPolicy:
>  #
> @@ -300,48 +147,6 @@
>  ##
>  { 'command': 'query-uuid', 'returns': 'UuidInfo', 'allow-preconfig': true }
>  
> -##
> -# @EventInfo:
> -#
> -# Information about a QMP event
> -#
> -# @name: The event name
> -#
> -# Since: 1.2.0
> -##
> -{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
> -
> -##
> -# @query-events:
> -#
> -# Return information on QMP events.
> -#
> -# Returns: A list of @EventInfo.
> -#
> -# Since: 1.2.0
> -#
> -# Note: This command is deprecated, because its output doesn't reflect
> -# compile-time configuration.  Use query-qmp-schema instead.
> -#
> -# Example:
> -#
> -# -> { "execute": "query-events" }
> -# <- {
> -#      "return": [
> -#          {
> -#             "name":"SHUTDOWN"
> -#          },
> -#          {
> -#             "name":"RESET"
> -#          }
> -#       ]
> -#    }
> -#
> -# Note: This example has been shortened as the real response is too long.
> -#
> -##
> -{ 'command': 'query-events', 'returns': ['EventInfo'] }
> -
>  ##
>  # @IOThreadInfo:
>  #
> @@ -764,23 +569,6 @@
>  ##
>  { 'command': 'query-pci', 'returns': ['PciInfo'] }
>  
> -##
> -# @quit:
> -#
> -# This command will cause the QEMU process to exit gracefully.  While every
> -# attempt is made to send the QMP response before terminating, this is not
> -# guaranteed.  When using this interface, a premature EOF would not be
> -# unexpected.
> -#
> -# Since: 0.14.0
> -#
> -# Example:
> -#
> -# -> { "execute": "quit" }
> -# <- { "return": {} }
> -##
> -{ 'command': 'quit' }
> -
>  ##
>  # @stop:
>  #
> diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> index 9751b11f8f..61fd91ede7 100644
> --- a/qapi/qapi-schema.json
> +++ b/qapi/qapi-schema.json
> @@ -103,6 +103,7 @@
>  { 'include': 'qdev.json' }
>  { 'include': 'machine.json' }
>  { 'include': 'machine-target.json' }
> +{ 'include': 'control.json' }
>  { 'include': 'misc.json' }
>  { 'include': 'misc-target.json' }
>  { 'include': 'audio.json' }

This determines position within docs/interop/qemu-qmp-ref.*.  Next to
misc.json is the least change.  Perhaps putting it next to
introspect.json would be better.

If we split @quit off control.json, then we could include the .json
providing @quit next to @stop & friends.  Again, I'm not demanding such
a split.

> diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
> index d78f5ca190..4d402ded85 100644
> --- a/monitor/monitor-internal.h
> +++ b/monitor/monitor-internal.h
> @@ -27,6 +27,7 @@
>  
>  #include "chardev/char-fe.h"
>  #include "monitor/monitor.h"
> +#include "qapi/qapi-types-control.h"
>  #include "qapi/qmp/dispatch.h"
>  #include "qapi/qmp/json-parser.h"
>  #include "qemu/readline.h"
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index d0e0af893a..abb052836b 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -33,6 +33,7 @@
>  #include "qapi/qapi-commands-char.h"
>  #include "qapi/qapi-commands-migration.h"
>  #include "qapi/qapi-commands-misc.h"
> +#include "qapi/qapi-commands-control.h"
>  #include "qapi/qapi-commands-net.h"
>  #include "qapi/qapi-commands-rocker.h"
>  #include "qapi/qapi-commands-run-state.h"

Please keep the qapi/qapi-commands-* sorted, like you do ...

> diff --git a/monitor/misc.c b/monitor/misc.c
> index 4752150a67..ce89cdb282 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -67,6 +67,7 @@
>  #include "qemu/thread.h"
>  #include "block/qapi.h"
>  #include "qapi/qapi-commands-char.h"
> +#include "qapi/qapi-commands-control.h"
>  #include "qapi/qapi-commands-migration.h"
>  #include "qapi/qapi-commands-misc.h"
>  #include "qapi/qapi-commands-qom.h"

... here.

> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index c6faa3eaf0..263b39e700 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -34,6 +34,7 @@
>  #include "qapi/qapi-commands-block-core.h"
>  #include "qapi/qapi-commands-machine.h"
>  #include "qapi/qapi-commands-misc.h"
> +#include "qapi/qapi-commands-control.h"
>  #include "qapi/qapi-commands-ui.h"
>  #include "qapi/qmp/qerror.h"
>  #include "hw/mem/memory-device.h"

Likewise.

> diff --git a/monitor/qmp.c b/monitor/qmp.c
> index 54c06ba824..8379c8f96e 100644
> --- a/monitor/qmp.c
> +++ b/monitor/qmp.c
> @@ -27,7 +27,7 @@
>  #include "chardev/char-io.h"
>  #include "monitor-internal.h"
>  #include "qapi/error.h"
> -#include "qapi/qapi-commands-misc.h"
> +#include "qapi/qapi-commands-control.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qapi/qmp/qjson.h"
>  #include "qapi/qmp/qlist.h"
> diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
> index 1b0eb69832..1a8876b6ca 100644
> --- a/tests/qtest/qmp-test.c
> +++ b/tests/qtest/qmp-test.c
> @@ -13,7 +13,7 @@
>  #include "qemu/osdep.h"
>  #include "libqtest.h"
>  #include "qapi/error.h"
> -#include "qapi/qapi-visit-misc.h"
> +#include "qapi/qapi-visit-control.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qapi/qmp/qlist.h"
>  #include "qapi/qobject-input-visitor.h"
> diff --git a/ui/gtk.c b/ui/gtk.c
> index d18892d1de..8ebbebe4ec 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -33,6 +33,7 @@
>  #include "qemu/osdep.h"
>  #include "qapi/error.h"
>  #include "qapi/qapi-commands-misc.h"
> +#include "qapi/qapi-commands-control.h"
>  #include "qemu/cutils.h"
>  
>  #include "ui/console.h"
> diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
> index a8f1f4c35e..20fcc37c2c 100644
> --- a/qapi/Makefile.objs
> +++ b/qapi/Makefile.objs
> @@ -5,9 +5,9 @@ util-obj-y += opts-visitor.o qapi-clone-visitor.o
>  util-obj-y += qmp-event.o
>  util-obj-y += qapi-util.o
>  
> -QAPI_COMMON_MODULES = audio authz block-core block char common crypto
> -QAPI_COMMON_MODULES += dump error introspect job machine migration misc net
> -QAPI_COMMON_MODULES += qdev qom rdma rocker run-state sockets tpm
> +QAPI_COMMON_MODULES = audio authz block-core block char common control crypto
> +QAPI_COMMON_MODULES += dump error introspect job machine migration misc
> +QAPI_COMMON_MODULES += net qdev qom rdma rocker run-state sockets tpm
>  QAPI_COMMON_MODULES += trace transaction ui
>  QAPI_TARGET_MODULES = machine-target misc-target
>  QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)

With the comments and the include directives tidied up:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Kevin Wolf Jan. 29, 2020, 9:09 a.m. UTC | #2
Am 29.01.2020 um 09:35 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
> 
> > misc.json contains definitions that are related to the system emulator,
> > so it can't be used for other tools like the storage daemon. This patch
> > moves basic functionality that is shared between all tools (and mostly
> > related to the monitor itself) into a new control.json, which could be
> > used in tools as well.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  qapi/control.json          | 218 +++++++++++++++++++++++++++++++++++++
> >  qapi/misc.json             | 212 ------------------------------------
> >  qapi/qapi-schema.json      |   1 +
> >  monitor/monitor-internal.h |   1 +
> >  monitor/hmp-cmds.c         |   1 +
> >  monitor/misc.c             |   1 +
> >  monitor/qmp-cmds.c         |   1 +
> >  monitor/qmp.c              |   2 +-
> >  tests/qtest/qmp-test.c     |   2 +-
> >  ui/gtk.c                   |   1 +
> >  qapi/Makefile.objs         |   6 +-
> >  11 files changed, 229 insertions(+), 217 deletions(-)
> >  create mode 100644 qapi/control.json
> >
> > diff --git a/qapi/control.json b/qapi/control.json
> > new file mode 100644
> > index 0000000000..a82a18da1a
> > --- /dev/null
> > +++ b/qapi/control.json
> > @@ -0,0 +1,218 @@
> > +# -*- Mode: Python -*-
> > +#
> > +
> 
> Let's add a copyright notice:
> 
>    # Copyright (C) 2011-2020 Red Hat, Inc.
>    #
>    # This work is licensed under the terms of the GNU GPL, version 2 or later.
>    # See the COPYING file in the top-level directory.

I'm not adding anything new, but just moving code from a file that
doesn't have a copyright notice. In fact, almost none of the schema
files have a copyright notice. I'm not comfortable adding legal
assertions without verifying that they are correct, and certainly not as
a side-effect of a code movement patch. This would be an unrelated
change.

I suggest that we leave this patch as is, and if you think copyright
notices should be added, the correct information can be tracked down
and added consistently for all schema files in a separate series.

> > +##
> > +# = Monitor definitions (shared between system emulator and tools)
> > +##
> 
> This comment does double-duty: it's for readers of this source file, and
> for readers of generated docs/interop/qemu-qmp-ref.*.  It's okay for
> the former, but not the latter, as the resulting table of contents
> shows:
> [...]

> Proposed header:
> 
>     # = QMP monitor control

Works for me.

> > diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> > index 9751b11f8f..61fd91ede7 100644
> > --- a/qapi/qapi-schema.json
> > +++ b/qapi/qapi-schema.json
> > @@ -103,6 +103,7 @@
> >  { 'include': 'qdev.json' }
> >  { 'include': 'machine.json' }
> >  { 'include': 'machine-target.json' }
> > +{ 'include': 'control.json' }
> >  { 'include': 'misc.json' }
> >  { 'include': 'misc-target.json' }
> >  { 'include': 'audio.json' }
> 
> This determines position within docs/interop/qemu-qmp-ref.*.  Next to
> misc.json is the least change.  Perhaps putting it next to
> introspect.json would be better.
> 
> If we split @quit off control.json, then we could include the .json
> providing @quit next to @stop & friends.  Again, I'm not demanding such
> a split.

I'll put it before introspect.json for now.

I don't think the whole order is overly meaningful and it could use some
rearrangement in general. Again, unrelated to this series.

> > diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
> > index d78f5ca190..4d402ded85 100644
> > --- a/monitor/monitor-internal.h
> > +++ b/monitor/monitor-internal.h
> > @@ -27,6 +27,7 @@
> >  
> >  #include "chardev/char-fe.h"
> >  #include "monitor/monitor.h"
> > +#include "qapi/qapi-types-control.h"
> >  #include "qapi/qmp/dispatch.h"
> >  #include "qapi/qmp/json-parser.h"
> >  #include "qemu/readline.h"
> > diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> > index d0e0af893a..abb052836b 100644
> > --- a/monitor/hmp-cmds.c
> > +++ b/monitor/hmp-cmds.c
> > @@ -33,6 +33,7 @@
> >  #include "qapi/qapi-commands-char.h"
> >  #include "qapi/qapi-commands-migration.h"
> >  #include "qapi/qapi-commands-misc.h"
> > +#include "qapi/qapi-commands-control.h"
> >  #include "qapi/qapi-commands-net.h"
> >  #include "qapi/qapi-commands-rocker.h"
> >  #include "qapi/qapi-commands-run-state.h"
> 
> Please keep the qapi/qapi-commands-* sorted, like you do ...

It is sorted! It's exactly where you would expect "-monitor"... *sigh*

/me goes back to finding each #include and moving it.
/me hates renaming header files.

> > diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
> > index a8f1f4c35e..20fcc37c2c 100644
> > --- a/qapi/Makefile.objs
> > +++ b/qapi/Makefile.objs
> > @@ -5,9 +5,9 @@ util-obj-y += opts-visitor.o qapi-clone-visitor.o
> >  util-obj-y += qmp-event.o
> >  util-obj-y += qapi-util.o
> >  
> > -QAPI_COMMON_MODULES = audio authz block-core block char common crypto
> > -QAPI_COMMON_MODULES += dump error introspect job machine migration misc net
> > -QAPI_COMMON_MODULES += qdev qom rdma rocker run-state sockets tpm
> > +QAPI_COMMON_MODULES = audio authz block-core block char common control crypto
> > +QAPI_COMMON_MODULES += dump error introspect job machine migration misc
> > +QAPI_COMMON_MODULES += net qdev qom rdma rocker run-state sockets tpm
> >  QAPI_COMMON_MODULES += trace transaction ui
> >  QAPI_TARGET_MODULES = machine-target misc-target
> >  QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)
> 
> With the comments and the include directives tidied up:
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Thanks. (I assume this means even without the copyright header.)

Kevin
Markus Armbruster Jan. 29, 2020, 9:41 a.m. UTC | #3
Kevin Wolf <kwolf@redhat.com> writes:

> Am 29.01.2020 um 09:35 hat Markus Armbruster geschrieben:
>> Kevin Wolf <kwolf@redhat.com> writes:
>> 
>> > misc.json contains definitions that are related to the system emulator,
>> > so it can't be used for other tools like the storage daemon. This patch
>> > moves basic functionality that is shared between all tools (and mostly
>> > related to the monitor itself) into a new control.json, which could be
>> > used in tools as well.
>> >
>> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> > ---
>> >  qapi/control.json          | 218 +++++++++++++++++++++++++++++++++++++
>> >  qapi/misc.json             | 212 ------------------------------------
>> >  qapi/qapi-schema.json      |   1 +
>> >  monitor/monitor-internal.h |   1 +
>> >  monitor/hmp-cmds.c         |   1 +
>> >  monitor/misc.c             |   1 +
>> >  monitor/qmp-cmds.c         |   1 +
>> >  monitor/qmp.c              |   2 +-
>> >  tests/qtest/qmp-test.c     |   2 +-
>> >  ui/gtk.c                   |   1 +
>> >  qapi/Makefile.objs         |   6 +-
>> >  11 files changed, 229 insertions(+), 217 deletions(-)
>> >  create mode 100644 qapi/control.json
>> >
>> > diff --git a/qapi/control.json b/qapi/control.json
>> > new file mode 100644
>> > index 0000000000..a82a18da1a
>> > --- /dev/null
>> > +++ b/qapi/control.json
>> > @@ -0,0 +1,218 @@
>> > +# -*- Mode: Python -*-
>> > +#
>> > +
>> 
>> Let's add a copyright notice:
>> 
>>    # Copyright (C) 2011-2020 Red Hat, Inc.
>>    #
>>    # This work is licensed under the terms of the GNU GPL, version 2 or later.
>>    # See the COPYING file in the top-level directory.
>
> I'm not adding anything new, but just moving code from a file that
> doesn't have a copyright notice. In fact, almost none of the schema
> files have a copyright notice. I'm not comfortable adding legal
> assertions without verifying that they are correct, and certainly not as
> a side-effect of a code movement patch. This would be an unrelated
> change.
>
> I suggest that we leave this patch as is, and if you think copyright
> notices should be added, the correct information can be tracked down
> and added consistently for all schema files in a separate series.

There is nothing to be tracked down.  Anything that lacks an explicit
copyright notice is under GPLv2+, as per LICENSE.

>> > +##
>> > +# = Monitor definitions (shared between system emulator and tools)
>> > +##
>> 
>> This comment does double-duty: it's for readers of this source file, and
>> for readers of generated docs/interop/qemu-qmp-ref.*.  It's okay for
>> the former, but not the latter, as the resulting table of contents
>> shows:
>> [...]
>
>> Proposed header:
>> 
>>     # = QMP monitor control
>
> Works for me.
>
>> > diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
>> > index 9751b11f8f..61fd91ede7 100644
>> > --- a/qapi/qapi-schema.json
>> > +++ b/qapi/qapi-schema.json
>> > @@ -103,6 +103,7 @@
>> >  { 'include': 'qdev.json' }
>> >  { 'include': 'machine.json' }
>> >  { 'include': 'machine-target.json' }
>> > +{ 'include': 'control.json' }
>> >  { 'include': 'misc.json' }
>> >  { 'include': 'misc-target.json' }
>> >  { 'include': 'audio.json' }
>> 
>> This determines position within docs/interop/qemu-qmp-ref.*.  Next to
>> misc.json is the least change.  Perhaps putting it next to
>> introspect.json would be better.
>> 
>> If we split @quit off control.json, then we could include the .json
>> providing @quit next to @stop & friends.  Again, I'm not demanding such
>> a split.
>
> I'll put it before introspect.json for now.
>
> I don't think the whole order is overly meaningful and it could use some
> rearrangement in general. Again, unrelated to this series.

Yes, the order could use some love.

>> > diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
>> > index d78f5ca190..4d402ded85 100644
>> > --- a/monitor/monitor-internal.h
>> > +++ b/monitor/monitor-internal.h
>> > @@ -27,6 +27,7 @@
>> >  
>> >  #include "chardev/char-fe.h"
>> >  #include "monitor/monitor.h"
>> > +#include "qapi/qapi-types-control.h"
>> >  #include "qapi/qmp/dispatch.h"
>> >  #include "qapi/qmp/json-parser.h"
>> >  #include "qemu/readline.h"
>> > diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
>> > index d0e0af893a..abb052836b 100644
>> > --- a/monitor/hmp-cmds.c
>> > +++ b/monitor/hmp-cmds.c
>> > @@ -33,6 +33,7 @@
>> >  #include "qapi/qapi-commands-char.h"
>> >  #include "qapi/qapi-commands-migration.h"
>> >  #include "qapi/qapi-commands-misc.h"
>> > +#include "qapi/qapi-commands-control.h"
>> >  #include "qapi/qapi-commands-net.h"
>> >  #include "qapi/qapi-commands-rocker.h"
>> >  #include "qapi/qapi-commands-run-state.h"
>> 
>> Please keep the qapi/qapi-commands-* sorted, like you do ...
>
> It is sorted! It's exactly where you would expect "-monitor"... *sigh*
>
> /me goes back to finding each #include and moving it.
> /me hates renaming header files.
>
>> > diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
>> > index a8f1f4c35e..20fcc37c2c 100644
>> > --- a/qapi/Makefile.objs
>> > +++ b/qapi/Makefile.objs
>> > @@ -5,9 +5,9 @@ util-obj-y += opts-visitor.o qapi-clone-visitor.o
>> >  util-obj-y += qmp-event.o
>> >  util-obj-y += qapi-util.o
>> >  
>> > -QAPI_COMMON_MODULES = audio authz block-core block char common crypto
>> > -QAPI_COMMON_MODULES += dump error introspect job machine migration misc net
>> > -QAPI_COMMON_MODULES += qdev qom rdma rocker run-state sockets tpm
>> > +QAPI_COMMON_MODULES = audio authz block-core block char common control crypto
>> > +QAPI_COMMON_MODULES += dump error introspect job machine migration misc
>> > +QAPI_COMMON_MODULES += net qdev qom rdma rocker run-state sockets tpm
>> >  QAPI_COMMON_MODULES += trace transaction ui
>> >  QAPI_TARGET_MODULES = machine-target misc-target
>> >  QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)
>> 
>> With the comments and the include directives tidied up:
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>
> Thanks. (I assume this means even without the copyright header.)

I'd prefer with, but I'll accept without.
Kevin Wolf Jan. 29, 2020, 10:17 a.m. UTC | #4
Am 29.01.2020 um 10:41 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
> 
> > Am 29.01.2020 um 09:35 hat Markus Armbruster geschrieben:
> >> Kevin Wolf <kwolf@redhat.com> writes:
> >> 
> >> > misc.json contains definitions that are related to the system emulator,
> >> > so it can't be used for other tools like the storage daemon. This patch
> >> > moves basic functionality that is shared between all tools (and mostly
> >> > related to the monitor itself) into a new control.json, which could be
> >> > used in tools as well.
> >> >
> >> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> >> > ---
> >> >  qapi/control.json          | 218 +++++++++++++++++++++++++++++++++++++
> >> >  qapi/misc.json             | 212 ------------------------------------
> >> >  qapi/qapi-schema.json      |   1 +
> >> >  monitor/monitor-internal.h |   1 +
> >> >  monitor/hmp-cmds.c         |   1 +
> >> >  monitor/misc.c             |   1 +
> >> >  monitor/qmp-cmds.c         |   1 +
> >> >  monitor/qmp.c              |   2 +-
> >> >  tests/qtest/qmp-test.c     |   2 +-
> >> >  ui/gtk.c                   |   1 +
> >> >  qapi/Makefile.objs         |   6 +-
> >> >  11 files changed, 229 insertions(+), 217 deletions(-)
> >> >  create mode 100644 qapi/control.json
> >> >
> >> > diff --git a/qapi/control.json b/qapi/control.json
> >> > new file mode 100644
> >> > index 0000000000..a82a18da1a
> >> > --- /dev/null
> >> > +++ b/qapi/control.json
> >> > @@ -0,0 +1,218 @@
> >> > +# -*- Mode: Python -*-
> >> > +#
> >> > +
> >> 
> >> Let's add a copyright notice:
> >> 
> >>    # Copyright (C) 2011-2020 Red Hat, Inc.
> >>    #
> >>    # This work is licensed under the terms of the GNU GPL, version 2 or later.
> >>    # See the COPYING file in the top-level directory.
> >
> > I'm not adding anything new, but just moving code from a file that
> > doesn't have a copyright notice. In fact, almost none of the schema
> > files have a copyright notice. I'm not comfortable adding legal
> > assertions without verifying that they are correct, and certainly not as
> > a side-effect of a code movement patch. This would be an unrelated
> > change.
> >
> > I suggest that we leave this patch as is, and if you think copyright
> > notices should be added, the correct information can be tracked down
> > and added consistently for all schema files in a separate series.
> 
> There is nothing to be tracked down.  Anything that lacks an explicit
> copyright notice is under GPLv2+, as per LICENSE.

The copyright holders should be tracked down rather than just putting
"Red Hat" there, which is most likely wrong. Not that copyright notices
anywhere else are much more complete, but they tend to be correct at
least when they are added (i.e. usually when the file is created), so
not updating them is the fault of the copyright holders that are
missing in the notice.

But anyway, it's unrelated to this patch in either case.

Kevin
diff mbox series

Patch

diff --git a/qapi/control.json b/qapi/control.json
new file mode 100644
index 0000000000..a82a18da1a
--- /dev/null
+++ b/qapi/control.json
@@ -0,0 +1,218 @@ 
+# -*- Mode: Python -*-
+#
+
+##
+# = Monitor definitions (shared between system emulator and tools)
+##
+
+##
+# @qmp_capabilities:
+#
+# Enable QMP capabilities.
+#
+# Arguments:
+#
+# @enable:   An optional list of QMPCapability values to enable.  The
+#            client must not enable any capability that is not
+#            mentioned in the QMP greeting message.  If the field is not
+#            provided, it means no QMP capabilities will be enabled.
+#            (since 2.12)
+#
+# Example:
+#
+# -> { "execute": "qmp_capabilities",
+#      "arguments": { "enable": [ "oob" ] } }
+# <- { "return": {} }
+#
+# Notes: This command is valid exactly when first connecting: it must be
+# issued before any other command will be accepted, and will fail once the
+# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt)
+#
+# The QMP client needs to explicitly enable QMP capabilities, otherwise
+# all the QMP capabilities will be turned off by default.
+#
+# Since: 0.13
+#
+##
+{ 'command': 'qmp_capabilities',
+  'data': { '*enable': [ 'QMPCapability' ] },
+  'allow-preconfig': true }
+
+##
+# @QMPCapability:
+#
+# Enumeration of capabilities to be advertised during initial client
+# connection, used for agreeing on particular QMP extension behaviors.
+#
+# @oob:   QMP ability to support out-of-band requests.
+#         (Please refer to qmp-spec.txt for more information on OOB)
+#
+# Since: 2.12
+#
+##
+{ 'enum': 'QMPCapability',
+  'data': [ 'oob' ] }
+
+##
+# @VersionTriple:
+#
+# A three-part version number.
+#
+# @major:  The major version number.
+#
+# @minor:  The minor version number.
+#
+# @micro:  The micro version number.
+#
+# Since: 2.4
+##
+{ 'struct': 'VersionTriple',
+  'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
+
+
+##
+# @VersionInfo:
+#
+# A description of QEMU's version.
+#
+# @qemu:        The version of QEMU.  By current convention, a micro
+#               version of 50 signifies a development branch.  A micro version
+#               greater than or equal to 90 signifies a release candidate for
+#               the next minor version.  A micro version of less than 50
+#               signifies a stable release.
+#
+# @package:     QEMU will always set this field to an empty string.  Downstream
+#               versions of QEMU should set this to a non-empty string.  The
+#               exact format depends on the downstream however it highly
+#               recommended that a unique name is used.
+#
+# Since: 0.14.0
+##
+{ 'struct': 'VersionInfo',
+  'data': {'qemu': 'VersionTriple', 'package': 'str'} }
+
+##
+# @query-version:
+#
+# Returns the current version of QEMU.
+#
+# Returns:  A @VersionInfo object describing the current version of QEMU.
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "query-version" }
+# <- {
+#       "return":{
+#          "qemu":{
+#             "major":0,
+#             "minor":11,
+#             "micro":5
+#          },
+#          "package":""
+#       }
+#    }
+#
+##
+{ 'command': 'query-version', 'returns': 'VersionInfo',
+  'allow-preconfig': true }
+
+##
+# @CommandInfo:
+#
+# Information about a QMP command
+#
+# @name: The command name
+#
+# Since: 0.14.0
+##
+{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
+
+##
+# @query-commands:
+#
+# Return a list of supported QMP commands by this server
+#
+# Returns: A list of @CommandInfo for all supported commands
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "query-commands" }
+# <- {
+#      "return":[
+#         {
+#            "name":"query-balloon"
+#         },
+#         {
+#            "name":"system_powerdown"
+#         }
+#      ]
+#    }
+#
+# Note: This example has been shortened as the real response is too long.
+#
+##
+{ 'command': 'query-commands', 'returns': ['CommandInfo'],
+  'allow-preconfig': true }
+
+##
+# @EventInfo:
+#
+# Information about a QMP event
+#
+# @name: The event name
+#
+# Since: 1.2.0
+##
+{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
+
+##
+# @query-events:
+#
+# Return information on QMP events.
+#
+# Returns: A list of @EventInfo.
+#
+# Since: 1.2.0
+#
+# Note: This command is deprecated, because its output doesn't reflect
+# compile-time configuration.  Use query-qmp-schema instead.
+#
+# Example:
+#
+# -> { "execute": "query-events" }
+# <- {
+#      "return": [
+#          {
+#             "name":"SHUTDOWN"
+#          },
+#          {
+#             "name":"RESET"
+#          }
+#       ]
+#    }
+#
+# Note: This example has been shortened as the real response is too long.
+#
+##
+{ 'command': 'query-events', 'returns': ['EventInfo'] }
+
+##
+# @quit:
+#
+# This command will cause the QEMU process to exit gracefully.  While every
+# attempt is made to send the QMP response before terminating, this is not
+# guaranteed.  When using this interface, a premature EOF would not be
+# unexpected.
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "quit" }
+# <- { "return": {} }
+##
+{ 'command': 'quit' }
diff --git a/qapi/misc.json b/qapi/misc.json
index 33b94e3589..cf656e9d4b 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -7,159 +7,6 @@ 
 
 { 'include': 'common.json' }
 
-##
-# @qmp_capabilities:
-#
-# Enable QMP capabilities.
-#
-# Arguments:
-#
-# @enable:   An optional list of QMPCapability values to enable.  The
-#            client must not enable any capability that is not
-#            mentioned in the QMP greeting message.  If the field is not
-#            provided, it means no QMP capabilities will be enabled.
-#            (since 2.12)
-#
-# Example:
-#
-# -> { "execute": "qmp_capabilities",
-#      "arguments": { "enable": [ "oob" ] } }
-# <- { "return": {} }
-#
-# Notes: This command is valid exactly when first connecting: it must be
-# issued before any other command will be accepted, and will fail once the
-# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt)
-#
-# The QMP client needs to explicitly enable QMP capabilities, otherwise
-# all the QMP capabilities will be turned off by default.
-#
-# Since: 0.13
-#
-##
-{ 'command': 'qmp_capabilities',
-  'data': { '*enable': [ 'QMPCapability' ] },
-  'allow-preconfig': true }
-
-##
-# @QMPCapability:
-#
-# Enumeration of capabilities to be advertised during initial client
-# connection, used for agreeing on particular QMP extension behaviors.
-#
-# @oob:   QMP ability to support out-of-band requests.
-#         (Please refer to qmp-spec.txt for more information on OOB)
-#
-# Since: 2.12
-#
-##
-{ 'enum': 'QMPCapability',
-  'data': [ 'oob' ] }
-
-##
-# @VersionTriple:
-#
-# A three-part version number.
-#
-# @major:  The major version number.
-#
-# @minor:  The minor version number.
-#
-# @micro:  The micro version number.
-#
-# Since: 2.4
-##
-{ 'struct': 'VersionTriple',
-  'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
-
-
-##
-# @VersionInfo:
-#
-# A description of QEMU's version.
-#
-# @qemu:        The version of QEMU.  By current convention, a micro
-#               version of 50 signifies a development branch.  A micro version
-#               greater than or equal to 90 signifies a release candidate for
-#               the next minor version.  A micro version of less than 50
-#               signifies a stable release.
-#
-# @package:     QEMU will always set this field to an empty string.  Downstream
-#               versions of QEMU should set this to a non-empty string.  The
-#               exact format depends on the downstream however it highly
-#               recommended that a unique name is used.
-#
-# Since: 0.14.0
-##
-{ 'struct': 'VersionInfo',
-  'data': {'qemu': 'VersionTriple', 'package': 'str'} }
-
-##
-# @query-version:
-#
-# Returns the current version of QEMU.
-#
-# Returns:  A @VersionInfo object describing the current version of QEMU.
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "query-version" }
-# <- {
-#       "return":{
-#          "qemu":{
-#             "major":0,
-#             "minor":11,
-#             "micro":5
-#          },
-#          "package":""
-#       }
-#    }
-#
-##
-{ 'command': 'query-version', 'returns': 'VersionInfo',
-  'allow-preconfig': true }
-
-##
-# @CommandInfo:
-#
-# Information about a QMP command
-#
-# @name: The command name
-#
-# Since: 0.14.0
-##
-{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
-
-##
-# @query-commands:
-#
-# Return a list of supported QMP commands by this server
-#
-# Returns: A list of @CommandInfo for all supported commands
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "query-commands" }
-# <- {
-#      "return":[
-#         {
-#            "name":"query-balloon"
-#         },
-#         {
-#            "name":"system_powerdown"
-#         }
-#      ]
-#    }
-#
-# Note: This example has been shortened as the real response is too long.
-#
-##
-{ 'command': 'query-commands', 'returns': ['CommandInfo'],
-  'allow-preconfig': true }
-
 ##
 # @LostTickPolicy:
 #
@@ -300,48 +147,6 @@ 
 ##
 { 'command': 'query-uuid', 'returns': 'UuidInfo', 'allow-preconfig': true }
 
-##
-# @EventInfo:
-#
-# Information about a QMP event
-#
-# @name: The event name
-#
-# Since: 1.2.0
-##
-{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
-
-##
-# @query-events:
-#
-# Return information on QMP events.
-#
-# Returns: A list of @EventInfo.
-#
-# Since: 1.2.0
-#
-# Note: This command is deprecated, because its output doesn't reflect
-# compile-time configuration.  Use query-qmp-schema instead.
-#
-# Example:
-#
-# -> { "execute": "query-events" }
-# <- {
-#      "return": [
-#          {
-#             "name":"SHUTDOWN"
-#          },
-#          {
-#             "name":"RESET"
-#          }
-#       ]
-#    }
-#
-# Note: This example has been shortened as the real response is too long.
-#
-##
-{ 'command': 'query-events', 'returns': ['EventInfo'] }
-
 ##
 # @IOThreadInfo:
 #
@@ -764,23 +569,6 @@ 
 ##
 { 'command': 'query-pci', 'returns': ['PciInfo'] }
 
-##
-# @quit:
-#
-# This command will cause the QEMU process to exit gracefully.  While every
-# attempt is made to send the QMP response before terminating, this is not
-# guaranteed.  When using this interface, a premature EOF would not be
-# unexpected.
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "quit" }
-# <- { "return": {} }
-##
-{ 'command': 'quit' }
-
 ##
 # @stop:
 #
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index 9751b11f8f..61fd91ede7 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -103,6 +103,7 @@ 
 { 'include': 'qdev.json' }
 { 'include': 'machine.json' }
 { 'include': 'machine-target.json' }
+{ 'include': 'control.json' }
 { 'include': 'misc.json' }
 { 'include': 'misc-target.json' }
 { 'include': 'audio.json' }
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index d78f5ca190..4d402ded85 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -27,6 +27,7 @@ 
 
 #include "chardev/char-fe.h"
 #include "monitor/monitor.h"
+#include "qapi/qapi-types-control.h"
 #include "qapi/qmp/dispatch.h"
 #include "qapi/qmp/json-parser.h"
 #include "qemu/readline.h"
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index d0e0af893a..abb052836b 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -33,6 +33,7 @@ 
 #include "qapi/qapi-commands-char.h"
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-control.h"
 #include "qapi/qapi-commands-net.h"
 #include "qapi/qapi-commands-rocker.h"
 #include "qapi/qapi-commands-run-state.h"
diff --git a/monitor/misc.c b/monitor/misc.c
index 4752150a67..ce89cdb282 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -67,6 +67,7 @@ 
 #include "qemu/thread.h"
 #include "block/qapi.h"
 #include "qapi/qapi-commands-char.h"
+#include "qapi/qapi-commands-control.h"
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qapi-commands-misc.h"
 #include "qapi/qapi-commands-qom.h"
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index c6faa3eaf0..263b39e700 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -34,6 +34,7 @@ 
 #include "qapi/qapi-commands-block-core.h"
 #include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-control.h"
 #include "qapi/qapi-commands-ui.h"
 #include "qapi/qmp/qerror.h"
 #include "hw/mem/memory-device.h"
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 54c06ba824..8379c8f96e 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -27,7 +27,7 @@ 
 #include "chardev/char-io.h"
 #include "monitor-internal.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-control.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qlist.h"
diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
index 1b0eb69832..1a8876b6ca 100644
--- a/tests/qtest/qmp-test.c
+++ b/tests/qtest/qmp-test.c
@@ -13,7 +13,7 @@ 
 #include "qemu/osdep.h"
 #include "libqtest.h"
 #include "qapi/error.h"
-#include "qapi/qapi-visit-misc.h"
+#include "qapi/qapi-visit-control.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qlist.h"
 #include "qapi/qobject-input-visitor.h"
diff --git a/ui/gtk.c b/ui/gtk.c
index d18892d1de..8ebbebe4ec 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -33,6 +33,7 @@ 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-control.h"
 #include "qemu/cutils.h"
 
 #include "ui/console.h"
diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
index a8f1f4c35e..20fcc37c2c 100644
--- a/qapi/Makefile.objs
+++ b/qapi/Makefile.objs
@@ -5,9 +5,9 @@  util-obj-y += opts-visitor.o qapi-clone-visitor.o
 util-obj-y += qmp-event.o
 util-obj-y += qapi-util.o
 
-QAPI_COMMON_MODULES = audio authz block-core block char common crypto
-QAPI_COMMON_MODULES += dump error introspect job machine migration misc net
-QAPI_COMMON_MODULES += qdev qom rdma rocker run-state sockets tpm
+QAPI_COMMON_MODULES = audio authz block-core block char common control crypto
+QAPI_COMMON_MODULES += dump error introspect job machine migration misc
+QAPI_COMMON_MODULES += net qdev qom rdma rocker run-state sockets tpm
 QAPI_COMMON_MODULES += trace transaction ui
 QAPI_TARGET_MODULES = machine-target misc-target
 QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)