[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 14/19] qemu-options: New -compat to set policy for "funny" in
From: |
Markus Armbruster |
Subject: |
[RFC PATCH 14/19] qemu-options: New -compat to set policy for "funny" interfaces |
Date: |
Thu, 24 Oct 2019 14:34:53 +0200 |
"Funny" interface policy is separate for input and output.
Input policy can be "accept" (accept silently; default), "reject"
(reject the request with an error), or "crash" (abort() the process).
Output policy can be "accept" (pass on unchanged), or "hide" (filter
out the deprecated parts).
Policies other than "accept" are implemented later in this series.
For now, the "funny" interfaces are just QMP commands and events with
feature "deprecated". We'll want to extend this to arguments,
returns, and the command line. Extending it to experimental
interfaces may make sense.
FIXME Documentation and help need some work
Signed-off-by: Markus Armbruster <address@hidden>
---
qapi/common.json | 48 ++++++++++++++++++++++++++++++++++++
include/qapi/compat-policy.h | 20 +++++++++++++++
qapi/qmp-dispatch.c | 3 +++
vl.c | 17 +++++++++++++
qemu-options.hx | 18 ++++++++++++++
5 files changed, 106 insertions(+)
create mode 100644 include/qapi/compat-policy.h
diff --git a/qapi/common.json b/qapi/common.json
index 7b9cbcd97b..9fc3e6400c 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -144,3 +144,51 @@
##
{ 'enum': 'PCIELinkWidth',
'data': [ '1', '2', '4', '8', '12', '16', '32' ] }
+
+##
+# @CompatPolicyInput:
+#
+# Policy for handling "funny" input.
+#
+# @accept: Accept silently
+# TODO @reject: Reject with an error
+# TODO @crash: abort() the process
+#
+# FIXME Guidance on intended use.
+#
+# Since: 4.2
+##
+{ 'enum': 'CompatPolicyInput',
+ 'data': [ 'accept' ] }
+
+##
+# @CompatPolicyOutput:
+#
+# Policy for handling "funny" output.
+#
+# @accept: Pass on unchanged
+# TODO @hide: Filter out
+#
+# FIXME Guidance on intended use.
+#
+# Since: 4.2
+##
+{ 'enum': 'CompatPolicyOutput',
+ 'data': [ 'accept' ] }
+
+##
+# @CompatPolicy:
+#
+# Policy for handling "funny" management interfaces.
+#
+# Limitation: covers only QMP commands and events. Argument support
+# is not yet implemented. CLI is not yet implemented.
+#
+# @deprecated-input: how to handle deprecated input (default 'accept')
+# @deprecated-output: how to handle deprecated output (default 'accept')
+##
+{ 'struct': 'CompatPolicy',
+ 'data': { '*deprecated-input': 'CompatPolicyInput',
+ '*deprecated-output': 'CompatPolicyOutput' } }
+
+# FIXME CompatPolicy & friends don't belong here
diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h
new file mode 100644
index 0000000000..c491d74aac
--- /dev/null
+++ b/include/qapi/compat-policy.h
@@ -0,0 +1,20 @@
+/*
+ * Policy for handling "funny" management interfaces
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * Authors:
+ * Markus Armbruster <address@hidden>,
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
+ */
+
+#ifndef QAPI_COMPAT_POLICY_H
+#define QAPI_COMPAT_POLICY_H
+
+#include "qapi/qapi-types-common.h"
+
+extern CompatPolicy qapi_compat_policy;
+
+#endif
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 55bc224c61..8fe59cf54d 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/compat-policy.h"
#include "qapi/error.h"
#include "qapi/qmp/dispatch.h"
#include "qapi/qmp/qdict.h"
@@ -19,6 +20,8 @@
#include "sysemu/runstate.h"
#include "qapi/qmp/qbool.h"
+CompatPolicy qapi_compat_policy;
+
static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oob,
QObject **id, Error **errp)
{
diff --git a/vl.c b/vl.c
index 4489cfb2bb..300f2a01de 100644
--- a/vl.c
+++ b/vl.c
@@ -26,6 +26,7 @@
#include "qemu-common.h"
#include "qemu/units.h"
#include "hw/qdev-properties.h"
+#include "qapi/compat-policy.h"
#include "qapi/error.h"
#include "qemu-version.h"
#include "qemu/cutils.h"
@@ -3783,6 +3784,22 @@ int main(int argc, char **argv, char **envp)
qemu_opt_get_bool(opts, "mem-lock", false);
enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", false);
break;
+ case QEMU_OPTION_compat:
+ {
+ CompatPolicy *opts;
+ Visitor *v;
+
+ v = qobject_input_visitor_new_str(optarg, NULL,
+ &error_fatal);
+
+ visit_type_CompatPolicy(v, NULL, &opts, &error_fatal);
+ QAPI_CLONE_MEMBERS(CompatPolicy, &qapi_compat_policy,
+ opts);
+
+ qapi_free_CompatPolicy(opts);
+ visit_free(v);
+ break;
+ }
case QEMU_OPTION_msg:
opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg,
false);
diff --git a/qemu-options.hx b/qemu-options.hx
index 996b6fba74..c43f768a15 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3319,6 +3319,24 @@ STEXI
@table @option
ETEXI
+DEF("compat", HAS_ARG, QEMU_OPTION_compat,
+ "-compat [deprecated-input=accept][,deprecated-output=accept]\n"
+ " Policy for handling deprecated management interfaces\n",
+ QEMU_ARCH_ALL)
+STEXI
+@item -compat
[deprecated-input=@var{input-policy}][,deprecated-output=@var{output-policy}]
+@findex -compat
+
+Set policy for handling deprecated management interfaces:
+@table @option
+@item deprecated-input=accept (default)
+Accept deprecated commands
+@item deprecated-output=accept (default)
+Emit deprecated events
+@end table
+FIXME Guidance on intended use
+ETEXI
+
DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,
"-fw_cfg [name=]<name>,file=<file>\n"
" add named fw_cfg entry with contents from file\n"
--
2.21.0
- [RFC PATCH 03/19] tests/test-qmp-cmds: Simplify test data setup, (continued)
- [RFC PATCH 03/19] tests/test-qmp-cmds: Simplify test data setup, Markus Armbruster, 2019/10/24
- [RFC PATCH 04/19] tests/test-qmp-event: Simplify test data setup, Markus Armbruster, 2019/10/24
- [RFC PATCH 01/19] tests/test-qmp-cmds: Factor out qmp_dispatch() test helpers, Markus Armbruster, 2019/10/24
- [RFC PATCH 12/19] qapi: Replace qmp_dispatch()'s TODO comment by an explanation, Markus Armbruster, 2019/10/24
- [RFC PATCH 15/19] qapi: Mark deprecated QMP commands with feature 'deprecated', Markus Armbruster, 2019/10/24
- [RFC PATCH 18/19] qapi: Include a warning in the response to a deprecated command, Markus Armbruster, 2019/10/24
- [RFC PATCH 19/19] qapi: Implement -compat deprecated-output=hide for events, Markus Armbruster, 2019/10/24
- [RFC PATCH 17/19] qapi: Implement -compat deprecated-input=crash for commands, Markus Armbruster, 2019/10/24
- [RFC PATCH 13/19] qapi: New special feature flag "deprecated", Markus Armbruster, 2019/10/24
- [RFC PATCH 05/19] tests/test-qmp-event: Use qobject_is_equal(), Markus Armbruster, 2019/10/24
- [RFC PATCH 14/19] qemu-options: New -compat to set policy for "funny" interfaces,
Markus Armbruster <=
- [RFC PATCH 09/19] qapi: Inline do_qmp_dispatch() into qmp_dispatch(), Markus Armbruster, 2019/10/24
- [RFC PATCH 11/19] qapi: Simplify how qmp_dispatch() gets the request ID, Markus Armbruster, 2019/10/24
- [RFC PATCH 16/19] qapi: Implement -compat deprecated-input=reject for commands, Markus Armbruster, 2019/10/24
- [RFC PATCH 06/19] tests/test-qmp-event: Check event is actually emitted, Markus Armbruster, 2019/10/24
- [RFC PATCH 10/19] qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP, Markus Armbruster, 2019/10/24
- [RFC PATCH 08/19] qapi: Consistently put @features parameter right after @ifcond, Markus Armbruster, 2019/10/24
- [RFC PATCH 07/19] qapi: Add feature flags to remaining definitions, Markus Armbruster, 2019/10/24