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

Peter Luo d8514 at sina.com
Fri Jan 31 10:38:33 UTC 2020


Hi All, 

 

I’m using qmp command via “virsh qemu-monitor-command” to perform block related jobs. 

And in my case, I execute block-commit to commit the changes in the top image to the base image which is encrypted. 

So in the base parameter, I need a json string which is single quoted to support the encryption parameters. 

However, the virsh is failed to parse the whole json qmp command. 

 

Attempt 1: Single quote without backflash, failed 

root at host:~# virsh qemu-monitor-command i-9wdfw2x8  "{\"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\"}}"

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) ------^

 

Attempt 2: Single quote with backflash, failed

root at host:~# virsh qemu-monitor-command i-9wdfw2x8  "{\"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\"}}"

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

                     (right here) ------^ 

 

 

My libvirt version is 5.7.0, libyajl is 2.1.0.

 

Thanks,

Peter Luo 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20200131/e6a327bd/attachment.htm>


More information about the libvirt-users mailing list