[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 30/34] qapi: Implement deprecated-output=hide for QMP even
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v4 30/34] qapi: Implement deprecated-output=hide for QMP event data |
Date: |
Wed, 18 Mar 2020 18:01:42 +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 event data: suppress
>> deprecated members.
>>
>> No QMP event data is deprecated right now.
>>
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>
>> +static void test_event_deprecated_data(TestEventData *data, const void
>> *unused)
>> +{
>> + memset(&compat_policy, 0, sizeof(compat_policy));
>> +
>> + data->expect = qdict_from_jsonf_nofail("{ 'event':
>> 'TEST-EVENT-FEATURES0',"
>> + " 'data': { 'foo': 42 } }");
>> + qapi_event_send_test_event_features0(42);
>> + g_assert(data->emitted);
>> +
>> + qobject_unref(data->expect);
>> +
>> + compat_policy.deprecated_output = COMPAT_POLICY_OUTPUT_HIDE;
>
> Again, playing fast-and-loose with compat_policy.has_deprecated_output.
I'll clean it up.
>> +++ b/scripts/qapi/events.py
>> @@ -104,7 +104,7 @@ def gen_event_send(name, arg_type, features, boxed,
>> if have_args:
>> ret += mcgen('''
>> - v = qobject_output_visitor_new(&obj);
>> + v = qobject_output_visitor_new_qmp(&obj);
>> ''')
>> if not arg_type.is_implicit():
>> ret += mcgen('''
>> @@ -123,7 +123,11 @@ def gen_event_send(name, arg_type, features, boxed,
>> ret += mcgen('''
>> visit_complete(v, &obj);
>> - qdict_put_obj(qmp, "data", obj);
>> + if (qdict_size(qobject_to(QDict, obj))) {
>> + qdict_put_obj(qmp, "data", obj);
>> + } else {
>> + qobject_unref(obj);
>> + }
>
> So you'd rather omit data altogether than emit "data":{} when all
> deprecated members disappear. Fair enough; both approaches work.
I initially didn't do this until my testing demonstrated that "data"
goes away entirely when I delete the last member from the schema. To
actually fulfill the "test the future" mission, I need policy hide drop
data, too.
> Reviewed-by: Eric Blake <address@hidden>
Thanks!
- [PATCH v4 07/34] tests/test-qmp-cmds: Simplify test data setup, (continued)
- [PATCH v4 07/34] tests/test-qmp-cmds: Simplify test data setup, Markus Armbruster, 2020/03/17
- [PATCH v4 16/34] qapi/schema: Change _make_features() to a take feature list, Markus Armbruster, 2020/03/17
- [PATCH v4 23/34] qapi: Simplify how qmp_dispatch() gets the request ID, Markus Armbruster, 2020/03/17
- [PATCH v4 09/34] tests/test-qmp-event: Use qobject_is_equal(), Markus Armbruster, 2020/03/17
- [PATCH v4 11/34] qapi/schema: Clean up around QAPISchemaEntity.connect_doc(), Markus Armbruster, 2020/03/17
- [PATCH v4 24/34] qapi: Replace qmp_dispatch()'s TODO comment by an explanation, Markus Armbruster, 2020/03/17
- [PATCH v4 30/34] qapi: Implement deprecated-output=hide for QMP event data, Markus Armbruster, 2020/03/17
- [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