mirror of
https://github.com/mii443/qemu.git
synced 2025-12-03 02:58:29 +00:00
qapi: Implement deprecated-input=reject for QMP command arguments
This policy rejects deprecated input, and thus permits "testing the
future". Implement it for QMP command arguments: reject commands with
deprecated ones. Example: when QEMU is run with -compat
deprecated-input=reject, then
{"execute": "eject", "arguments": {"device": "cd"}}
fails like this
{"error": {"class": "GenericError", "desc": "Deprecated parameter 'device' disabled by policy"}}
When the deprecated parameter is removed, the error will change to
{"error": {"class": "GenericError", "desc": "Parameter 'device' is unexpected"}}
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210318155519.1224118-11-armbru@redhat.com>
This commit is contained in:
@@ -17,6 +17,15 @@
|
||||
|
||||
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
|
||||
*
|
||||
|
||||
@@ -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,6 +59,9 @@ typedef struct QObjectInputVisitor QObjectInputVisitor;
|
||||
*/
|
||||
Visitor *qobject_input_visitor_new(QObject *obj);
|
||||
|
||||
void qobject_input_visitor_set_policy(Visitor *v,
|
||||
CompatPolicyInput deprecated);
|
||||
|
||||
/*
|
||||
* Create a QObject input visitor for @obj for use with keyval_parse()
|
||||
*
|
||||
|
||||
@@ -113,6 +113,9 @@ struct Visitor
|
||||
The core takes care of the return type in the public interface. */
|
||||
void (*optional)(Visitor *v, const char *name, bool *present);
|
||||
|
||||
/* Optional */
|
||||
bool (*deprecated_accept)(Visitor *v, const char *name, Error **errp);
|
||||
|
||||
/* Optional */
|
||||
bool (*deprecated)(Visitor *v, const char *name);
|
||||
|
||||
|
||||
@@ -459,6 +459,15 @@ void visit_end_alternate(Visitor *v, void **obj);
|
||||
*/
|
||||
bool visit_optional(Visitor *v, const char *name, bool *present);
|
||||
|
||||
/*
|
||||
* Should we reject deprecated member @name?
|
||||
*
|
||||
* @name must not be NULL. This function is only useful between
|
||||
* visit_start_struct() and visit_end_struct(), since only objects
|
||||
* have deprecated members.
|
||||
*/
|
||||
bool visit_deprecated_accept(Visitor *v, const char *name, Error **errp);
|
||||
|
||||
/*
|
||||
* Should we visit deprecated member @name?
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user