From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] QMP: allow dot separated dict path arguments in qmp-shell
Date: Wed, 12 Feb 2014 08:56:22 +0800 [thread overview]
Message-ID: <20140212005622.GC7257@T430.nay.redhat.com> (raw)
In-Reply-To: <20140211132808.GA29957@stefanha-thinkpad.brq.redhat.com>
On Tue, 02/11 14:28, Stefan Hajnoczi wrote:
> 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
Yes, thanks. And we should check the contradictive case "foo=a foo.bar=b". Will
send v2.
Fam
prev parent reply other threads:[~2014-02-12 0:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-29 11:17 [Qemu-devel] [PATCH] QMP: allow JSON dict arguments in qmp-shell Stefan Hajnoczi
2014-01-29 15:48 ` Eric Blake
2014-01-29 15:50 ` Benoît Canet
2014-02-10 20:43 ` Luiz Capitulino
2014-02-11 1:39 ` Fam Zheng
2014-02-11 8:41 ` Kevin Wolf
2014-02-11 9:35 ` Fam Zheng
2014-02-11 8:43 ` Markus Armbruster
2014-02-11 9:38 ` Fam Zheng
2014-02-11 10:45 ` [Qemu-devel] [PATCH] QMP: allow dot separated dict path " Fam Zheng
2014-02-11 13:28 ` Stefan Hajnoczi
2014-02-12 0:56 ` Fam Zheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140212005622.GC7257@T430.nay.redhat.com \
--to=famz@redhat.com \
--cc=imammedo@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).