[PATCH v3 0/2] python: a few improvements to qmp-shell

Daniel P. Berrangé posted 2 patches 2 years, 3 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220128161157.36261-1-berrange@redhat.com
python/qemu/aqmp/qmp_shell.py | 88 ++++++++++++++++++++++++++++++++---
python/setup.cfg              |  4 ++
scripts/qmp/qmp-shell-wrap    | 11 +++++
3 files changed, 96 insertions(+), 7 deletions(-)
create mode 100755 scripts/qmp/qmp-shell-wrap
[PATCH v3 0/2] python: a few improvements to qmp-shell
Posted by Daniel P. Berrangé 2 years, 3 months ago
This makes the qmp-shell program a little more pleasant to use when you
are just trying to spawn a throw-away QEMU process to query some info
from.

First it introduces a 'qmp-shell-wrap' command that takes a QEMU command
line instead of QMP socket, and spawns QEMU automatically, so its life
is tied to that of the shell.

Second it adds ability to log QMP commands/responses to a file that can
be queried with 'jq' to extract information. This is good for commands
which return huge JSON docs.

In v3:

 - Add qmp-shell-wrap to setup.cfg entry points

In v2:

 - Unlink unix socket path on exit
 - Fix default command name
 - Deal with flake8/pylint warnings

Daniel P. Berrangé (2):
  python: introduce qmp-shell-wrap convenience tool
  python: support recording QMP session to a file

 python/qemu/aqmp/qmp_shell.py | 88 ++++++++++++++++++++++++++++++++---
 python/setup.cfg              |  4 ++
 scripts/qmp/qmp-shell-wrap    | 11 +++++
 3 files changed, 96 insertions(+), 7 deletions(-)
 create mode 100755 scripts/qmp/qmp-shell-wrap

-- 
2.34.1



Re: [PATCH v3 0/2] python: a few improvements to qmp-shell
Posted by John Snow 2 years, 2 months ago
On Fri, Jan 28, 2022 at 11:12 AM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> This makes the qmp-shell program a little more pleasant to use when you
> are just trying to spawn a throw-away QEMU process to query some info
> from.
>
> First it introduces a 'qmp-shell-wrap' command that takes a QEMU command
> line instead of QMP socket, and spawns QEMU automatically, so its life
> is tied to that of the shell.
>
> Second it adds ability to log QMP commands/responses to a file that can
> be queried with 'jq' to extract information. This is good for commands
> which return huge JSON docs.
>
> In v3:
>
>  - Add qmp-shell-wrap to setup.cfg entry points
>
> In v2:
>
>  - Unlink unix socket path on exit
>  - Fix default command name
>  - Deal with flake8/pylint warnings
>
> Daniel P. Berrangé (2):
>   python: introduce qmp-shell-wrap convenience tool
>   python: support recording QMP session to a file
>
>  python/qemu/aqmp/qmp_shell.py | 88 ++++++++++++++++++++++++++++++++---
>  python/setup.cfg              |  4 ++
>  scripts/qmp/qmp-shell-wrap    | 11 +++++
>  3 files changed, 96 insertions(+), 7 deletions(-)
>  create mode 100755 scripts/qmp/qmp-shell-wrap
>
> --
> 2.34.1
>
>

Great, thanks! I rebased patch 1/2 myself as a courtesy and have staged these.

--js

(fwiw: using pip, it seems like the wrapper script works just fine. it
appears as though using 'python3 setup.py install' does indeed cause
issues here. I have a patch I'll send soon that discourages the direct
setup.py invocation to avoid frustration in the future.)


Re: [PATCH v3 0/2] python: a few improvements to qmp-shell
Posted by Daniel P. Berrangé 2 years, 2 months ago
On Mon, Feb 07, 2022 at 04:05:47PM -0500, John Snow wrote:
> On Fri, Jan 28, 2022 at 11:12 AM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > This makes the qmp-shell program a little more pleasant to use when you
> > are just trying to spawn a throw-away QEMU process to query some info
> > from.
> >
> > First it introduces a 'qmp-shell-wrap' command that takes a QEMU command
> > line instead of QMP socket, and spawns QEMU automatically, so its life
> > is tied to that of the shell.
> >
> > Second it adds ability to log QMP commands/responses to a file that can
> > be queried with 'jq' to extract information. This is good for commands
> > which return huge JSON docs.
> >
> > In v3:
> >
> >  - Add qmp-shell-wrap to setup.cfg entry points
> >
> > In v2:
> >
> >  - Unlink unix socket path on exit
> >  - Fix default command name
> >  - Deal with flake8/pylint warnings
> >
> > Daniel P. Berrangé (2):
> >   python: introduce qmp-shell-wrap convenience tool
> >   python: support recording QMP session to a file
> >
> >  python/qemu/aqmp/qmp_shell.py | 88 ++++++++++++++++++++++++++++++++---
> >  python/setup.cfg              |  4 ++
> >  scripts/qmp/qmp-shell-wrap    | 11 +++++
> >  3 files changed, 96 insertions(+), 7 deletions(-)
> >  create mode 100755 scripts/qmp/qmp-shell-wrap
> >
> > --
> > 2.34.1
> >
> >
> 
> Great, thanks! I rebased patch 1/2 myself as a courtesy and have staged these.
> 
> --js
> 
> (fwiw: using pip, it seems like the wrapper script works just fine. it
> appears as though using 'python3 setup.py install' does indeed cause
> issues here. I have a patch I'll send soon that discourages the direct
> setup.py invocation to avoid frustration in the future.)

I've only ever used  pip to install from pypi or remote git archives.
How do you use it to install from your local git checkout

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH v3 0/2] python: a few improvements to qmp-shell
Posted by John Snow 2 years, 2 months ago
On Tue, Feb 8, 2022, 3:56 AM Daniel P. Berrangé <berrange@redhat.com> wrote:

> On Mon, Feb 07, 2022 at 04:05:47PM -0500, John Snow wrote:
> > On Fri, Jan 28, 2022 at 11:12 AM Daniel P. Berrangé <berrange@redhat.com>
> wrote:
> > >
> > > This makes the qmp-shell program a little more pleasant to use when you
> > > are just trying to spawn a throw-away QEMU process to query some info
> > > from.
> > >
> > > First it introduces a 'qmp-shell-wrap' command that takes a QEMU
> command
> > > line instead of QMP socket, and spawns QEMU automatically, so its life
> > > is tied to that of the shell.
> > >
> > > Second it adds ability to log QMP commands/responses to a file that can
> > > be queried with 'jq' to extract information. This is good for commands
> > > which return huge JSON docs.
> > >
> > > In v3:
> > >
> > >  - Add qmp-shell-wrap to setup.cfg entry points
> > >
> > > In v2:
> > >
> > >  - Unlink unix socket path on exit
> > >  - Fix default command name
> > >  - Deal with flake8/pylint warnings
> > >
> > > Daniel P. Berrangé (2):
> > >   python: introduce qmp-shell-wrap convenience tool
> > >   python: support recording QMP session to a file
> > >
> > >  python/qemu/aqmp/qmp_shell.py | 88 ++++++++++++++++++++++++++++++++---
> > >  python/setup.cfg              |  4 ++
> > >  scripts/qmp/qmp-shell-wrap    | 11 +++++
> > >  3 files changed, 96 insertions(+), 7 deletions(-)
> > >  create mode 100755 scripts/qmp/qmp-shell-wrap
> > >
> > > --
> > > 2.34.1
> > >
> > >
> >
> > Great, thanks! I rebased patch 1/2 myself as a courtesy and have staged
> these.
> >
> > --js
> >
> > (fwiw: using pip, it seems like the wrapper script works just fine. it
> > appears as though using 'python3 setup.py install' does indeed cause
> > issues here. I have a patch I'll send soon that discourages the direct
> > setup.py invocation to avoid frustration in the future.)
>
> I've only ever used  pip to install from pypi or remote git archives.
> How do you use it to install from your local git checkout
>

cd ~/src/qemu/python
pip install [-e] [--user] .

See python/README.rst:  https://gitlab.com/jsnow/qemu/-/tree/master/python

I've also sent a patch that disables the broken method (and explains why
it's broken), see

https://patchew.org/QEMU/20220207213039.2278569-1-jsnow@redhat.com/

thanks!
--js


> Regards,
> Daniel
> --
> |: https://berrange.com      -o-
> https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-
> https://www.instagram.com/dberrange :|
>
>