qapi: Implement deprecated-output=hide for QMP command results
This policy suppresses deprecated bits in output, and thus permits
"testing the future". Implement it for QMP command results. Example:
when QEMU is run with -compat deprecated-output=hide, then
{"execute": "query-cpus-fast"}
yields
{"return": [{"thread-id": 9805, "props": {"core-id": 0, "thread-id": 0, "socket-id": 0}, "qom-path": "/machine/unattached/device[0]", "cpu-index": 0, "target": "x86_64"}]}
instead of
{"return": [{"arch": "x86", "thread-id": 22436, "props": {"core-id": 0, "thread-id": 0, "socket-id": 0}, "qom-path": "/machine/unattached/device[0]", "cpu-index": 0, "target": "x86_64"}]}
Note the suppression of deprecated member "arch".
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210318155519.1224118-4-armbru@redhat.com>
This commit is contained in:
@@ -17,4 +17,13 @@
|
||||
|
||||
extern CompatPolicy compat_policy;
|
||||
|
||||
/*
|
||||
* Create a QObject output visitor for @obj for use with QMP
|
||||
*
|
||||
* This is like qobject_output_visitor_new(), except it obeys the
|
||||
* policy for handling deprecated management interfaces set with
|
||||
* -compat.
|
||||
*/
|
||||
Visitor *qobject_output_visitor_new_qmp(QObject **result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define QOBJECT_OUTPUT_VISITOR_H
|
||||
|
||||
#include "qapi/visitor.h"
|
||||
#include "qapi/qapi-types-compat.h"
|
||||
|
||||
typedef struct QObjectOutputVisitor QObjectOutputVisitor;
|
||||
|
||||
@@ -53,4 +54,7 @@ typedef struct QObjectOutputVisitor QObjectOutputVisitor;
|
||||
*/
|
||||
Visitor *qobject_output_visitor_new(QObject **result);
|
||||
|
||||
void qobject_output_visitor_set_policy(Visitor *v,
|
||||
CompatPolicyOutput deprecated);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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)(Visitor *v, const char *name);
|
||||
|
||||
/* Must be set */
|
||||
VisitorType type;
|
||||
|
||||
|
||||
@@ -459,6 +459,15 @@ void visit_end_alternate(Visitor *v, void **obj);
|
||||
*/
|
||||
bool visit_optional(Visitor *v, const char *name, bool *present);
|
||||
|
||||
/*
|
||||
* Should we visit 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(Visitor *v, const char *name);
|
||||
|
||||
/*
|
||||
* Visit an enum value.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user