Markus Armbruster
2021-Mar-12 15:32 UTC
[Libguestfs] [PATCH v6 00/10] Configurable policy for handling deprecated interfaces
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. v6: * Rebased, with straightforward conflicts * PATCH 1: More verbose commit message, explaining intent, and the lack of introspection [Peter], comments updated for 6.0, Eric's R-by kept anyway * PATCH 5+6: Split old PATCH 5 [Eric], Eric's R-by lept anyway * PATCH 7: New, correcting a latent issue so it doesn't break PATCH 8 * PATCH 10: Doc fix [Eric] v5: * Old PATCH 01-26 merged in commit f57587c7d47. * Rebased, non-trivial conflicts in PATCH 1 due to Meson, and in PATCH 7 due to visitor changes * PATCH 1: Comments updated for 5.2 [Eric] * PATCH 2: Harmless missing initialization fixed [Eric] * PATCH 3+4: Harmless missing has_FOO = true fixed [Eric] * PATCH 6+7: Commit message tweaked v4: * PATCH 05+07: Temporary memory leak plugged [Marc-Andr?] * PATCH 23: Rewritten [Marc-Andr?] * PATCH 24: Comment typo [Marc-Andr?] * PATCH 30: Memory leaks plugged v3: * Rebased, non-trivial conflicts in PATCH 01+26+27+34 due to RST conversion and code motion * PATCH 28-29: Old PATCH 28 split up to ease review * PATCH 30-31: New * PATCH 32-33: Old PATCH 29 split up to ease review 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 at dusky.pond.sub.org> https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg05828.html Cc: Luk?? Doktor <ldoktor at redhat.com> Cc: libguestfs at redhat.com Cc: libvir-list at redhat.com Cc: Daniel P. Berrange <berrange at redhat.com> Cc: Peter Krempa <pkrempa at redhat.com> Cc: Kevin Wolf <kwolf at redhat.com> Markus Armbruster (10): qemu-options: New -compat to set policy for deprecated interfaces qapi: Implement deprecated-output=hide for QMP command results qapi: Implement deprecated-output=hide for QMP events qapi: Implement deprecated-output=hide for QMP event data monitor: Drop query-qmp-schema 'gen': false hack qapi: Implement deprecated-output=hide for QMP introspection test-util-sockets: Add stub for monitor_set_cur() qapi: Implement deprecated-input=reject for QMP commands qapi: Implement deprecated-input=reject for QMP command arguments qapi: New -compat deprecated-input=crash qapi/compat.json | 52 ++++++++++++ qapi/introspect.json | 2 +- 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 | 6 ++ include/qapi/visitor.h | 18 +++++ monitor/monitor-internal.h | 3 - monitor/misc.c | 2 - monitor/qmp-cmds-control.c | 100 +++++++++++++++++++++--- qapi/qapi-visit-core.c | 18 +++++ qapi/qmp-dispatch.c | 17 ++++ qapi/qobject-input-visitor.c | 29 +++++++ qapi/qobject-output-visitor.c | 19 +++++ softmmu/vl.c | 17 ++++ storage-daemon/qemu-storage-daemon.c | 2 - tests/test-qmp-cmds.c | 91 +++++++++++++++++++-- tests/test-qmp-event.c | 41 ++++++++++ tests/test-util-sockets.c | 1 + qapi/meson.build | 1 + qapi/trace-events | 2 + qemu-options.hx | 22 ++++++ scripts/qapi/commands.py | 14 ++-- scripts/qapi/events.py | 20 ++++- scripts/qapi/visit.py | 15 ++++ tests/qapi-schema/qapi-schema-test.json | 20 +++-- tests/qapi-schema/qapi-schema-test.out | 20 ++--- 29 files changed, 522 insertions(+), 50 deletions(-) create mode 100644 qapi/compat.json create mode 100644 include/qapi/compat-policy.h -- 2.26.2
Markus Armbruster
2021-Mar-18 15:08 UTC
[Libguestfs] [PATCH v6 00/10] Configurable policy for handling deprecated interfaces
This series needs fixups to not break --disable-system --disable-tools builds. It's not much (see appended diff), but enough to make me respin it as v7. I'll respin the pull request, too. diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h index b8c6638156..1083f95122 100644 --- a/include/qapi/compat-policy.h +++ b/include/qapi/compat-policy.h @@ -17,4 +17,22 @@ extern CompatPolicy compat_policy; +/* + * Create a QObject input visitor for @obj for use with QMP + * + * This is like qobject_input_visitor_new(), except it obeys the + * policy for handling deprecated management interfaces set with + * -compat. + */ +Visitor *qobject_input_visitor_new_qmp(QObject *obj); + +/* + * Create a QObject output visitor for @obj for use with QMP + * + * This is like qobject_output_visitor_new(), except it obeys the + * policy for handling deprecated management interfaces set with + * -compat. + */ +Visitor *qobject_output_visitor_new_qmp(QObject **result); + #endif diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-input-visitor.h index cbc54de4ac..8d69388810 100644 --- a/include/qapi/qobject-input-visitor.h +++ b/include/qapi/qobject-input-visitor.h @@ -15,6 +15,7 @@ #ifndef QOBJECT_INPUT_VISITOR_H #define QOBJECT_INPUT_VISITOR_H +#include "qapi/qapi-types-compat.h" #include "qapi/visitor.h" typedef struct QObjectInputVisitor QObjectInputVisitor; @@ -58,14 +59,8 @@ typedef struct QObjectInputVisitor QObjectInputVisitor; */ Visitor *qobject_input_visitor_new(QObject *obj); -/* - * Create a QObject input visitor for @obj for use with QMP - * - * This is like qobject_input_visitor_new(), except it obeys the - * policy for handling deprecated management interfaces set with - * -compat. - */ -Visitor *qobject_input_visitor_new_qmp(QObject *obj); +void qobject_input_visitor_set_policy(Visitor *v, + CompatPolicyInput deprecated); /* * Create a QObject input visitor for @obj for use with keyval_parse() diff --git a/include/qapi/qobject-output-visitor.h b/include/qapi/qobject-output-visitor.h index 29f4ea6aad..f2a2f92a00 100644 --- a/include/qapi/qobject-output-visitor.h +++ b/include/qapi/qobject-output-visitor.h @@ -15,6 +15,7 @@ #define QOBJECT_OUTPUT_VISITOR_H #include "qapi/visitor.h" +#include "qapi/qapi-types-compat.h" typedef struct QObjectOutputVisitor QObjectOutputVisitor; @@ -53,13 +54,7 @@ typedef struct QObjectOutputVisitor QObjectOutputVisitor; */ Visitor *qobject_output_visitor_new(QObject **result); -/* - * Create a QObject output visitor for @obj for use with QMP - * - * This is like qobject_output_visitor_new(), except it obeys the - * policy for handling deprecated management interfaces set with - * -compat. - */ -Visitor *qobject_output_visitor_new_qmp(QObject **result); +void qobject_output_visitor_set_policy(Visitor *v, + CompatPolicyOutput deprecated); #endif diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 12657d635e..0f7e2e48fa 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -19,6 +19,8 @@ #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-output-visitor.h" #include "sysemu/runstate.h" #include "qapi/qmp/qbool.h" #include "qemu/coroutine.h" @@ -26,6 +28,22 @@ CompatPolicy compat_policy; +Visitor *qobject_input_visitor_new_qmp(QObject *obj) +{ + Visitor *v = qobject_input_visitor_new(obj); + + qobject_input_visitor_set_policy(v, compat_policy.deprecated_input); + return v; +} + +Visitor *qobject_output_visitor_new_qmp(QObject **result) +{ + Visitor *v = qobject_output_visitor_new(result); + + qobject_output_visitor_set_policy(v, compat_policy.deprecated_output); + return v; +} + static QDict *qmp_dispatch_check_obj(QDict *dict, bool allow_oob, Error **errp) { diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index baad0dcd3c..04b790412e 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -739,12 +739,12 @@ Visitor *qobject_input_visitor_new(QObject *obj) return &v->visitor; } -Visitor *qobject_input_visitor_new_qmp(QObject *obj) +void qobject_input_visitor_set_policy(Visitor *v, + CompatPolicyInput deprecated) { - QObjectInputVisitor *v = to_qiv(qobject_input_visitor_new(obj)); + QObjectInputVisitor *qiv = to_qiv(v); - v->deprecated_policy = compat_policy.deprecated_input; - return &v->visitor; + qiv->deprecated_policy = deprecated; } Visitor *qobject_input_visitor_new_keyval(QObject *obj) diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 5c4aa0f64d..e4873308d4 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -276,10 +276,10 @@ Visitor *qobject_output_visitor_new(QObject **result) return &v->visitor; } -Visitor *qobject_output_visitor_new_qmp(QObject **result) +void qobject_output_visitor_set_policy(Visitor *v, + CompatPolicyOutput deprecated) { - QObjectOutputVisitor *v = to_qov(qobject_output_visitor_new(result)); + QObjectOutputVisitor *qov = to_qov(v); - v->deprecated_policy = compat_policy.deprecated_output; - return &v->visitor; + qov->deprecated_policy = deprecated; } diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 8ccd1d9224..0e13d51054 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -255,10 +255,9 @@ def _begin_user_module(self, name: str) -> None: visit = self._module_basename('qapi-visit', name) self._genc.add(mcgen(''' #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/visitor.h" #include "qapi/qmp/qdict.h" -#include "qapi/qobject-output-visitor.h" -#include "qapi/qobject-input-visitor.h" #include "qapi/dealloc-visitor.h" #include "qapi/error.h" #include "%(visit)s.h" diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 8335c2bdfc..fee8c671e7 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -192,7 +192,6 @@ def _begin_user_module(self, name: str) -> None: #include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qobject-output-visitor.h" #include "qapi/qmp-event.h" ''',