[libvirt] [RFC PATCH 14/19] qemu-options: New -compat to set policy for "funny" interfaces

Markus Armbruster armbru at redhat.com
Thu Oct 24 12:34:53 UTC 2019


"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 <armbru at redhat.com>
---
 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 <armbru at redhat.com>,
+ *
+ * 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
+ at item -compat [deprecated-input=@var{input-policy}][,deprecated-output=@var{output-policy}]
+ at findex -compat
+
+Set policy for handling deprecated management interfaces:
+ at table @option
+ at item deprecated-input=accept (default)
+Accept deprecated commands
+ at item deprecated-output=accept (default)
+Emit deprecated events
+ at 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




More information about the libvir-list mailing list