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

Daniel P. Berrangé berrange at redhat.com
Mon Feb 3 10:13:52 UTC 2020


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 ?

If we're going to call QMP protocol JSON, then IMHO QEMU should follow 
the JSON spec as closely as possible, without extensions.

On the flip side, if we're going to support extensions like single quoting, 
then we should make it clear to applications that this is not really JSON 
and that they need to provide an impl that is 100% matching QEMU's dialect.
This effectively means they need just import a copy of QEMU's code.

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 :|




More information about the libvirt-users mailing list