On 3/16/22 11:24, Daniel P. Berrangé wrote:
On Wed, Mar 16, 2022 at 10:54:55AM +0100, Damien Hedde wrote:
It takes an input file containing raw qmp commands (concatenated json
dicts) and send all commands one by one to a qmp server. When one
command fails, it exits.

As a convenience, it can also wrap the qemu process to avoid having
to start qemu in background. When wrapping qemu, the program returns
only when the qemu process terminates.

Signed-off-by: Damien Hedde <[email protected]>
---

Hi all,

Following our discussion, I've started this. What do you think ?

I tried to follow Daniel's qmp-shell-wrap. I think it is
better to have similar options (eg: logging). There is also room
for factorizing code if we want to keep them aligned and ease
maintenance.

Having CLI similarity to the existing scripts is a good idea.

As a proof of usefulness, it might be worth trying to illustrate
this qmp-send command by converting an I/O test.

Quite a few I/O tests have code that look like:

do_run_qemu()
{
     echo Testing: "$@" | _filter_imgfmt
     $QEMU -nographic -qmp stdio -serial none "$@"
     echo
}


run_qemu()
{
     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | 
_filter_qemu_io
}

run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
    ....
}
{ "execute": "quit" }
EOF

(eg iotests 71)

I would hope this qmp-send command to be able to satisfy that
use case by modifying do_run_qemu like this:

do_run_qemu()
{
     echo Testing: "$@" | _filter_imgfmt
     qmp-send --wrap $QEMU -nographic -serial none "$@"
     echo
}

I need to add stdin handling, but it should be straightforward.

I'm more worried by what should happen if there is a failure that makes qemu hang, because then run_qemu won't exit. I'll take a look at the iotest. I expect the test will be killed at some point, I need to ensure that part is handled properly by qmp-send.

Thanks,
Damien

Reply via email to