qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/5] scripts: qmp-shell: add support for [] expr


From: John Snow
Subject: Re: [Qemu-devel] [PATCH 2/5] scripts: qmp-shell: add support for [] expressions
Date: Wed, 22 Apr 2015 10:31:41 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0



On 04/22/2015 10:28 AM, Eric Blake wrote:
On 04/21/2015 08:02 PM, John Snow wrote:
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":{...}}]

Add support for arrays.

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 <address@hidden>
---
  scripts/qmp/qmp-shell | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index a9632ec..5347f89 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -102,6 +102,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
                      value = False
                  elif opt[1].startswith('{'):
                      value = json.loads(opt[1])
+                elif opt[1].startswith('['):
+                    value = json.loads(opt[1])

Why not:

elif opt[1].startswith('{'} or opt[1].startswith('['):


Didn't really consider this patch too long is why :)
If the rest of it looks worth checking in to you, I'll make the tidying edits.

for a one-line change instead of two-line addition?  And I'm no python
expert, but I think you can write that with fewer characters. Untested,
but does this work?

elif opt[1][0] in "{[":


It should.

Thanks,
--js



reply via email to

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