Re: Does Libvirt's json parser support single quoted string in qmp json string?

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

 



On Tue, Feb 04, 2020 at 09:11:27AM +0100, Markus Armbruster wrote:
> Eric Blake <eblake@xxxxxxxxxx> writes:
> 
> > [adding Markus]
> >
> > On 2/3/20 4:13 AM, Daniel P. Berrangé wrote:
> >> On Fri, Jan 31, 2020 at 06:44:42AM -0600, Eric Blake wrote:
> >>> On 1/31/20 4:38 AM, Peter Luo wrote:
> >>>
> >>>> error: internal error: cannot parse json {"execute": "block-commit", "arguments": { "device": "drive-virtio-disk2", "job-id": "job100", "base":'json:{"encrypt.key-secret":"vol-38973xjl.secret","driver":"qcow2","file":{"driver":"file","filename":"/pitrix/data/container/vol-38973xjl.img"}}', "top": "/pitrix/data/container/vol-38973xjl_ss-2tw7v0mm.img"}}: lexical error: invalid char in json text.
> >>>>
> >>>>             , "job-id": "job100", "base":'json:{"encrypt.key-secret":"vo
> >>>>
> >>>>                        (right here) ------^
> >>>>
> >>>
> >>> qemu's QMP language has an extension where it accepts 'string' in addition
> >>> to the JSON "string".  But it uses a hand-rolled parser, so it can do
> >>> whatever it wants.
> >>
> >> Can we deprecate & remove this extension in QEMU ?
> 
> I think deprecating the extension makes sense only if we can actually
> kill it.
> 
> We could try to make the extension opt-in, and have only the intermal
> users opt in.  Can't say offhand whether that's practical.
> 
> > We could start a deprecation clock, if desired, but I don't know how
> > many external users would be impacted (at least qemu's testsuite
> > heavily relies on the extension of single quotes).
> 
> Looks like this:
> 
>     rsp = qdict_from_jsonf_nofail("{ 'error': { 'class': %s, 'desc': %s } }",
>                                   QapiErrorClass_str(error_get_class(err)),
>                                   error_get_pretty(err));
> 
> Without the extension, we'd suffer from a mild case of leaning toothpick
> syndrome:
> 
>     rsp = qdict_from_jsonf_nofail("{ \"error\": { \"class\": %s, \"desc\": %s } }",
>                                   QapiErrorClass_str(error_get_class(err)),
>                                   error_get_pretty(err));
> 
> I intentionally picked an example outside tests/ :)

This is purely QEMU internal code. That is fine to use whatever
extensions are desired, as it isn't exposed to end users or mgmt
apps. 

The harm from JSON extensions comes in places where our public API
accepts it - CLI, QMP, JSON inside disk images, etc, as those are
all places where interoperability with third party apps is relevant


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|





[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux