[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 17/36] qtest: Avoid dynamic JSON in
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 17/36] qtest: Avoid dynamic JSON in ahci-test |
Date: |
Wed, 30 Nov 2016 15:19:29 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
On 11/30/2016 03:02 PM, John Snow wrote:
>
>
> On 11/30/2016 02:44 PM, Eric Blake wrote:
>> As argued elsewhere, it's less code to maintain if we convert
>> from a dynamic string passed to qobject_from_jsonv() to instead
>> use a hand-built QDict.
>>
>> Rather than build up a QDict by manual qdict_put*() calls, we
>> can let QAPI do the work for us. The result is more lines of
>> code to initialize the QAPI struct, but the result will force us
>> to track any changes to the qapi (whereas the dynamic JSON string
>> would not detect qapi changes until runtime).
>>
>
> Benefit of doubt that you're right.
>
>> Signed-off-by: Eric Blake <address@hidden>
>> ---
>> tests/ahci-test.c | 26 +++++++++++++++++++++-----
>> 1 file changed, 21 insertions(+), 5 deletions(-)
>> + args = QAPI_TO_QOBJECT(BlockdevOptions, &opts, &error_abort);
>> + }
>> +
>> + qmp_cmd_discard_response("blockdev-add", qobject_to_qdict(args));
>> qmp_discard_response("{'execute': 'x-blockdev-insert-medium',"
>> "'arguments': { 'device': 'drive0', "
>> "'node-name': 'node0' }}");
>>
>
> I assume qmp_cmd_discard_response takes ownership of the object we just
> built?
Yes. I had to track that down myself, which is why in patch 9, I
documented it:
/**
+ * qmp_cmd_discard_response:
+ * @cmd: Command name to send
+ * @args: Arguments to transfer to the command, or NULL.
+ *
+ * Sends a QMP message to QEMU and consumes the response. Calling this will
+ * reduce the reference count of @args.
+ */
+void qmp_cmd_discard_response(const char *cmd, QDict *args);
>
> Assuming yes:
> Reviewed-by: John Snow <address@hidden>
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature