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 <ebl...@redhat.com>
>> ---
>>  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 <js...@redhat.com>
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to