I'm pleased to announce the very first version of the standalone QMP library for Python, "qemu.qmp".
PyPI: https://pypi.org/project/qemu.qmp/ Docs: https://qemu-project.gitlab.io/python-qemu-qmp/ Source: https://gitlab.com/qemu-project/python-qemu-qmp This library is identical to the one currently in the QEMU repo, with a generous helping of extra GitLab CI rules and PyPI packaging scripts. In 2021, the QMP library originally written by Luiz Capitulino was re-written from the ground up to include native support for Python asyncio, which brings along with it some new features and characteristics: - Full, native support for Python asyncio - True asynchronous event handling and full-duplex communication - Arbitrary numbers of separate event-handling queues (EventListener objects) - Support for out-of-band execution - Continued support for QEMU Guest Agent - Robust error detection and error reporting mechanisms - Semantic error classes for simplified client writing - Extensible callback hooks for logging and rewriting I/O messages - Support for Python 3.6 through the upcoming Python 3.11 - Unit testing of the library itself provided by Avocado Framework - Compatibility with Luiz's QMP library provided by a synchronous shim class - Fully statically typed using Python 3.6 type hints and validated with mypy - PEP 561 compliant export of static typing information for client packages - Rigorously documented API, including all error pathways and exceptions - *Zero* mandatory dependencies! This is all Python stdlib native. - LGPLv2+ license for easier external integration. - Fully self-contained repository with all publishing and packaging scripts included. - qmp-shell and qmp-shell-wrap convenience/debugging utilities are included - An early alpha version of qmp-tui which has support for displaying asynchronous events is also included. This is the version authored by Niteesh for Summer 2021's GSoC session. - Extensible "AsyncProtocol" class that can be used to implement QTEST or other full-duplex, asynchronous message-based protocols. - Native GitLab merge request contributor workflow for ease of contribution by newer, casual contributors. Merge request announcements are automatically relayed to the qemu-devel list via GitLab webhook integrations so that core QEMU developers don't miss out on development activity. Cool, in my opinion! This library has been the provider of QMP support for all of our Python tests in qemu.git for about two releases now, so we've already been using it for some time. I would be flattered if you didn't even notice. Some other features that are in a draft state and need polish, docs, and review, but do exist; - A fully statically typed implementation of the qtest protocol built on top of AsyncProtocol - An extensible implementation of a complete QMP server, useful for acting as a debugging proxy to a QMP server, unit testing of the QMP library itself, or for more meticulous unit testing of other QMP clients. With the first official release of this library now published, attention will shift to integrating this library back into qemu.git, ensuring that both internal and external projects benefit from the same library. Please check out the README visible from PyPI, the source repository, or the documentation site for more information; see the issue tracker for pending issues and enhancements, or refer to the project milestones on GitLab[1] for future roadmap information on this mini-project. Thanks to everyone that helped get to this point; in no particular order: Luiz, Hanna, Kevin, Vladimir, Kashyap, Eduardo, Cleber, Daniel, Niteesh, Willian, Beraldo, Wainer, Thomas, Eric, Paolo, Stefan, Andrea, and Victor. Thanks to my friends outside of work for their help, too; thanks Mike J.! Enjoy! --John Snow [1] https://gitlab.com/qemu-project/python-qemu-qmp/-/milestones