[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A brief look at deprecating our JSON extensions over RFC 8259
From: |
Markus Armbruster |
Subject: |
Re: A brief look at deprecating our JSON extensions over RFC 8259 |
Date: |
Tue, 23 Feb 2021 10:06:30 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Paolo Bonzini <pbonzini@redhat.com> writes:
> On 22/02/21 16:24, Daniel P. Berrangé wrote:
>> This problem isn't unique to QEMU. Any app using JSON from the
>> shell will have the tedium of quote escaping. JSON is incredibly
>> widespread and no other apps felt it neccessary to introduce single
>> quoting support, because the benefit doesn't outweigh the interop
>> problem it introduces.
>
> The quotes were introduced for C code (and especially qtest), not for
> the shell. We have something like
>
> response = qmp("{ 'execute': 'qom-get', 'arguments': { 'path': %s, "
> "'property': 'temperature' } }", id);
>
> These are sent to QEMU as double-quoted strings (the single-quoted
> JSON is parsed to get interpolation and printed back; commit
> 563890c7c7, "libqtest: escape strings in QMP commands, fix leak",
> 2014-07-01). However, doing the interpolation requires a parser that
> recognizes the single-quoted strings.
Doing interpolation requires a parser that recognizes %-sequences.
Single quote support isn't *required*, but quite desirable to let us
avoid leaning toothpick syndrome (LTS).
Example: compare the above to
response = qmp("{ \"execute\": \"qom-get\", \"arguments\": { \"path\":
%s, "
"\"property\": \"temperature\" } }", id);
We kept the interpolation extension out of the external interfaces, but
not the single quotes.
> Markus, did you rebuild the qtests after disabling single-quoted
> strings? "make check-qtest-x86_64" would have rebuilt them, but I'm
> confused by the results.
I ran "make check" and looked at the failures:
* check-qjson.c
- escaped_string() covers \'. Naturally, this fails.
- escaped_string() and utf8_string() try every string twice, first in
double quotes, then in single quotes. Naturally, the latter fails.
- string_with_quotes() tests unquoted single quote in double-quoted
string, and unquoted double quote in single-quoted string.
Naturally, the latter fails.
- large_dict() and simple_whitespace() use single quotes to avoid LTS.
This is the test my "The unit test testing the JSON parser is of
course excused" referred to.
* test-qobject-input-visitor.c
* qtest/qmp-test.c
More LTS avoidance.
This is "The remaining qtest and the unit test could perhaps be
dismissed as atypical use of QEMU from C."
* tests/qemu-iotests/
Unlike the tests above, these use *external* interfaces.
In shell, we need to use double quotes to get parameter expansion. We
then use single quotes to avoid LTS.
The Python code has less excuse, I think.
Still confused?
- Re: A brief look at deprecating our JSON extensions over RFC 8259, (continued)
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Peter Krempa, 2021/02/22
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Daniel P . Berrangé, 2021/02/22
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Liviu Ionescu, 2021/02/22
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Paolo Bonzini, 2021/02/22
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Daniel P . Berrangé, 2021/02/22
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Paolo Bonzini, 2021/02/22
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Markus Armbruster, 2021/02/23
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Markus Armbruster, 2021/02/23
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Peter Maydell, 2021/02/23
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Markus Armbruster, 2021/02/23
- Re: A brief look at deprecating our JSON extensions over RFC 8259,
Markus Armbruster <=
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Paolo Bonzini, 2021/02/23
- Re: A brief look at deprecating our JSON extensions over RFC 8259, Markus Armbruster, 2021/02/23
Re: A brief look at deprecating our JSON extensions over RFC 8259, Paolo Bonzini, 2021/02/22