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:
Markus Armbruster 2021-03-18 16:55:11 +01:00
parent 6dd75472d5
commit 91fa93e516
13 changed files with 132 additions and 24 deletions

View file

@ -135,6 +135,15 @@ bool visit_optional(Visitor *v, const char *name, bool *present)
return *present;
}
bool visit_deprecated(Visitor *v, const char *name)
{
trace_visit_deprecated(v, name);
if (v->deprecated) {
return v->deprecated(v, name);
}
return true;
}
bool visit_is_input(Visitor *v)
{
return v->type == VISITOR_INPUT;