[PATCH v2 00/30] Configurable policy for handling deprecated interfaces

Markus Armbruster posted 30 patches 4 years, 1 month ago
Failed in applying to current master (apply log)
There is a newer version of this series
docs/devel/qapi-code-gen.txt                  |  79 ++-
qemu-deprecated.texi                          |  38 +-
tests/qapi-schema/doc-good.texi               |  32 ++
qapi/block-core.json                          |  69 ++-
qapi/block.json                               |   9 +-
qapi/char.json                                |   1 +
qapi/compat.json                              |  52 ++
qapi/control.json                             |  11 +-
qapi/introspect.json                          |  26 +-
qapi/machine.json                             |  34 +-
qapi/migration.json                           |  36 +-
qapi/misc.json                                |  13 +-
qapi/qapi-schema.json                         |   1 +
include/qapi/compat-policy.h                  |  20 +
include/qapi/qmp/dispatch.h                   |   1 +
include/qapi/qobject-input-visitor.h          |   9 +
include/qapi/qobject-output-visitor.h         |   9 +
include/qapi/visitor-impl.h                   |   3 +
include/qapi/visitor.h                        |   9 +
qapi/qapi-visit-core.c                        |   9 +
qapi/qmp-dispatch.c                           | 137 ++---
qapi/qobject-input-visitor.c                  |  29 ++
qapi/qobject-output-visitor.c                 |  20 +
softmmu/vl.c                                  |  17 +
tests/test-qmp-cmds.c                         | 249 +++++----
tests/test-qmp-event.c                        | 183 ++-----
qapi/Makefile.objs                            |   8 +-
qapi/trace-events                             |   1 +
qemu-options.hx                               |  23 +
scripts/qapi/commands.py                      |  20 +-
scripts/qapi/doc.py                           |  16 +-
scripts/qapi/events.py                        |  16 +-
scripts/qapi/expr.py                          |  14 +-
scripts/qapi/introspect.py                    | 104 ++--
scripts/qapi/schema.py                        | 488 ++++++++++--------
scripts/qapi/types.py                         |   8 +-
scripts/qapi/visit.py                         |  28 +-
tests/Makefile.include                        |   1 +
tests/qapi-schema/alternate-base.err          |   2 +-
tests/qapi-schema/doc-good.json               |  22 +-
tests/qapi-schema/doc-good.out                |  18 +
.../qapi-schema/features-deprecated-type.err  |   2 +
.../qapi-schema/features-deprecated-type.json |   3 +
.../qapi-schema/features-deprecated-type.out  |   0
tests/qapi-schema/qapi-schema-test.json       |  48 +-
tests/qapi-schema/qapi-schema-test.out        |  46 +-
tests/qapi-schema/test-qapi.py                |  26 +-
47 files changed, 1259 insertions(+), 731 deletions(-)
create mode 100644 qapi/compat.json
create mode 100644 include/qapi/compat-policy.h
create mode 100644 tests/qapi-schema/features-deprecated-type.err
create mode 100644 tests/qapi-schema/features-deprecated-type.json
create mode 100644 tests/qapi-schema/features-deprecated-type.out
[PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Markus Armbruster 4 years, 1 month ago
Based-on: <20200227144531.24309-1-armbru@redhat.com>

This series extends QMP introspection to cover deprecation.
Additionally, new option -compat lets you configure what to do when
deprecated interfaces get used.  This is intended for testing users of
the management interfaces.  It is experimental.

-compat deprecated-input=<in-policy> configures what to do when
deprecated input is received.  Available policies:

* accept: Accept deprecated commands and arguments (default)
* reject: Reject them
* crash: Crash

-compat deprecated-output=<out-policy> configures what to do when
deprecated output is sent.  Available output policies:

* accept: Emit deprecated command results and events (default)
* hide: Suppress them

For now, -compat covers only deprecated syntactic aspects of QMP.  We
may want to extend it to cover semantic aspects, CLI, and experimental
features.

PATCH 01-04: Documentation fixes
PATCH 05-10: Test improvements
PATCH 11-24: Add feature flags to remaining user-defined types and to
      	     struct members
PATCH 25-26: New special feature 'deprecated', visible in
      	     introspection
PATCH 27-30: New -compat to set policy for handling stuff marked with
      	     feature 'deprecated'

Comparison to RFC (24 Oct 2019):
* Cover arguments and results in addition to commands and events
* Half-baked "[RFC PATCH 18/19] qapi: Include a warning in the
  response to a deprecated command" dropped

See also last item of
    Subject: Minutes of KVM Forum BoF on deprecating stuff
    Date: Fri, 26 Oct 2018 16:03:51 +0200
    Message-ID: <87mur0ls8o.fsf@dusky.pond.sub.org>
    https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg05828.html

Markus Armbruster (30):
  qemu-doc: Belatedly document QMP command arg & result deprecation
  qapi: Belatedly update doc comment for @wait deprecation
  docs/devel/qapi-code-gen: Clarify allow-oob introspection
  docs/devel/qapi-code-gen: Document 'features' introspection
  tests/test-qmp-cmds: Factor out qmp_dispatch() test helpers
  tests/test-qmp-cmds: Check responses more thoroughly
  tests/test-qmp-cmds: Simplify test data setup
  tests/test-qmp-event: Simplify test data setup
  tests/test-qmp-event: Use qobject_is_equal()
  tests/test-qmp-event: Check event is actually emitted
  qapi/schema: Clean up around QAPISchemaEntity.connect_doc()
  qapi: Add feature flags to remaining definitions
  qapi: Consistently put @features parameter right after @ifcond
  qapi/introspect: Rename *qlit* to reduce confusion
  qapi/introspect: Factor out _make_tree()
  qapi/schema: Change _make_features() to a take feature list
  qapi/schema: Reorder classes so related ones are together
  qapi/schema: Rename QAPISchemaObjectType{Variant,Variants}
  qapi/schema: Call QAPIDoc.connect_member() in just one place
  qapi: Add feature flags to struct members
  qapi: Inline do_qmp_dispatch() into qmp_dispatch()
  qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP
  qapi: Simplify how qmp_dispatch() gets the request ID
  qapi: Replace qmp_dispatch()'s TODO comment by an explanation
  qapi: New special feature flag "deprecated"
  qapi: Mark deprecated QMP parts with feature 'deprecated'
  qemu-options: New -compat to set policy for deprecated interfaces
  qapi: Implement -compat deprecated-output=hide
  qapi: Implement -compat deprecated-input=reject
  qapi: New -compat deprecated-input=crash

 docs/devel/qapi-code-gen.txt                  |  79 ++-
 qemu-deprecated.texi                          |  38 +-
 tests/qapi-schema/doc-good.texi               |  32 ++
 qapi/block-core.json                          |  69 ++-
 qapi/block.json                               |   9 +-
 qapi/char.json                                |   1 +
 qapi/compat.json                              |  52 ++
 qapi/control.json                             |  11 +-
 qapi/introspect.json                          |  26 +-
 qapi/machine.json                             |  34 +-
 qapi/migration.json                           |  36 +-
 qapi/misc.json                                |  13 +-
 qapi/qapi-schema.json                         |   1 +
 include/qapi/compat-policy.h                  |  20 +
 include/qapi/qmp/dispatch.h                   |   1 +
 include/qapi/qobject-input-visitor.h          |   9 +
 include/qapi/qobject-output-visitor.h         |   9 +
 include/qapi/visitor-impl.h                   |   3 +
 include/qapi/visitor.h                        |   9 +
 qapi/qapi-visit-core.c                        |   9 +
 qapi/qmp-dispatch.c                           | 137 ++---
 qapi/qobject-input-visitor.c                  |  29 ++
 qapi/qobject-output-visitor.c                 |  20 +
 softmmu/vl.c                                  |  17 +
 tests/test-qmp-cmds.c                         | 249 +++++----
 tests/test-qmp-event.c                        | 183 ++-----
 qapi/Makefile.objs                            |   8 +-
 qapi/trace-events                             |   1 +
 qemu-options.hx                               |  23 +
 scripts/qapi/commands.py                      |  20 +-
 scripts/qapi/doc.py                           |  16 +-
 scripts/qapi/events.py                        |  16 +-
 scripts/qapi/expr.py                          |  14 +-
 scripts/qapi/introspect.py                    | 104 ++--
 scripts/qapi/schema.py                        | 488 ++++++++++--------
 scripts/qapi/types.py                         |   8 +-
 scripts/qapi/visit.py                         |  28 +-
 tests/Makefile.include                        |   1 +
 tests/qapi-schema/alternate-base.err          |   2 +-
 tests/qapi-schema/doc-good.json               |  22 +-
 tests/qapi-schema/doc-good.out                |  18 +
 .../qapi-schema/features-deprecated-type.err  |   2 +
 .../qapi-schema/features-deprecated-type.json |   3 +
 .../qapi-schema/features-deprecated-type.out  |   0
 tests/qapi-schema/qapi-schema-test.json       |  48 +-
 tests/qapi-schema/qapi-schema-test.out        |  46 +-
 tests/qapi-schema/test-qapi.py                |  26 +-
 47 files changed, 1259 insertions(+), 731 deletions(-)
 create mode 100644 qapi/compat.json
 create mode 100644 include/qapi/compat-policy.h
 create mode 100644 tests/qapi-schema/features-deprecated-type.err
 create mode 100644 tests/qapi-schema/features-deprecated-type.json
 create mode 100644 tests/qapi-schema/features-deprecated-type.out

-- 
2.21.1

Re: [PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Peter Maydell 4 years, 1 month ago
On Tue, 3 Mar 2020 at 16:37, Markus Armbruster <armbru@redhat.com> wrote:
>
> Based-on: <20200227144531.24309-1-armbru@redhat.com>
>
> This series extends QMP introspection to cover deprecation.
> Additionally, new option -compat lets you configure what to do when
> deprecated interfaces get used.  This is intended for testing users of
> the management interfaces.  It is experimental.

How much do you think this is likely to affect the
generate-rst-from-qapi-docs series? I'd really like
that to go in for this release, but this looks like
it's shaping up to be a big conflict :-(

thanks
-- PMM


Re: [PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Markus Armbruster 4 years, 1 month ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On Tue, 3 Mar 2020 at 16:37, Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Based-on: <20200227144531.24309-1-armbru@redhat.com>
>>
>> This series extends QMP introspection to cover deprecation.
>> Additionally, new option -compat lets you configure what to do when
>> deprecated interfaces get used.  This is intended for testing users of
>> the management interfaces.  It is experimental.
>
> How much do you think this is likely to affect the
> generate-rst-from-qapi-docs series? I'd really like
> that to go in for this release, but this looks like
> it's shaping up to be a big conflict :-(

I paused reviewing your series to post this one, because "I'd really
like that to go in for this release" :)

My series touches 21 existing commented definitions in qapi/, six more
in tests/qapi-schema/doc-good.json, and adds new module
qapi/compat.json.  Consolidated diff appended.

Rule of thumb for reducing conflict resolution labor: the bigger manual
change goes first.  Yours is bigger, but I don't remember how manual it
is.

Let's try to get both series reviewed, then figure out together how to
get them merged with the least pain.



$ git-diff -p --stat master posted/qapi-features \*.json
 qapi/block-core.json                            | 69 +++++++++++++++++++------
 qapi/block.json                                 |  9 ++--
 qapi/char.json                                  |  1 +
 qapi/compat.json                                | 52 +++++++++++++++++++
 qapi/control.json                               | 11 ++--
 qapi/introspect.json                            | 26 +++++-----
 qapi/machine.json                               | 34 ++++++------
 qapi/migration.json                             | 36 ++++++++-----
 qapi/misc.json                                  | 13 ++---
 qapi/qapi-schema.json                           |  1 +
 tests/qapi-schema/doc-good.json                 | 22 +++++++-
 tests/qapi-schema/features-deprecated-type.json |  3 ++
 tests/qapi-schema/qapi-schema-test.json         | 48 +++++++++++------
 13 files changed, 239 insertions(+), 86 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 85e27bb61f..bade02760c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -297,7 +297,7 @@
 #
 # @encrypted: true if the backing device is encrypted
 #
-# @encryption_key_missing: Deprecated; always false
+# @encryption_key_missing: always false
 #
 # @detect_zeroes: detect and optimize zero writes (Since 2.1)
 #
@@ -363,13 +363,19 @@
 # @dirty-bitmaps: dirty bitmaps information (only present if node
 #                 has one or more dirty bitmaps) (Since 4.2)
 #
+# Features:
+# @deprecated: Member @encryption_key_missing is deprecated.  It is
+#     always false.
+#
 # Since: 0.14.0
 #
 ##
 { 'struct': 'BlockDeviceInfo',
   'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
             '*backing_file': 'str', 'backing_file_depth': 'int',
-            'encrypted': 'bool', 'encryption_key_missing': 'bool',
+            'encrypted': 'bool',
+            'encryption_key_missing': { 'type': 'bool',
+                                        'features': [ 'deprecated' ] },
             'detect_zeroes': 'BlockdevDetectZeroesOptions',
             'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
             'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
@@ -475,7 +481,7 @@
 #
 # @granularity: granularity of the dirty bitmap in bytes (since 1.4)
 #
-# @status: Deprecated in favor of @recording and @locked. (since 2.4)
+# @status: current status of the dirty bitmap (since 2.4)
 #
 # @recording: true if the bitmap is recording new writes from the guest.
 #             Replaces `active` and `disabled` statuses. (since 4.0)
@@ -492,11 +498,17 @@
 #                @busy to be false. This bitmap cannot be used. To remove
 #                it, use @block-dirty-bitmap-remove. (Since 4.0)
 #
+# Features:
+# @deprecated: Member @status is deprecated.  Use @recording and
+#     @locked instead.
+#
 # Since: 1.3
 ##
 { 'struct': 'BlockDirtyInfo',
   'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
-           'recording': 'bool', 'busy': 'bool', 'status': 'DirtyBitmapStatus',
+           'recording': 'bool', 'busy': 'bool',
+           'status': { 'type': 'DirtyBitmapStatus',
+                       'features': [ 'deprecated' ] },
            'persistent': 'bool', '*inconsistent': 'bool' } }
 
 ##
@@ -659,7 +671,6 @@
 #
 # @dirty-bitmaps: dirty bitmaps information (only present if the
 #                 driver has one or more dirty bitmaps) (Since 2.0)
-#                 Deprecated in 4.2; see BlockDeviceInfo instead.
 #
 # @io-status: @BlockDeviceIoStatus. Only present if the device
 #             supports it and the VM is configured to stop on errors
@@ -669,13 +680,18 @@
 # @inserted: @BlockDeviceInfo describing the device if media is
 #            present
 #
+# Features:
+# @deprecated: Member @dirty-bitmaps is deprecated.  Use @inserted
+#     member @dirty-bitmaps instead.
+#
 # Since:  0.14.0
 ##
 { 'struct': 'BlockInfo',
   'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool',
            'locked': 'bool', '*inserted': 'BlockDeviceInfo',
            '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
-           '*dirty-bitmaps': ['BlockDirtyInfo'] } }
+           '*dirty-bitmaps': { 'type': ['BlockDirtyInfo'],
+                               'features': [ 'deprecated' ] } } }
 
 ##
 # @BlockMeasureInfo:
@@ -1616,7 +1632,7 @@
 # @base: Same as @base-node, except that it is a file name rather than a node
 #        name. This must be the exact filename string that was used to open the
 #        node; other strings, even if addressing the same file, are not
-#        accepted (deprecated, use @base-node instead)
+#        accepted
 #
 # @top-node: The node name of the backing image within the image chain
 #            which contains the topmost data to be committed down. If
@@ -1625,7 +1641,7 @@
 # @top: Same as @top-node, except that it is a file name rather than a node
 #       name. This must be the exact filename string that was used to open the
 #       node; other strings, even if addressing the same file, are not
-#       accepted (deprecated, use @base-node instead)
+#       accepted
 #
 # @backing-file: The backing file string to write into the overlay
 #                image of 'top'.  If 'top' is the active layer,
@@ -1679,6 +1695,10 @@
 #                list without user intervention.
 #                Defaults to true. (Since 3.1)
 #
+# Features:
+# @deprecated: Members @base and @top are deprecated.  Use @base-node
+#     and @top-node instead.
+#
 # Returns: - Nothing on success
 #          - If @device does not exist, DeviceNotFound
 #          - Any other error returns a GenericError.
@@ -1695,7 +1715,9 @@
 ##
 { 'command': 'block-commit',
   'data': { '*job-id': 'str', 'device': 'str', '*base-node': 'str',
-            '*base': 'str', '*top-node': 'str', '*top': 'str',
+            '*base': { 'type': 'str', 'features': [ 'deprecated' ] },
+            '*top-node': 'str',
+            '*top': { 'type': 'str', 'features': [ 'deprecated' ] },
             '*backing-file': 'str', '*speed': 'int',
             '*on-error': 'BlockdevOnError',
             '*filter-node-name': 'str',
@@ -2433,7 +2455,7 @@
 #
 # A set of parameters describing block throttling.
 #
-# @device: Block device name (deprecated, use @id instead)
+# @device: Block device name
 #
 # @id: The name or QOM path of the guest device (since: 2.8)
 #
@@ -2501,10 +2523,14 @@
 #
 # @group: throttle group name (Since 2.4)
 #
+# Features:
+# @deprecated: Member @device is deprecated.  Use @id instead.
+#
 # Since: 1.1
 ##
 { 'struct': 'BlockIOThrottle',
-  'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
+  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
+            '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
             'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
             '*bps_max': 'int', '*bps_rd_max': 'int',
             '*bps_wr_max': 'int', '*iops_max': 'int',
@@ -4776,7 +4802,7 @@
 #   to it
 # - if the guest device does not have an actual tray
 #
-# @device: Block device name (deprecated, use @id instead)
+# @device: Block device name
 #
 # @id: The name or QOM path of the guest device (since: 2.8)
 #
@@ -4785,6 +4811,9 @@
 #         immediately); if true, the tray will be opened regardless of whether
 #         it is locked
 #
+# Features:
+# @deprecated: Member @device is deprecated.  Use @id instead.
+#
 # Since: 2.5
 #
 # Example:
@@ -4803,7 +4832,7 @@
 #
 ##
 { 'command': 'blockdev-open-tray',
-  'data': { '*device': 'str',
+  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
             '*id': 'str',
             '*force': 'bool' } }
 
@@ -4816,10 +4845,13 @@
 #
 # If the tray was already closed before, this will be a no-op.
 #
-# @device: Block device name (deprecated, use @id instead)
+# @device: Block device name
 #
 # @id: The name or QOM path of the guest device (since: 2.8)
 #
+# Features:
+# @deprecated: Member @device is deprecated.  Use @id instead.
+#
 # Since: 2.5
 #
 # Example:
@@ -4838,7 +4870,7 @@
 #
 ##
 { 'command': 'blockdev-close-tray',
-  'data': { '*device': 'str',
+  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
             '*id': 'str' } }
 
 ##
@@ -4945,7 +4977,7 @@
 # combines blockdev-open-tray, blockdev-remove-medium, blockdev-insert-medium
 # and blockdev-close-tray).
 #
-# @device: Block device name (deprecated, use @id instead)
+# @device: Block device name
 #
 # @id: The name or QOM path of the guest device
 #      (since: 2.8)
@@ -4958,6 +4990,9 @@
 # @read-only-mode: change the read-only mode of the device; defaults
 #                  to 'retain'
 #
+# Features:
+# @deprecated: Member @device is deprecated.  Use @id instead.
+#
 # Since: 2.5
 #
 # Examples:
@@ -4992,7 +5027,7 @@
 #
 ##
 { 'command': 'blockdev-change-medium',
-  'data': { '*device': 'str',
+  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
             '*id': 'str',
             'filename': 'str',
             '*format': 'str',
diff --git a/qapi/block.json b/qapi/block.json
index da19834db4..8314ef21d1 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -185,15 +185,18 @@
 ##
 # @eject:
 #
-# Ejects a device from a removable drive.
+# Ejects the medium from a removable block device.
 #
-# @device: Block device name (deprecated, use @id instead)
+# @device: Block device name
 #
 # @id: The name or QOM path of the guest device (since: 2.8)
 #
 # @force: If true, eject regardless of whether the drive is locked.
 #         If not specified, the default value is false.
 #
+# Features:
+# @deprecated: Member @device is deprecated.  Use @id instead.
+#
 # Returns: - Nothing on success
 #          - If @device is not a valid block device, DeviceNotFound
 # Notes:    Ejecting a device with no media results in success
@@ -206,7 +209,7 @@
 # <- { "return": {} }
 ##
 { 'command': 'eject',
-  'data': { '*device': 'str',
+  'data': { '*device': { 'type': 'str', 'features': [ 'deprecated' ] },
             '*id': 'str',
             '*force': 'bool' } }
 
diff --git a/qapi/char.json b/qapi/char.json
index 6907b2bfdb..daceb20f84 100644
--- a/qapi/char.json
+++ b/qapi/char.json
@@ -258,6 +258,7 @@
 # @server: create server socket (default: true)
 # @wait: wait for incoming connection on server
 #        sockets (default: false).
+#        Silently ignored with server: false.  This use is deprecated.
 # @nodelay: set TCP_NODELAY socket option (default: false)
 # @telnet: enable telnet protocol on server
 #          sockets (default: false)
diff --git a/qapi/compat.json b/qapi/compat.json
new file mode 100644
index 0000000000..ec24567639
--- /dev/null
+++ b/qapi/compat.json
@@ -0,0 +1,52 @@
+# -*- Mode: Python -*-
+
+##
+# = Compatibility policy
+##
+
+##
+# @CompatPolicyInput:
+#
+# Policy for handling "funny" input.
+#
+# @accept: Accept silently
+# @reject: Reject with an error
+# @crash: abort() the process
+#
+# Since: 5.0
+##
+{ 'enum': 'CompatPolicyInput',
+  'data': [ 'accept', 'reject', 'crash' ] }
+
+##
+# @CompatPolicyOutput:
+#
+# Policy for handling "funny" output.
+#
+# @accept: Pass on unchanged
+# @hide: Filter out
+#
+# Since: 5.0
+##
+{ 'enum': 'CompatPolicyOutput',
+  'data': [ 'accept', 'hide' ] }
+
+##
+# @CompatPolicy:
+#
+# Policy for handling deprecated management interfaces.
+#
+# This is intended for testing users of the management interfaces.
+#
+# Limitation: covers only syntactic aspects of QMP, i.e. stuff tagged
+# with feature 'deprecated'.  We may want to extend it to cover
+# semantic aspects, CLI, and experimental features.
+#
+# @deprecated-input: how to handle deprecated input (default 'accept')
+# @deprecated-output: how to handle deprecated output (default 'accept')
+#
+# Since: 5.0
+##
+{ 'struct': 'CompatPolicy',
+  'data': { '*deprecated-input': 'CompatPolicyInput',
+            '*deprecated-output': 'CompatPolicyOutput' } }
diff --git a/qapi/control.json b/qapi/control.json
index 759c20e76f..cdb058eca0 100644
--- a/qapi/control.json
+++ b/qapi/control.json
@@ -174,13 +174,15 @@
 #
 # Return information on QMP events.
 #
+# Features:
+# @deprecated: This command is deprecated, because its output doesn't
+#     reflect compile-time configuration.  Use 'query-qmp-schema'
+#     instead.
+#
 # 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" }
@@ -198,7 +200,8 @@
 # Note: This example has been shortened as the real response is too long.
 #
 ##
-{ 'command': 'query-events', 'returns': ['EventInfo'] }
+{ 'command': 'query-events', 'returns': ['EventInfo'],
+  'features': [ 'deprecated' ] }
 
 ##
 # @quit:
diff --git a/qapi/introspect.json b/qapi/introspect.json
index 8756e7920e..b1aabd4cfd 100644
--- a/qapi/introspect.json
+++ b/qapi/introspect.json
@@ -89,12 +89,18 @@
 #
 # @meta-type: the entity's meta type, inherited from @base.
 #
+# @features: names of features associated with the entity, in no
+#            particular order.
+#            (since 4.1 for object types, 4.2 for commands, 5.0 for
+#            the rest)
+#
 # Additional members depend on the value of @meta-type.
 #
 # Since: 2.5
 ##
 { 'union': 'SchemaInfo',
-  'base': { 'name': 'str', 'meta-type': 'SchemaMetaType' },
+  'base': { 'name': 'str', 'meta-type': 'SchemaMetaType',
+            '*features': [ 'str' ] },
   'discriminator': 'meta-type',
   'data': {
       'builtin': 'SchemaInfoBuiltin',
@@ -174,9 +180,6 @@
 #            and may even differ from the order of the values of the
 #            enum type of the @tag.
 #
-# @features: names of features associated with the type, in no particular
-#            order. (since: 4.1)
-#
 # Values of this type are JSON object on the wire.
 #
 # Since: 2.5
@@ -184,8 +187,7 @@
 { 'struct': 'SchemaInfoObject',
   'data': { 'members': [ 'SchemaInfoObjectMember' ],
             '*tag': 'str',
-            '*variants': [ 'SchemaInfoObjectVariant' ],
-            '*features': [ 'str' ] } }
+            '*variants': [ 'SchemaInfoObjectVariant' ] } }
 
 ##
 # @SchemaInfoObjectMember:
@@ -204,11 +206,15 @@
 #           Future extension: if present and non-null, the parameter
 #           is optional, and defaults to this value.
 #
+# @features: names of features associated with the member, in no
+#            particular order.  (since 5.0)
+#
 # Since: 2.5
 ##
 { 'struct': 'SchemaInfoObjectMember',
-  'data': { 'name': 'str', 'type': 'str', '*default': 'any' } }
+  'data': { 'name': 'str', 'type': 'str', '*default': 'any',
 # @default's type must be null or match @type
+            '*features': [ 'str' ] } }
 
 ##
 # @SchemaInfoObjectVariant:
@@ -266,17 +272,13 @@
 # @allow-oob: whether the command allows out-of-band execution,
 #             defaults to false (Since: 2.12)
 #
-# @features: names of features associated with the command, in no particular
-#            order. (since 4.2)
-#
 # TODO: @success-response (currently irrelevant, because it's QGA, not QMP)
 #
 # Since: 2.5
 ##
 { 'struct': 'SchemaInfoCommand',
   'data': { 'arg-type': 'str', 'ret-type': 'str',
-            '*allow-oob': 'bool',
-            '*features': [ 'str' ] } }
+            '*allow-oob': 'bool' } }
 
 ##
 # @SchemaInfoEvent:
diff --git a/qapi/machine.json b/qapi/machine.json
index 6c11e3cf3a..0da3f3adc4 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -184,8 +184,11 @@
 # This command causes vCPU threads to exit to userspace, which causes
 # a small interruption to guest CPU execution. This will have a negative
 # impact on realtime guests and other latency sensitive guest workloads.
-# It is recommended to use @query-cpus-fast instead of this command to
-# avoid the vCPU interruption.
+#
+# Features:
+# @deprecated: This command is deprecated, because it interferes with
+#     the guest.  Use 'query-cpus-fast' instead to avoid the vCPU
+#     interruption.
 #
 # Returns: a list of @CpuInfo for each virtual CPU
 #
@@ -216,12 +219,9 @@
 #       ]
 #    }
 #
-# Notes: This interface is deprecated (since 2.12.0), and it is strongly
-#        recommended that you avoid using it. Use @query-cpus-fast to
-#        obtain information about virtual CPUs.
-#
 ##
-{ 'command': 'query-cpus', 'returns': ['CpuInfo'] }
+{ 'command': 'query-cpus', 'returns': ['CpuInfo'],
+  'features': [ 'deprecated' ] }
 
 ##
 # @CpuInfoFast:
@@ -237,12 +237,14 @@
 # @props: properties describing to which node/socket/core/thread
 #         virtual CPU belongs to, provided if supported by board
 #
-# @arch: base architecture of the cpu; deprecated since 3.0.0 in favor
-#        of @target
+# @arch: base architecture of the cpu
 #
 # @target: the QEMU system emulation target, which determines which
 #          additional fields will be listed (since 3.0)
 #
+# Features:
+# @deprecated: Member @arch is deprecated.  Use @target instead.
+#
 # Since: 2.12
 #
 ##
@@ -251,7 +253,8 @@
                       'qom-path'     : 'str',
                       'thread-id'    : 'int',
                       '*props'       : 'CpuInstanceProperties',
-                      'arch'         : 'CpuInfoArch',
+                      'arch'         : { 'type': 'CpuInfoArch',
+                                         'features': [ 'deprecated' ] },
                       'target'       : 'SysEmuTarget' },
   'discriminator' : 'target',
   'data'          : { 's390x'        : 'CpuInfoS390' } }
@@ -307,21 +310,22 @@
 #
 # @id: ID of CPU to be created, valid values [0..max_cpus)
 #
+# Features:
+# @deprecated: This command is deprecated.  Use `device_add` instead.
+#     See the `query-hotpluggable-cpus` command for details.
+#
 # Returns: Nothing on success
 #
 # Since: 1.5
 #
-# Note: This command is deprecated.  The `device_add` command should be
-#       used instead.  See the `query-hotpluggable-cpus` command for
-#       details.
-#
 # Example:
 #
 # -> { "execute": "cpu-add", "arguments": { "id": 2 } }
 # <- { "return": {} }
 #
 ##
-{ 'command': 'cpu-add', 'data': {'id': 'int'} }
+{ 'command': 'cpu-add', 'data': {'id': 'int'},
+  'features': [ 'deprecated' ] }
 
 ##
 # @MachineInfo:
diff --git a/qapi/migration.json b/qapi/migration.json
index d44d99cd78..b8b5eb195f 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1196,9 +1196,11 @@
 #
 # @value: maximum downtime in seconds
 #
-# Returns: nothing on success
+# Features:
+# @deprecated: This command is deprecated.  Use
+#     'migrate-set-parameters' instead.
 #
-# Notes: This command is deprecated in favor of 'migrate-set-parameters'
+# Returns: nothing on success
 #
 # Since: 0.14.0
 #
@@ -1208,7 +1210,8 @@
 # <- { "return": {} }
 #
 ##
-{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
+{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'},
+  'features': [ 'deprecated' ] }
 
 ##
 # @migrate_set_speed:
@@ -1217,9 +1220,11 @@
 #
 # @value: maximum speed in bytes per second.
 #
-# Returns: nothing on success
+# Features:
+# @deprecated: This command is deprecated.  Use
+#     'migrate-set-parameters' instead.
 #
-# Notes: This command is deprecated in favor of 'migrate-set-parameters'
+# Returns: nothing on success
 #
 # Since: 0.14.0
 #
@@ -1229,7 +1234,8 @@
 # <- { "return": {} }
 #
 ##
-{ 'command': 'migrate_set_speed', 'data': {'value': 'int'} }
+{ 'command': 'migrate_set_speed', 'data': {'value': 'int'},
+  'features': [ 'deprecated' ] }
 
 ##
 # @migrate-set-cache-size:
@@ -1238,13 +1244,15 @@
 #
 # @value: cache size in bytes
 #
+# Features:
+# @deprecated: This command is deprecated.  Use
+#     'migrate-set-parameters' instead.
+#
 # The size will be rounded down to the nearest power of 2.
 # The cache size can be modified before and during ongoing migration
 #
 # Returns: nothing on success
 #
-# Notes: This command is deprecated in favor of 'migrate-set-parameters'
-#
 # Since: 1.2
 #
 # Example:
@@ -1254,17 +1262,20 @@
 # <- { "return": {} }
 #
 ##
-{ 'command': 'migrate-set-cache-size', 'data': {'value': 'int'} }
+{ 'command': 'migrate-set-cache-size', 'data': {'value': 'int'},
+  'features': [ 'deprecated' ] }
 
 ##
 # @query-migrate-cache-size:
 #
 # Query migration XBZRLE cache size
 #
+# Features:
+# @deprecated: This command is deprecated.  Use
+#     'query-migrate-parameters' instead.
+#
 # Returns: XBZRLE cache size in bytes
 #
-# Notes: This command is deprecated in favor of 'query-migrate-parameters'
-#
 # Since: 1.2
 #
 # Example:
@@ -1273,7 +1284,8 @@
 # <- { "return": 67108864 }
 #
 ##
-{ 'command': 'query-migrate-cache-size', 'returns': 'int' }
+{ 'command': 'query-migrate-cache-size', 'returns': 'int',
+  'features': [ 'deprecated' ] }
 
 ##
 # @migrate:
diff --git a/qapi/misc.json b/qapi/misc.json
index c18fe681fb..99b90ac80b 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -872,14 +872,14 @@
 #       If @device is 'vnc' and @target is 'password', this is the new VNC
 #       password to set.  See change-vnc-password for additional notes.
 #
+# Features:
+# @deprecated: This command is deprecated.  For changing block
+#     devices, use 'blockdev-change-medium' instead; for changing VNC
+#     parameters, use 'change-vnc-password' instead.
+#
 # Returns: - Nothing on success.
 #          - If @device is not a valid block device, DeviceNotFound
 #
-# Notes: This interface is deprecated, and it is strongly recommended that you
-#        avoid using it.  For changing block devices, use
-#        blockdev-change-medium; for changing VNC parameters, use
-#        change-vnc-password.
-#
 # Since: 0.14.0
 #
 # Example:
@@ -900,7 +900,8 @@
 #
 ##
 { 'command': 'change',
-  'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
+  'data': {'device': 'str', 'target': 'str', '*arg': 'str'},
+  'features': [ 'deprecated' ] }
 
 ##
 # @xen-set-global-dirty-log:
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index fe980ce437..fa800042e0 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -98,6 +98,7 @@
 { 'include': 'migration.json' }
 { 'include': 'transaction.json' }
 { 'include': 'trace.json' }
+{ 'include': 'compat.json' }
 { 'include': 'control.json' }
 { 'include': 'introspect.json' }
 { 'include': 'qom.json' }
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index d992e713d9..ddd89d1233 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -53,10 +53,14 @@
 # @Enum:
 # @one: The _one_ {and only}
 #
+# Features:
+# @enum-feat: Also _one_ {and only}
+#
 # @two is undocumented
 ##
 { 'enum': 'Enum', 'data':
   [ { 'name': 'one', 'if': 'defined(IFONE)' }, 'two' ],
+  'features': [ 'enum-feat' ],
   'if': 'defined(IFCOND)' }
 
 ##
@@ -74,10 +78,13 @@
 #
 # Features:
 # @variant1-feat: a feature
+# @member-feat: a member feature
 ##
 { 'struct': 'Variant1',
   'features': [ 'variant1-feat' ],
-  'data': { 'var1': { 'type': 'str', 'if': 'defined(IFSTR)' } } }
+  'data': { 'var1': { 'type': 'str',
+                      'features': [ 'member-feat' ],
+                      'if': 'defined(IFSTR)' } } }
 
 ##
 # @Variant2:
@@ -86,24 +93,34 @@
 
 ##
 # @Object:
+# Features:
+# @union-feat1: a feature
 ##
 { 'union': 'Object',
+  'features': [ 'union-feat1' ],
   'base': 'Base',
   'discriminator': 'base1',
   'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' } } }
 
 ##
 # @SugaredUnion:
+# Features:
+# @union-feat2: a feature
 ##
 { 'union': 'SugaredUnion',
+  'features': [ 'union-feat2' ],
   'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' } } }
 
 ##
 # @Alternate:
 # @i: an integer
 # @b is undocumented
+#
+# Features:
+# @alt-feat: a feature
 ##
 { 'alternate': 'Alternate',
+  'features': [ 'alt-feat' ],
   'data': { 'i': 'int', 'b': 'bool' } }
 
 ##
@@ -160,6 +177,9 @@
 
 ##
 # @EVT-BOXED:
+# Features:
+# @feat3: a feature
 ##
 { 'event': 'EVT-BOXED',  'boxed': true,
+  'features': [ 'feat3' ],
   'data': 'Object' }
diff --git a/tests/qapi-schema/features-deprecated-type.json b/tests/qapi-schema/features-deprecated-type.json
new file mode 100644
index 0000000000..4b5bf5b86e
--- /dev/null
+++ b/tests/qapi-schema/features-deprecated-type.json
@@ -0,0 +1,3 @@
+# Feature 'deprecated' is not supported for types
+{ 'struct': 'S', 'data': {},
+  'features': [ 'deprecated' ] }
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 9abf175fe0..e4cce0d5b0 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -252,13 +252,13 @@
     'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } },
   'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' }
 
-# test 'features' for structs
+# test 'features'
 
 { 'struct': 'FeatureStruct0',
   'data': { 'foo': 'int' },
   'features': [] }
 { 'struct': 'FeatureStruct1',
-  'data': { 'foo': 'int' },
+  'data': { 'foo': { 'type': 'int', 'features': [ 'deprecated' ] } },
   'features': [ 'feature1' ] }
 { 'struct': 'FeatureStruct2',
   'data': { 'foo': 'int' },
@@ -281,22 +281,35 @@
   'data': { 'foo': 'int' },
   'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)',
                                               'defined(TEST_IF_COND_2)'] } ] }
-{ 'command': 'test-features',
-  'data': { 'fs0': 'FeatureStruct0',
-            'fs1': 'FeatureStruct1',
-            'fs2': 'FeatureStruct2',
-            'fs3': 'FeatureStruct3',
-            'fs4': 'FeatureStruct4',
-            'cfs1': 'CondFeatureStruct1',
-            'cfs2': 'CondFeatureStruct2',
-            'cfs3': 'CondFeatureStruct3' } }
-
-# test 'features' for command
-
-{ 'command': 'test-command-features0',
+
+{ 'enum': 'FeatureEnum1',
+  'data': [ 'eins', 'zwei', 'drei' ],
+  'features': [ 'feature1' ] }
+
+{ 'union': 'FeatureUnion1',
+  'base': { 'tag': 'FeatureEnum1' },
+  'discriminator': 'tag',
+  'data': { 'eins': 'FeatureStruct1' },
+  'features': [ 'feature1' ] }
+
+{ 'alternate': 'FeatureAlternate1',
+  'data': { 'eins': 'FeatureStruct1' },
+  'features': [ 'feature1' ] }
+
+{ 'command': 'test-features0',
+  'data': { '*fs0': 'FeatureStruct0',
+            '*fs1': 'FeatureStruct1',
+            '*fs2': 'FeatureStruct2',
+            '*fs3': 'FeatureStruct3',
+            '*fs4': 'FeatureStruct4',
+            '*cfs1': 'CondFeatureStruct1',
+            '*cfs2': 'CondFeatureStruct2',
+            '*cfs3': 'CondFeatureStruct3' },
+  'returns': 'FeatureStruct1',
   'features': [] }
+
 { 'command': 'test-command-features1',
-  'features': [ 'feature1' ] }
+  'features': [ 'deprecated' ] }
 { 'command': 'test-command-features3',
   'features': [ 'feature1', 'feature2' ] }
 
@@ -308,3 +321,6 @@
 { 'command': 'test-command-cond-features3',
   'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)',
                                               'defined(TEST_IF_COND_2)'] } ] }
+
+{ 'event': 'TEST-EVENT-FEATURES1',
+  'features': [ 'deprecated' ] }

Re: [PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Peter Maydell 4 years, 1 month ago
On Wed, 4 Mar 2020 at 08:18, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
> > How much do you think this is likely to affect the
> > generate-rst-from-qapi-docs series? I'd really like
> > that to go in for this release, but this looks like
> > it's shaping up to be a big conflict :-(
>
> I paused reviewing your series to post this one, because "I'd really
> like that to go in for this release" :)
>
> My series touches 21 existing commented definitions in qapi/, six more
> in tests/qapi-schema/doc-good.json, and adds new module
> qapi/compat.json.  Consolidated diff appended.
>
> Rule of thumb for reducing conflict resolution labor: the bigger manual
> change goes first.  Yours is bigger, but I don't remember how manual it
> is.

We got pretty much all the manual changes I needed into
master already, so all that's left really is the script parts.
The conflicts would basically be where this series affects
the generate-docs parts of the scripts -- any changes here
to doc.py are basically dead-code-walking and would need
to be done over again in the equivalent code for rust generation.
But looking at the diffstat
 scripts/qapi/doc.py                           |  16 +-
so hopefully it won't be too bad.

thanks
-- PMM


Re: [PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Markus Armbruster 4 years, 1 month ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On Wed, 4 Mar 2020 at 08:18, Markus Armbruster <armbru@redhat.com> wrote:
>> Peter Maydell <peter.maydell@linaro.org> writes:
>> > How much do you think this is likely to affect the
>> > generate-rst-from-qapi-docs series? I'd really like
>> > that to go in for this release, but this looks like
>> > it's shaping up to be a big conflict :-(
>>
>> I paused reviewing your series to post this one, because "I'd really
>> like that to go in for this release" :)
>>
>> My series touches 21 existing commented definitions in qapi/, six more
>> in tests/qapi-schema/doc-good.json, and adds new module
>> qapi/compat.json.  Consolidated diff appended.
>>
>> Rule of thumb for reducing conflict resolution labor: the bigger manual
>> change goes first.  Yours is bigger, but I don't remember how manual it
>> is.
>
> We got pretty much all the manual changes I needed into
> master already, so all that's left really is the script parts.
> The conflicts would basically be where this series affects
> the generate-docs parts of the scripts -- any changes here
> to doc.py are basically dead-code-walking and would need
> to be done over again in the equivalent code for rust generation.
> But looking at the diffstat
>  scripts/qapi/doc.py                           |  16 +-
> so hopefully it won't be too bad.

Not bad at all: two patches, both trivial for this file:

$ git-log --patch master..posted/qapi-features scripts/qapi/doc.py
commit 63daae3c1da9a7d8a189a9dfc80804c812b3f6af
Author: Markus Armbruster <armbru@redhat.com>
Date:   Fri Oct 18 11:23:40 2019 +0200

    qapi: Consistently put @features parameter right after @ifcond
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>

diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 36e823338b..92f584edcf 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -249,8 +249,8 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor):
                                 texi_members(doc, 'Values',
                                              member_func=texi_enum_value)))
 
-    def visit_object_type(self, name, info, ifcond, base, members, variants,
-                          features):
+    def visit_object_type(self, name, info, ifcond, features,
+                          base, members, variants):
         doc = self.cur_doc
         if base and base.is_implicit():
             base = None
@@ -262,9 +262,9 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor):
         self._gen.add(texi_type('Alternate', doc, ifcond,
                                 texi_members(doc, 'Members')))
 
-    def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
-                      success_response, boxed, allow_oob, allow_preconfig,
-                      features):
+    def visit_command(self, name, info, ifcond, features,
+                      arg_type, ret_type, gen, success_response, boxed,
+                      allow_oob, allow_preconfig):
         doc = self.cur_doc
         self._gen.add(texi_msg('Command', doc, ifcond,
                                texi_arguments(doc,

commit 9e101e2b1803f326df46e42d88bae9f281da9fe4
Author: Markus Armbruster <armbru@redhat.com>
Date:   Tue Oct 15 14:33:24 2019 +0200

    qapi: Add feature flags to remaining definitions
    
    In v4.1.0, we added feature flags just to struct types (commit
    6a8c0b5102^..f3ed93d545), to satisfy an immediate need (commit
    c9d4070991 "file-posix: Add dynamic-auto-read-only QAPI feature").  In
    v4.2.0, we added them to commands (commit 23394b4c39 "qapi: Add
    feature flags to commands") to satisfy another immediate need (commit
    d76744e65e "qapi: Allow introspecting fix for savevm's cooperation
    with blockdev").
    
    Add them to the remaining definitions: enumeration types, union types,
    alternate types, and events.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>

diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 1787a53d91..36e823338b 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -243,7 +243,7 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor):
     def write(self, output_dir):
         self._gen.write(output_dir)
 
-    def visit_enum_type(self, name, info, ifcond, members, prefix):
+    def visit_enum_type(self, name, info, ifcond, features, members, prefix):
         doc = self.cur_doc
         self._gen.add(texi_type('Enum', doc, ifcond,
                                 texi_members(doc, 'Values',
@@ -257,7 +257,7 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor):
         self._gen.add(texi_type('Object', doc, ifcond,
                                 texi_members(doc, 'Members', base, variants)))
 
-    def visit_alternate_type(self, name, info, ifcond, variants):
+    def visit_alternate_type(self, name, info, ifcond, features, variants):
         doc = self.cur_doc
         self._gen.add(texi_type('Alternate', doc, ifcond,
                                 texi_members(doc, 'Members')))
@@ -270,7 +270,7 @@ class QAPISchemaGenDocVisitor(QAPISchemaVisitor):
                                texi_arguments(doc,
                                               arg_type if boxed else None)))
 
-    def visit_event(self, name, info, ifcond, arg_type, boxed):
+    def visit_event(self, name, info, ifcond, features, arg_type, boxed):
         doc = self.cur_doc
         self._gen.add(texi_msg('Event', doc, ifcond,
                                texi_arguments(doc,

Re: [PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Markus Armbruster 4 years, 1 month ago
Markus Armbruster <armbru@redhat.com> writes:

> Based-on: <20200227144531.24309-1-armbru@redhat.com>
>
> This series extends QMP introspection to cover deprecation.
> Additionally, new option -compat lets you configure what to do when
> deprecated interfaces get used.  This is intended for testing users of
> the management interfaces.  It is experimental.
>
> -compat deprecated-input=<in-policy> configures what to do when
> deprecated input is received.  Available policies:
>
> * accept: Accept deprecated commands and arguments (default)
> * reject: Reject them
> * crash: Crash
>
> -compat deprecated-output=<out-policy> configures what to do when
> deprecated output is sent.  Available output policies:
>
> * accept: Emit deprecated command results and events (default)
> * hide: Suppress them

Missing: hide in output of query-qmp-schema.  I can look into that.

> For now, -compat covers only deprecated syntactic aspects of QMP.  We
> may want to extend it to cover semantic aspects, CLI, and experimental
> features.
>
> PATCH 01-04: Documentation fixes
> PATCH 05-10: Test improvements
> PATCH 11-24: Add feature flags to remaining user-defined types and to
>       	     struct members
> PATCH 25-26: New special feature 'deprecated', visible in
>       	     introspection
> PATCH 27-30: New -compat to set policy for handling stuff marked with
>       	     feature 'deprecated'
>
> Comparison to RFC (24 Oct 2019):
> * Cover arguments and results in addition to commands and events
> * Half-baked "[RFC PATCH 18/19] qapi: Include a warning in the
>   response to a deprecated command" dropped
>
> See also last item of
>     Subject: Minutes of KVM Forum BoF on deprecating stuff
>     Date: Fri, 26 Oct 2018 16:03:51 +0200
>     Message-ID: <87mur0ls8o.fsf@dusky.pond.sub.org>
>     https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg05828.html

Re: [PATCH v2 00/30] Configurable policy for handling deprecated interfaces
Posted by Peter Krempa 4 years, 1 month ago
On Tue, Mar 03, 2020 at 17:34:35 +0100, Markus Armbruster wrote:
> Based-on: <20200227144531.24309-1-armbru@redhat.com>
> 
> This series extends QMP introspection to cover deprecation.
> Additionally, new option -compat lets you configure what to do when
> deprecated interfaces get used.  This is intended for testing users of
> the management interfaces.  It is experimental.

I've quickly hacked up support for the 'deprecated' feature in libvirt's
QMP validator. I've found a few uses of deprecated commands but they
might very well be in code paths that are no longer invoked in modern
qemus:

Offenders from qemumonitorjsontest:

44) qemuMonitorJSONSetCPU                                             ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'cpu-add': failed to validate arguments of 'cpu-add' against QAPI schema: ERROR: 'cpu-add' is deprecated
FAILED
46) qemuMonitorJSONChangeMedia                                        ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'change': failed to validate arguments of 'change' against QAPI schema: ERROR: 'change' is deprecated
FAILED
49) qemuMonitorJSONSetMigrationSpeed                                  ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'migrate_set_speed': failed to validate arguments of 'migrate_set_speed' against QAPI schema: ERROR: 'migrate_set_speed' is deprecated
FAILED
50) qemuMonitorJSONSetMigrationDowntime                               ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'migrate_set_downtime': failed to validate arguments of 'migrate_set_downtime' against QAPI schema: ERROR: 'migrate_set_downtime' is deprecated
FAILED
77) qemuMonitorJSONGetMigrationCacheSize                              ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-migrate-cache-size': failed to validate arguments of 'query-migrate-cache-size' against QAPI schema: ERROR: 'query-migrate-cache-size' is deprecated
FAILED
83) qemuMonitorJSONQueryCPUs                                          ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
93) GetCPUInfo(x86-basic-pluggable)                                   ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
94) GetCPUInfo(x86-full)                                              ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
95) GetCPUInfo(x86-node-full)                                         ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
97) GetCPUInfo(ppc64-basic)                                           ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
98) GetCPUInfo(ppc64-hotplug-1)                                       ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
99) GetCPUInfo(ppc64-hotplug-2)                                       ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
100) GetCPUInfo(ppc64-hotplug-4)                                       ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED
101) GetCPUInfo(ppc64-no-threads)                                      ... libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'query-cpus': failed to validate arguments of 'query-cpus' against QAPI schema: ERROR: 'query-cpus' is deprecated
FAILED

Here all commands are tested just for legacy reasons. query-cpus-fast is
used on any live codebase, cpu-add is no longer used, change is not used
with -blockdev. I'm not sure about the migration parameter APIs but I
didn't check either.

The above shows that we can't enable this without thinking even in our
test-suite.

I'll try to come up with a solution where we can enable the reporting of
use of deprecated commands through /etc/qemu.conf so that I as an
developer can always use it.

I'm currently busy but I plan to follow up later.

I've pushed the test change here:

https://gitlab.com/pipo.sk/libvirt/-/commits/qmp-deprecated

The unfortunate part is that we'll need to manually inspect the codebase
for any deprecation in returned values. Our parser is 'artisanaly
handcrafted' so it can't be introspected.