From: Nathan Baum <nathan@parenthephobia.org.uk>
To: Avi Kivity <avi@redhat.com>
Cc: Paolo Bonzini <bonzini@gnu.org>,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] Re: ANN: QEMU Monitor Protocol git tree
Date: Wed, 23 Sep 2009 16:19:41 +0100 [thread overview]
Message-ID: <1253719181.24147.84.camel@localhost.localdomain> (raw)
In-Reply-To: <4ABA2AD2.3040005@redhat.com>
On Wed, 2009-09-23 at 17:04 +0300, Avi Kivity wrote:
> On 09/23/2009 04:40 PM, Paolo Bonzini wrote:
> > On 09/23/2009 12:57 PM, Avi Kivity wrote:
> >> On 09/23/2009 12:57 PM, Daniel P. Berrange wrote:
> >>>> Ignoring the dos-ism, since you can parse JSON with a regexp, why
> >>>> do we
> >>>> need explicit message boundaries?
> >>> I think it would be nice to be able to assume that each JSON message
> >>> will not cross a line-end boundary. Whether we use CRLF, just CR or
> >>> just LF I don't mind. Its much easier to search for a message boundary
> >>> by just doing strchr('\n') than having to actually parse the JSON or
> >>> use a regexp at that point.
> >>
> >> A good parser will consume exactly enough characters to make up an
> >> object or let you know if it needs more. I don't think using a regexp is
> >> warranted.
> >
> > Agreed, regexes are unnecessary. Also because a regex cannot parse
> > JSON; it can only detect _some_ invalid JSON inputs, and then only if
> > you're given an already complete input.
> >
> > In other words, there are Javascript JSON parsers that are just "match
> > a regexp and run eval on the input", but the actual parsing is done by
> > the Javascript interpreter using eval. The regexp is just avoiding
> > the security problems that are inherent in eval.
>
> On the other hand, the two parsers I looked at only accept a string as
> input, not a stream (strangely, one of them internally converts the
> string to a stream, but doesn't expose the stream interface), so record
> termination might be helpful to parsers. Would be best not to rely on
> it in the server, though.
Relying upon a newline to terminate is also useful in environments where
it is difficult or even impossible to turn off line-buffered mode.
I sometimes have this problem when trying to consume the human-readable
monitor from a pipe; if I can't disable line-buffering, I don't see
"(qemu) " until I've entered the next command, which can be an
inconvenience.
I strongly agree that the server shouldn't rely on the line endings. The
server should accept any valid JSON syntax, being "liberal in what it
accepts, and conservative in what it sends".
next prev parent reply other threads:[~2009-09-23 15:19 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 1:44 [Qemu-devel] ANN: QEMU Monitor Protocol git tree Luiz Capitulino
2009-09-23 1:56 ` Anthony Liguori
2009-09-23 9:57 ` Daniel P. Berrange
2009-09-23 10:57 ` Avi Kivity
2009-09-23 13:40 ` [Qemu-devel] " Paolo Bonzini
2009-09-23 14:04 ` Avi Kivity
2009-09-23 15:19 ` Nathan Baum [this message]
2009-09-23 15:40 ` Luiz Capitulino
2009-09-23 18:15 ` Anthony Liguori
2009-09-23 18:36 ` Jamie Lokier
2009-09-23 18:45 ` Paolo Bonzini
2009-09-23 16:01 ` [Qemu-devel] " Markus Armbruster
2009-09-23 16:11 ` Luiz Capitulino
2009-09-23 18:15 ` Jamie Lokier
2009-09-23 18:18 ` Anthony Liguori
2009-09-23 17:08 ` Daniel P. Berrange
2009-09-23 19:07 ` Luiz Capitulino
2009-09-23 14:18 ` Luiz Capitulino
2009-09-23 18:21 ` Anthony Liguori
2009-09-23 10:08 ` Daniel P. Berrange
2009-09-23 14:21 ` Luiz Capitulino
2009-09-23 15:55 ` Markus Armbruster
2009-09-23 22:37 ` Markus Armbruster
2009-09-24 12:31 ` Luiz Capitulino
2009-09-24 12:44 ` Avi Kivity
2009-09-24 13:05 ` Luiz Capitulino
2009-09-24 13:07 ` Avi Kivity
2009-09-24 13:14 ` Luiz Capitulino
2009-11-11 9:59 ` [Qemu-devel] " Michael S. Tsirkin
2009-09-24 13:28 ` [Qemu-devel] " Markus Armbruster
2009-09-24 19:09 ` Luiz Capitulino
2009-11-11 10:03 ` [Qemu-devel] " Michael S. Tsirkin
2009-11-13 8:38 ` Markus Armbruster
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=1253719181.24147.84.camel@localhost.localdomain \
--to=nathan@parenthephobia.org.uk \
--cc=avi@redhat.com \
--cc=bonzini@gnu.org \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).