scripts: qmp-shell: Expand support for QMP expressions
authorJohn Snow <jsnow@redhat.com>
Wed, 29 Apr 2015 19:14:02 +0000 (15:14 -0400)
committerLuiz Capitulino <lcapitulino@redhat.com>
Mon, 11 May 2015 12:59:07 +0000 (08:59 -0400)
commit6092c3ecc4bdafee5bf07061be78a4a2cc5a5088
treef662bd8b7d8b4a52f008cb4260c4385a2f3583e2
parenta7430a0badc59bd6295936e06c1869e8fe32649d
scripts: qmp-shell: Expand support for QMP expressions

This includes support for [] expressions, single-quotes in
QMP expressions (which is not strictly a part of JSON), and
the ability to use "True", "False" and "None" literals instead
of JSON's equivalent true, false, and null literals.

qmp-shell currently allows you to describe values as
JSON expressions:
key={"key":{"key2":"val"}}

But it does not currently support arrays, which are needed
for serializing and deserializing transactions:
key=[{"type":"drive-backup","data":{...}}]

qmp-shell also only currently accepts doubly quoted strings
as-per JSON spec, but QMP allows single quotes.

Lastly, python allows you to utilize "True" or "False" as
boolean literals, but JSON expects "true" or "false". Expand
qmp-shell to allow the user to type either, converting to the
correct type.

As a consequence of the above, the key=val parsing is also improved
to give better error messages if a key=val token is not provided.

CAVEAT: The parser is still extremely rudimentary and does not
expect to find spaces in {} nor [] expressions. This patch does
not improve this functionality.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
scripts/qmp/qmp-shell