mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
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:
parent
6dd75472d5
commit
91fa93e516
13 changed files with 132 additions and 24 deletions
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/compat-policy.h"
|
||||
#include "qapi/qobject-output-visitor.h"
|
||||
#include "qapi/visitor-impl.h"
|
||||
#include "qemu/queue.h"
|
||||
|
@ -31,6 +32,8 @@ typedef struct QStackEntry {
|
|||
|
||||
struct QObjectOutputVisitor {
|
||||
Visitor visitor;
|
||||
CompatPolicyOutput deprecated_policy;
|
||||
|
||||
QSLIST_HEAD(, QStackEntry) stack; /* Stack of unfinished containers */
|
||||
QObject *root; /* Root of the output visit */
|
||||
QObject **result; /* User's storage location for result */
|
||||
|
@ -207,6 +210,13 @@ static bool qobject_output_type_null(Visitor *v, const char *name,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool qobject_output_deprecated(Visitor *v, const char *name)
|
||||
{
|
||||
QObjectOutputVisitor *qov = to_qov(v);
|
||||
|
||||
return qov->deprecated_policy != COMPAT_POLICY_OUTPUT_HIDE;
|
||||
}
|
||||
|
||||
/* Finish building, and return the root object.
|
||||
* The root object is never null. The caller becomes the object's
|
||||
* owner, and should use qobject_unref() when done with it. */
|
||||
|
@ -256,6 +266,7 @@ Visitor *qobject_output_visitor_new(QObject **result)
|
|||
v->visitor.type_number = qobject_output_type_number;
|
||||
v->visitor.type_any = qobject_output_type_any;
|
||||
v->visitor.type_null = qobject_output_type_null;
|
||||
v->visitor.deprecated = qobject_output_deprecated;
|
||||
v->visitor.complete = qobject_output_complete;
|
||||
v->visitor.free = qobject_output_free;
|
||||
|
||||
|
@ -264,3 +275,11 @@ Visitor *qobject_output_visitor_new(QObject **result)
|
|||
|
||||
return &v->visitor;
|
||||
}
|
||||
|
||||
void qobject_output_visitor_set_policy(Visitor *v,
|
||||
CompatPolicyOutput deprecated)
|
||||
{
|
||||
QObjectOutputVisitor *qov = to_qov(v);
|
||||
|
||||
qov->deprecated_policy = deprecated;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue