qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qmp-shell: fix nested json regression


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH] qmp-shell: fix nested json regression
Date: Mon, 11 Mar 2019 10:27:36 -0300
User-agent: Mutt/1.10.1 (2018-07-13)

On Sat, Mar 09, 2019 at 10:01:58AM +0100, Markus Armbruster wrote:
> John Snow <address@hidden> writes:
> 
> > On 2/5/19 8:49 AM, Marc-André Lureau wrote:
> >> Commit fcfab7541 ("qmp-shell: learn to send commands with quoted
> >> arguments") introduces the usage of Python 'shlex' to handle quoted
> >> arguments, but it accidentally broke generation of nested JSON
> >> structs.
> >> 
> >> shlex drops quotes, which breaks parsing of the nested struct.
> >> 
> >> cmd='blockdev-create job-id="job0 foo" 
> >> options={"driver":"qcow2","size":16384,"file":{"driver":"file","filename":"foo.qcow2"}}'
> >> 
> >> shlex.split(cmd)
> >> ['blockdev-create',
> >>  'job-id=job0 foo',
> >>  'options={driver:qcow2,size:16384,file:{driver:file,filename:foo.qcow2}}']
> >> 
> >> Replace with a regexp to split while respecting quoted strings and 
> >> preserving quotes:
> >> 
> >> re.findall(r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''', cmd)
> >> ['blockdev-create',
> >>  'job-id="job0 foo"',
> >>  
> >> 'options={"driver":"qcow2","size":16384,"file":{"driver":"file","filename":"foo.qcow2"}}']
> >> 
> >> Fixes: fcfab7541 ("qmp-shell: learn to send commands with quoted 
> >> arguments")
> >> Reported-by: Kashyap Chamarthy <address@hidden>
> >> Signed-off-by: Marc-André Lureau <address@hidden>
> >
> > Hi, did this get misplaced? Would be nice to have back for 4.0 release.
> 
> Eduardo, Cleber, I think this one's for you.

Queued, thanks.

I'm really bothered by the lack of tests for qmp-shell
command-line parsing.  Does anybody volunteer to write a small
set of doctest examples for __build_cmd()?

-- 
Eduardo



reply via email to

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