aboutsummaryrefslogtreecommitdiff
path: root/qapi
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-03-19 16:40:00 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-03-19 16:40:00 +0000
commit2e1293cbaac75e84f541f9acfa8e26749f4c3562 (patch)
tree0d59e90331072297512f782638e511a5dd25611d /qapi
parent8631a430e65ef73b3d8a297128be2ef3c7317b90 (diff)
parentdbb675c19aa6ca328f4449ccd1ff605f9cb744e9 (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-03-16-v4' into staging
QAPI patches patches for 2021-03-16 # gpg: Signature made Fri 19 Mar 2021 15:06:52 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-03-16-v4: qapi: New -compat deprecated-input=crash qapi: Implement deprecated-input=reject for QMP command arguments qapi: Implement deprecated-input=reject for QMP commands test-util-sockets: Add stub for monitor_set_cur() qapi: Implement deprecated-output=hide for QMP introspection monitor: Drop query-qmp-schema 'gen': false hack qapi: Implement deprecated-output=hide for QMP event data qapi: Implement deprecated-output=hide for QMP events qapi: Implement deprecated-output=hide for QMP command results qemu-options: New -compat to set policy for deprecated interfaces qemuutil: remove qemu_set_fd_handler duplicate symbol Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qapi')
-rw-r--r--qapi/compat.json52
-rw-r--r--qapi/introspect.json2
-rw-r--r--qapi/meson.build1
-rw-r--r--qapi/qapi-schema.json1
-rw-r--r--qapi/qapi-visit-core.c18
-rw-r--r--qapi/qmp-dispatch.c35
-rw-r--r--qapi/qobject-input-visitor.c29
-rw-r--r--qapi/qobject-output-visitor.c19
-rw-r--r--qapi/trace-events2
9 files changed, 158 insertions, 1 deletions
diff --git a/qapi/compat.json b/qapi/compat.json
new file mode 100644
index 0000000000..ae3afc22df
--- /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: 6.0
+##
+{ 'enum': 'CompatPolicyInput',
+ 'data': [ 'accept', 'reject', 'crash' ] }
+
+##
+# @CompatPolicyOutput:
+#
+# Policy for handling "funny" output.
+#
+# @accept: Pass on unchanged
+# @hide: Filter out
+#
+# Since: 6.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: 6.0
+##
+{ 'struct': 'CompatPolicy',
+ 'data': { '*deprecated-input': 'CompatPolicyInput',
+ '*deprecated-output': 'CompatPolicyOutput' } }
diff --git a/qapi/introspect.json b/qapi/introspect.json
index 944bb87a20..39bd303778 100644
--- a/qapi/introspect.json
+++ b/qapi/introspect.json
@@ -49,7 +49,7 @@
##
{ 'command': 'query-qmp-schema',
'returns': [ 'SchemaInfo' ],
- 'gen': false } # just to simplify qmp_query_json()
+ 'allow-preconfig': true }
##
# @SchemaMetaType:
diff --git a/qapi/meson.build b/qapi/meson.build
index d4424ae6e7..0d20226fa3 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -25,6 +25,7 @@ qapi_all_modules = [
'block-export',
'char',
'common',
+ 'compat',
'control',
'crypto',
'dump',
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index 3441c9a9ae..4912b9744e 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -79,6 +79,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/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 7e5f40e7f0..a641adec51 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -135,6 +135,24 @@ bool visit_optional(Visitor *v, const char *name, bool *present)
return *present;
}
+bool visit_deprecated_accept(Visitor *v, const char *name, Error **errp)
+{
+ trace_visit_deprecated_accept(v, name);
+ if (v->deprecated_accept) {
+ return v->deprecated_accept(v, name, errp);
+ }
+ return true;
+}
+
+bool visit_deprecated(Visitor *v, const char *name)
+{
+ trace_visit_deprecated(v, name);
+ if (v->deprecated) {
+ return v->deprecated(v, name);
+ }
+ return true;
+}
+
bool visit_is_input(Visitor *v)
{
return v->type == VISITOR_INPUT;
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 5e597c76f7..59600210ce 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -14,15 +14,36 @@
#include "qemu/osdep.h"
#include "block/aio.h"
+#include "qapi/compat-policy.h"
#include "qapi/error.h"
#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"
#include "qemu/main-loop.h"
+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)
{
@@ -155,6 +176,20 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
"The command %s has not been found", command);
goto out;
}
+ if (cmd->options & QCO_DEPRECATED) {
+ switch (compat_policy.deprecated_input) {
+ case COMPAT_POLICY_INPUT_ACCEPT:
+ break;
+ case COMPAT_POLICY_INPUT_REJECT:
+ error_set(&err, ERROR_CLASS_COMMAND_NOT_FOUND,
+ "Deprecated command %s disabled by policy",
+ command);
+ goto out;
+ case COMPAT_POLICY_INPUT_CRASH:
+ default:
+ abort();
+ }
+ }
if (!cmd->enabled) {
error_set(&err, ERROR_CLASS_COMMAND_NOT_FOUND,
"Command %s has been disabled%s%s",
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 23843b242e..04b790412e 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include <math.h>
+#include "qapi/compat-policy.h"
#include "qapi/error.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/visitor-impl.h"
@@ -43,6 +44,7 @@ typedef struct StackObject {
struct QObjectInputVisitor {
Visitor visitor;
+ CompatPolicyInput deprecated_policy;
/* Root of visit at visitor creation. */
QObject *root;
@@ -662,6 +664,24 @@ static void qobject_input_optional(Visitor *v, const char *name, bool *present)
*present = true;
}
+static bool qobject_input_deprecated_accept(Visitor *v, const char *name,
+ Error **errp)
+{
+ QObjectInputVisitor *qiv = to_qiv(v);
+
+ switch (qiv->deprecated_policy) {
+ case COMPAT_POLICY_INPUT_ACCEPT:
+ return true;
+ case COMPAT_POLICY_INPUT_REJECT:
+ error_setg(errp, "Deprecated parameter '%s' disabled by policy",
+ name);
+ return false;
+ case COMPAT_POLICY_INPUT_CRASH:
+ default:
+ abort();
+ }
+}
+
static void qobject_input_free(Visitor *v)
{
QObjectInputVisitor *qiv = to_qiv(v);
@@ -696,6 +716,7 @@ static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj)
v->visitor.end_list = qobject_input_end_list;
v->visitor.start_alternate = qobject_input_start_alternate;
v->visitor.optional = qobject_input_optional;
+ v->visitor.deprecated_accept = qobject_input_deprecated_accept;
v->visitor.free = qobject_input_free;
v->root = qobject_ref(obj);
@@ -718,6 +739,14 @@ Visitor *qobject_input_visitor_new(QObject *obj)
return &v->visitor;
}
+void qobject_input_visitor_set_policy(Visitor *v,
+ CompatPolicyInput deprecated)
+{
+ QObjectInputVisitor *qiv = to_qiv(v);
+
+ qiv->deprecated_policy = deprecated;
+}
+
Visitor *qobject_input_visitor_new_keyval(QObject *obj)
{
QObjectInputVisitor *v = qobject_input_visitor_base_new(obj);
diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c
index ba6f6ac8a7..e4873308d4 100644
--- a/qapi/qobject-output-visitor.c
+++ b/qapi/qobject-output-visitor.c
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/compat-policy.h"
#include "qapi/qobject-output-visitor.h"
#include "qapi/visitor-impl.h"
#include "qemu/queue.h"
@@ -31,6 +32,8 @@ typedef struct QStackEntry {
struct QObjectOutputVisitor {
Visitor visitor;
+ CompatPolicyOutput deprecated_policy;
+
QSLIST_HEAD(, QStackEntry) stack; /* Stack of unfinished containers */
QObject *root; /* Root of the output visit */
QObject **result; /* User's storage location for result */
@@ -207,6 +210,13 @@ static bool qobject_output_type_null(Visitor *v, const char *name,
return true;
}
+static bool qobject_output_deprecated(Visitor *v, const char *name)
+{
+ QObjectOutputVisitor *qov = to_qov(v);
+
+ return qov->deprecated_policy != COMPAT_POLICY_OUTPUT_HIDE;
+}
+
/* Finish building, and return the root object.
* The root object is never null. The caller becomes the object's
* owner, and should use qobject_unref() when done with it. */
@@ -256,6 +266,7 @@ Visitor *qobject_output_visitor_new(QObject **result)
v->visitor.type_number = qobject_output_type_number;
v->visitor.type_any = qobject_output_type_any;
v->visitor.type_null = qobject_output_type_null;
+ v->visitor.deprecated = qobject_output_deprecated;
v->visitor.complete = qobject_output_complete;
v->visitor.free = qobject_output_free;
@@ -264,3 +275,11 @@ Visitor *qobject_output_visitor_new(QObject **result)
return &v->visitor;
}
+
+void qobject_output_visitor_set_policy(Visitor *v,
+ CompatPolicyOutput deprecated)
+{
+ QObjectOutputVisitor *qov = to_qov(v);
+
+ qov->deprecated_policy = deprecated;
+}
diff --git a/qapi/trace-events b/qapi/trace-events
index 5eb4afa110..3cabe912ae 100644
--- a/qapi/trace-events
+++ b/qapi/trace-events
@@ -17,6 +17,8 @@ visit_start_alternate(void *v, const char *name, void *obj, size_t size) "v=%p n
visit_end_alternate(void *v, void *obj) "v=%p obj=%p"
visit_optional(void *v, const char *name, bool *present) "v=%p name=%s present=%p"
+visit_deprecated_accept(void *v, const char *name) "v=%p name=%s"
+visit_deprecated(void *v, const char *name) "v=%p name=%s"
visit_type_enum(void *v, const char *name, int *obj) "v=%p name=%s obj=%p"
visit_type_int(void *v, const char *name, int64_t *obj) "v=%p name=%s obj=%p"