[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 28/34] qapi: Implement deprecated-output=hide for QMP comm
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v4 28/34] qapi: Implement deprecated-output=hide for QMP command results |
Date: |
Wed, 18 Mar 2020 17:47:46 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 3/17/20 6:54 AM, Markus Armbruster wrote:
>> 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 <address@hidden>
>> ---
>
>> +++ b/tests/test-qmp-cmds.c
>> @@ -1,4 +1,5 @@
>> #include "qemu/osdep.h"
>> +#include "qapi/compat-policy.h"
>> #include "qapi/qmp/qdict.h"
>> #include "qapi/qmp/qjson.h"
>> #include "qapi/qmp/qnum.h"
>> @@ -45,12 +46,17 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp)
>> {
>> }
>> -void qmp_test_features0(FeatureStruct0 *fs0, FeatureStruct1 *fs1,
>> - FeatureStruct2 *fs2, FeatureStruct3 *fs3,
>> - FeatureStruct4 *fs4, CondFeatureStruct1 *cfs1,
>> - CondFeatureStruct2 *cfs2, CondFeatureStruct3 *cfs3,
>> - Error **errp)
>> +FeatureStruct1 *qmp_test_features0(bool has_fs0, FeatureStruct0 *fs0,
>> + bool has_fs1, FeatureStruct1 *fs1,
>> + bool has_fs2, FeatureStruct2 *fs2,
>> + bool has_fs3, FeatureStruct3 *fs3,
>> + bool has_fs4, FeatureStruct4 *fs4,
>> + bool has_cfs1, CondFeatureStruct1 *cfs1,
>> + bool has_cfs2, CondFeatureStruct2 *cfs2,
>> + bool has_cfs3, CondFeatureStruct3 *cfs3,
>> + Error **errp)
>> {
>> + return g_new(FeatureStruct1, 1);
>
> Should this be using g_new0, rather than random contents?
Accident. It's not actually used.
>> }
>> void qmp_test_command_features1(Error **errp)
>> @@ -271,6 +277,30 @@ static void test_dispatch_cmd_io(void)
>> qobject_unref(ret3);
>> }
>> +static void test_dispatch_cmd_ret_deprecated(void)
>> +{
>> + const char *cmd = "{ 'execute': 'test-features0' }";
>> + QDict *ret;
>> +
>> + memset(&compat_policy, 0, sizeof(compat_policy));
>> +
>> + /* default accept */
>> + ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
>> + assert(ret && qdict_size(ret) == 1);
>> + qobject_unref(ret);
>> +
>> + compat_policy.has_deprecated_output = true;
>> + compat_policy.deprecated_output = COMPAT_POLICY_OUTPUT_ACCEPT;
>
> Of course, if we ever enable defaults in QAPI, we can get rid of
> has_deprecated_output by recording proper defaults for bools. But
> that's a different project ;)
Yes. The has_FOO have been annoying me since forever. I just never get
around to doing anything about it.
>> + ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
>> + assert(ret && qdict_size(ret) == 1);
>> + qobject_unref(ret);
>> +
>> + compat_policy.deprecated_output = COMPAT_POLICY_OUTPUT_HIDE;
>> + ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
>> + assert(ret && qdict_size(ret) == 0);
>> + qobject_unref(ret);
>> +}
>> +
>
> Otherwise,
> Reviewed-by: Eric Blake <address@hidden>
Thanks!
- [PATCH v4 22/34] qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP, (continued)
- [PATCH v4 22/34] qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP, Markus Armbruster, 2020/03/17
- [PATCH v4 10/34] tests/test-qmp-event: Check event is actually emitted, Markus Armbruster, 2020/03/17
- [PATCH v4 18/34] qapi/schema: Rename QAPISchemaObjectType{Variant, Variants}, Markus Armbruster, 2020/03/17
- [PATCH v4 27/34] qemu-options: New -compat to set policy for deprecated interfaces, Markus Armbruster, 2020/03/17
- [PATCH v4 21/34] qapi: Inline do_qmp_dispatch() into qmp_dispatch(), Markus Armbruster, 2020/03/17
- [PATCH v4 32/34] qapi: Implement deprecated-input=reject for QMP commands, Markus Armbruster, 2020/03/17
- [PATCH v4 28/34] qapi: Implement deprecated-output=hide for QMP command results, Markus Armbruster, 2020/03/17
- [PATCH v4 25/34] qapi: New special feature flag "deprecated", Markus Armbruster, 2020/03/17
- [PATCH v4 13/34] qapi: Consistently put @features parameter right after @ifcond, Markus Armbruster, 2020/03/17
- [PATCH v4 29/34] qapi: Implement deprecated-output=hide for QMP events, Markus Armbruster, 2020/03/17
- [PATCH v4 34/34] qapi: New -compat deprecated-input=crash, Markus Armbruster, 2020/03/17
- [PATCH v4 19/34] qapi/schema: Call QAPIDoc.connect_member() in just one place, Markus Armbruster, 2020/03/17
- [PATCH v4 26/34] qapi: Mark deprecated QMP parts with feature 'deprecated', Markus Armbruster, 2020/03/17