On Tue, Jan 18, 2022 at 08:07:32PM -0500, John Snow wrote:
> On Tue, Jan 18, 2022 at 5:01 AM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > With the current 'qmp-shell' tool developers must first spawn QEMU with
> > a suitable -qmp arg and then spawn qmp-shell in a separate terminal
> > pointing to the right socket.
> >
> > With 'qmp-shell-wrap' developers can ignore QMP sockets entirely and
> > just pass the QEMU command and arguments they want. The program will
> > listen on a UNIX socket and tell QEMU to connect QMP to that.
> >
> > For example, this:
> >
> > # qmp-shell-wrap -- qemu-system-x86_64 -display none
> >
> > Is roughly equivalent of running:
> >
> > # qemu-system-x86_64 -display none -qmp qmp-shell-1234 &
> > # qmp-shell qmp-shell-1234
> >
> > Except that 'qmp-shell-wrap' switches the socket peers around so that
> > it is the UNIX socket server and QEMU is the socket client. This makes
> > QEMU reliably go away when qmp-shell-wrap exits, closing the server
> > socket.
> >
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>
> Thanks, I think this is pretty useful.
>
> Can you look at setup.cfg and see about adding a qmp-shell-wrap entry
> point there? I had intended to wean people off of using /scripts for
> things that rely on the QMP packages, because I'm gonna fork them out
> and then these little forwards won't work without installing something
> anyway.
This looks simple enough but when I test I can't actuall get any of
the existing programs to work this way.
I did:
$ python setup.py install --user
...snip...
Processing qemu-0.6.1.0a1-py3.10.egg
Copying qemu-0.6.1.0a1-py3.10.egg to /home/berrange/.local/lib/python3.10/site-packages
Adding qemu 0.6.1.0a1 to easy-install.pth file
Installing aqmp-tui script to /home/berrange/.local/bin
Installing qemu-ga-client script to /home/berrange/.local/bin
Installing qmp-shell script to /home/berrange/.local/bin
Installing qmp-shell-wrap script to /home/berrange/.local/bin
Installing qom script to /home/berrange/.local/bin
Installing qom-fuse script to /home/berrange/.local/bin
Installing qom-get script to /home/berrange/.local/bin
Installing qom-list script to /home/berrange/.local/bin
Installing qom-set script to /home/berrange/.local/bin
Installing qom-tree script to /home/berrange/.local/bin
Installed /home/berrange/.local/lib/python3.10/site-packages/qemu-0.6.1.0a1-py3.10.egg
Processing dependencies for qemu==0.6.1.0a1
Finished processing dependencies for qemu==0.6.1.0a1
$ export PYTHONPATH=/home/berrange/.local/lib/python3.10/site-packages
$ qmp-shell
$ qmp-shell
Traceback (most recent call last):
File "/home/berrange/.local/bin/qmp-shell", line 33, in <module>
sys.exit(load_entry_point('qemu==0.6.1.0a1', 'console_scripts', 'qmp-shell')())
File "/home/berrange/.local/bin/qmp-shell", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib64/python3.10/importlib/metadata/__init__.py", line 162, in load
module = import_module(match.group('module'))
File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'qemu'
I can't see why this is failing to find 'qemu' when it exists fine:
$ python
>>> import qemu.aqmp.qmp_shell
>>> qemu.aqmp.qmp_shell.main()
usage: [-h] [-H] [-N] [-v] [-p] [-l LOGFILE] qmp_server
: error: the following arguments are required: qmp_server
Why is 'load_entry_point' unhappy ?
I'm sorry, I'm not sure.
It may be because you installed via setup.py instead of pip ... I always use pip. "Eventually" setup.py is going away, but there's some reasons I haven't dropped it for QEMU yet. (Our long support tail for RHEL.)
(I don't know if that's the reason, I'll test. If it is the reason, I'll see if there's some way to guard against this in the future.)
I see you've posted a new version, I'll test with that version and if you don't mind, if there's any small problem I'll just modify it for the PR myself, and you can review the changes and I'll get you on your way quicker.
Thanks (and sorry for so many long emails lately),
--js