qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from bloc


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
Date: Fri, 9 Jun 2017 07:46:19 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0

On 06/09/2017 07:40 AM, Markus Armbruster wrote:
> Marc-André Lureau <address@hidden> writes:
> 
>> Hi
>>
>> ----- Original Message -----
>>>>
>>>> The title claims "move dump_qobject() from block/ to qobject/", but
>>>> that's not what the patch does.  It *replaces* dump_qobject() by
>>>> qobject_to_string().  The former dumps to a callback, the latter to a
>>>> dynamic string buffer.
>>>>
>>>> Providing dump functionality in one way doesn't preclude the other way:
>>>> given callback, one could define a callback that builds up a string
>>>> buffer, and given buffer, one could (and you actually do) pass the
>>>> buffer to a callback.  That's less efficient, though.
>>>>
>>>> Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
>>>> Max and Kevin to double-check.
>>>
>>> I believe convenience is more important than efficiency here. It's easy to
>>> call qobject_to_string(foo) from gdb for example, with a callback, it's less
>>> easy.
>>>
>>> (fprintf or monitor_fprintf will both build an internal buffer anyway,
>>> efficiency is probably similar)
> 
> monitor_vprintf() formats to a dynamic buffer, which it passes to
> monitor_puts().  monitor_puts() uses a line buffer.
> 
> fprintf() can be unbuffered, line-buffered, or fully buffered.
> 
> Converting everything to a string first is different: the string buffer
> holds *everything* rather than just a line or some fixed size.

My patch series to create a QAPI-to-JSON output visitor, and convert the
existing qobject-to-json conversion to be a thin wrapper over the JSON
visitor, is a natural place to create a visitor constructor that can
take a callback (where the callback either appends to a QString or uses
pwrite() (no need to spend time with the slower printf()) to go straight
to stdout.  I'll have to revive that series on top of your work.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]