qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: libvir-list@redhat.com, mdroth@linux.vnet.ibm.com
Subject: [RFC PATCH 14/19] qemu-options: New -compat to set policy for "funny" interfaces
Date: Thu, 24 Oct 2019 14:34:53 +0200	[thread overview]
Message-ID: <20191024123458.13505-15-armbru@redhat.com> (raw)
In-Reply-To: <20191024123458.13505-1-armbru@redhat.com>

"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@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@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
+@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



  parent reply	other threads:[~2019-10-24 13:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 12:34 [RFC PATCH 00/19] Configurable policy for handling deprecated interfaces Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 01/19] tests/test-qmp-cmds: Factor out qmp_dispatch() test helpers Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 02/19] tests/test-qmp-cmds: Check responses more thoroughly Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 03/19] tests/test-qmp-cmds: Simplify test data setup Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 04/19] tests/test-qmp-event: " Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 05/19] tests/test-qmp-event: Use qobject_is_equal() Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 06/19] tests/test-qmp-event: Check event is actually emitted Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 07/19] qapi: Add feature flags to remaining definitions Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 08/19] qapi: Consistently put @features parameter right after @ifcond Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 09/19] qapi: Inline do_qmp_dispatch() into qmp_dispatch() Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 10/19] qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 11/19] qapi: Simplify how qmp_dispatch() gets the request ID Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 12/19] qapi: Replace qmp_dispatch()'s TODO comment by an explanation Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 13/19] qapi: New special feature flag "deprecated" Markus Armbruster
2019-10-24 12:34 ` Markus Armbruster [this message]
2019-10-24 12:34 ` [RFC PATCH 15/19] qapi: Mark deprecated QMP commands with feature 'deprecated' Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 16/19] qapi: Implement -compat deprecated-input=reject for commands Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 17/19] qapi: Implement -compat deprecated-input=crash " Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 18/19] qapi: Include a warning in the response to a deprecated command Markus Armbruster
2019-10-24 14:01   ` [libvirt] " Daniel P. Berrangé
2019-10-24 19:35     ` Markus Armbruster
2019-10-24 12:34 ` [RFC PATCH 19/19] qapi: Implement -compat deprecated-output=hide for events Markus Armbruster
2019-10-24 14:16   ` [libvirt] " Daniel P. Berrangé
2019-10-24 19:56     ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191024123458.13505-15-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).