From: Damien Hedde <damien.hedde@greensocs.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>,
"John Snow" <jsnow@redhat.com>
Cc: Eduardo Habkost <eduardo@habkost.net>,
qemu-devel <qemu-devel@nongnu.org>,
Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH 4/5] python: qmp_shell: add -e/--exit-on-error option
Date: Wed, 23 Feb 2022 17:46:40 +0100 [thread overview]
Message-ID: <8836d74b-2803-61b3-1def-67e6eaab3f8b@greensocs.com> (raw)
In-Reply-To: <58ba5bf4-b374-31f6-ae8a-556418cedbfc@greensocs.com>
On 2/23/22 17:43, Damien Hedde wrote:
>
>
> On 2/23/22 16:44, Daniel P. Berrangé wrote:
>> On Wed, Feb 23, 2022 at 10:41:11AM -0500, John Snow wrote:
>>> On Wed, Feb 23, 2022 at 10:27 AM Daniel P. Berrangé
>>> <berrange@redhat.com> wrote:
>>>>
>>>> On Wed, Feb 23, 2022 at 10:22:11AM -0500, John Snow wrote:
>>>>> On Mon, Feb 21, 2022 at 10:55 AM Damien Hedde
>>>>> <damien.hedde@greensocs.com> wrote:
>>>>>>
>>>>>> This option makes qmp_shell exit (with error code 1)
>>>>>> as soon as one of the following error occurs:
>>>>>> + command parsing error
>>>>>> + disconnection
>>>>>> + command failure (response is an error)
>>>>>>
>>>>>> _execute_cmd() method now returns None or the response
>>>>>> so that read_exec_command() can do the last check.
>>>>>>
>>>>>> This is meant to be used in combination with an input file
>>>>>> redirection. It allows to store a list of commands
>>>>>> into a file and try to run them by qmp_shell and easily
>>>>>> see if it failed or not.
>>>>>>
>>>>>> Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
>>>>>
>>>>> Based on this patch, it looks like you really want something
>>>>> scriptable, so I think the qemu-send idea that Dan has suggested might
>>>>> be the best way to go. Are you still hoping to use the interactive
>>>>> "short" QMP command format? That might be a bad idea, given how flaky
>>>>> the parsing is -- and how we don't actually have a published standard
>>>>> for that format. We've *never* liked the bad parsing here, so I have a
>>>>> reluctance to use it in more places.
>
> I don't really care of the command format. I was just using the one
> expected by qmp-shell to avoid providing another script.
> I think it's better not to use some standard syntax like json.
I wanted to say the opposite: it's best to use json.
> As long as we can store the commands into a file and tests them easily,
> it's ok. The crucial feature is the "stop as soon something unexpected
> happens" so that we can easily spot an issue.
>>>>>
>>>>> I'm having the naive idea that a script file could be as simple as a
>>>>> list of QMP commands to send:
>>>>>
>>>>> [
>>>>> {"execute": "block-dirty-bitmap-add", "arguments": { ... }},
>>>>> ...
>>>>> ]
>
> I used this format at some point because it's so trivial to feed into
> the QMP tools. Even used a yaml version of that to get the "human
> readability" that goes with it.
>
>>>>
>>>> I'd really recommend against creating a new format for the script
>>>> file, especially one needing opening & closing [] like this, as
>>>> that isn't so amenable to dynamic usage/creation. ie you can't
>>>> just append an extcra command to an existing file.
>>>>
>>>> IMHO, the "file" format should be identical to the result of
>>>> capturing the socket data off the wire. ie just a concatenation
>>>> of QMP commands, with no extra wrapping / change in format.
>>>> >>
>>> Eugh. That's just so hard to parse, because there's no off-the-shelf
>>> tooling for "load a sequence of JSON documents". Nothing in Python
>>> does it. :\
>>
>> It isn't that hard if you require each JSON doc to be followed by
>> a newline.
>>
>> Feed one line at a time to the JSON parser, until you get a complete
>> JSON doc, process that, then re-init the parser and carry on feeding
>> it lines until it emits the next JSON doc, and so on.
>>
>
> I agree it's doable. I can look into that.
>
> It makes me think that I've managed to modify the chardev 'file' backend
> a few months ago so that it can be used with an input file on the cli.
> This allowed to give such raw qmp file directly with the -qmp option
> instead of using an intermediate socket and a script issuing the same file.
> But I gave up with this approach because then it can't stop if a command
> failed without hacking into the receiving side in qemu.
>
> --
> Damien
>
>
>
next prev parent reply other threads:[~2022-02-23 16:55 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 15:55 [PATCH 0/5] qmp-shell modifications for non-interactive use Damien Hedde
2022-02-21 15:55 ` [PATCH 1/5] python: qmp_shell: don't prompt when stdin is non-interactive Damien Hedde
2022-02-21 15:55 ` [PATCH 2/5] python: qmp_shell: refactor the parsing error handling Damien Hedde
2022-02-21 15:55 ` [PATCH 3/5] python: qmp_shell: refactor disconnection handling Damien Hedde
2022-02-21 15:55 ` [PATCH 4/5] python: qmp_shell: add -e/--exit-on-error option Damien Hedde
2022-02-23 15:22 ` John Snow
2022-02-23 15:27 ` Daniel P. Berrangé
2022-02-23 15:41 ` John Snow
2022-02-23 15:44 ` Daniel P. Berrangé
2022-02-23 16:18 ` John Snow
2022-02-23 17:09 ` Damien Hedde
2022-02-23 18:20 ` John Snow
2022-02-24 11:20 ` Damien Hedde
2022-02-23 17:50 ` Daniel P. Berrangé
2022-02-23 16:43 ` Damien Hedde
2022-02-23 16:46 ` Damien Hedde [this message]
2022-02-21 15:55 ` [PATCH 5/5] python: qmp_shell: handle comment lines and escaped eol Damien Hedde
2022-02-22 6:10 ` [PATCH 0/5] qmp-shell modifications for non-interactive use Markus Armbruster
2022-02-22 7:57 ` Damien Hedde
2022-02-22 9:21 ` Daniel P. Berrangé
2022-02-22 9:38 ` Damien Hedde
2022-02-22 10:31 ` Daniel P. Berrangé
2022-02-23 9:57 ` Damien Hedde
2022-02-23 11:13 ` Daniel P. Berrangé
2022-02-23 15:01 ` John Snow
2022-02-23 15:08 ` Daniel P. Berrangé
2022-02-22 9:52 ` Markus Armbruster
2022-02-25 20:40 ` John Snow
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=8836d74b-2803-61b3-1def-67e6eaab3f8b@greensocs.com \
--to=damien.hedde@greensocs.com \
--cc=berrange@redhat.com \
--cc=crosa@redhat.com \
--cc=eduardo@habkost.net \
--cc=jsnow@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).