[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v2 41/47] qom: Don't use 'gen': false for qo
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH RFC v2 41/47] qom: Don't use 'gen': false for qom-get, qom-set, object-add |
Date: |
Tue, 28 Jul 2015 13:59:09 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 07/01/2015 02:22 PM, Markus Armbruster wrote:
>> With the previous commit, the generated marshalers just work, and save
>> us a bit of handwritten code.
>>
>
> Generated code grows, because you are now generating the hook :)
>
> qmp-commands.h | 6 ++
> qmp-marshal.c | 144
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 150 insertions(+)
>
>
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> include/monitor/monitor.h | 3 ---
>> qapi-schema.json | 9 +++------
>> qmp-commands.hx | 6 +++---
>> qmp.c | 20 +++++++-------------
>> scripts/qapi.py | 1 +
>> 5 files changed, 14 insertions(+), 25 deletions(-)
>>
>
>> +++ b/qmp.c
>> @@ -229,11 +229,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path,
>> Error **errp)
>> }
>>
>> /* FIXME: teach qapi about how to pass through Visitors */
>> -void qmp_qom_set(QDict *qdict, QObject **ret, Error **errp)
>> +void qmp_qom_set(const char *path, const char *property, QObject *value,
>> + Error **errp)
>
> The FIXME seems stale now.
I'm not 100% sure I understand the intent of the FIXME, but my best
guess is "do what this patch does". I'll drop it.
>> -void qmp_object_add(QDict *qdict, QObject **ret, Error **errp)
>> +void qmp_object_add(const char *type, const char *id,
>> + bool has_props, QObject *props, Error **errp)
>> {
>> - const char *type = qdict_get_str(qdict, "qom-type");
>> - const char *id = qdict_get_str(qdict, "id");
>> - QObject *props = qdict_get(qdict, "props");
>> const QDict *pdict = NULL;
>> QmpInputVisitor *qiv;
>>
>
> Continuing:
>
> if (props) {
> pdict = qobject_to_qdict(props);
> if (!pdict) {
> error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
> return;
> }
> }
>
> I know that we guarantee that all pointers are initialized to NULL in
> our marshaler, so this is correct; but wouldn't it be more idiomatic to
> write 'if (has_props)' as the condition?
We do similar things elsewhere. Moreover:
> (And it would make a nice followup project for someone to figure out how
> to get rid of have_FOO arguments for strings and objects where NULL is a
> nice witness; it is only integers and booleans that require them - but
> doing that will touch a lot of the tree, and is a series of its own)
Shouldn't be hard, and I really want it done.
Will change all the places that test has_PTR to just PTR. More reason
to simply test PTR now.
> What I pointed out is minor, so you can fix it and add:
> Reviewed-by: Eric Blake <address@hidden>
Thanks!
- Re: [Qemu-devel] [PATCH RFC v2 27/47] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs, (continued)
[Qemu-devel] [PATCH RFC v2 24/47] tests/qapi-schema: Convert test harness to QAPISchemaVisitor, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 41/47] qom: Don't use 'gen': false for qom-get, qom-set, object-add, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 33/47] qapi: Clean up after recent conversions to QAPISchemaVisitor, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 19/47] qapi: Generated code cleanup, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 45/47] qapi: New QMP command query-schema for QMP schema introspection, Markus Armbruster, 2015/07/01