On Tue, Feb 11, 2014 at 06:45:05PM +0800, Fam Zheng wrote: > diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell > index d374b35..9c84551 100755 > --- a/scripts/qmp/qmp-shell > +++ b/scripts/qmp/qmp-shell > @@ -112,7 +112,14 @@ class QMPShell(qmp.QEMUMonitorProtocol): > value = json.loads(opt[1]) > else: > value = opt[1] > - qmpcmd['arguments'][opt[0]] = value > + optpath = opt[0].split('.') > + parent = qmpcmd['arguments'] > + for p in optpath[:-1]: > + if not p in parent: > + d = dict() > + parent[p] = d > + parent = d
d is a stale reference when the path component already exists (e.g. a.b.c=1 a.d=2). Since 'a' already exists when processing 'a.d' we'll the value of d will actually be the a.b dict! I think you need the following instead: for p in optpath[:-1]: d = parent.get(p, {}) parent[p] = d parent = d