Registry / devops / qmp
library1.1.0pypypi✓ verified 86d ago

qmp is a Python client library for the QEMU Machine Protocol (QMP), used to interact with QEMU virtual machines programmatically. The current version is 1.1.0, supported on Python >=3.6. The library is mature but sees infrequent releases.

pip install qmp
INSTALL
IMPORT
SIG · QMP
Q
qmp
devopspythonv1.1.0
Install
1.5s avg
Import
32ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.032s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.032s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QEMUMonitorProtocol
from qmp import QEMUMonitorProtocol
from qmp.qmp import QEMUMonitorProtocol
In v1.x, the class is directly exposed at the package level. Old imports from .qmp submodule may fail.

Connect to a running QEMU instance via a Unix socket and execute a QMP command.

from qmp import QEMUMonitorProtocol # Connect to QEMU over a Unix socket sock_path = '/tmp/qemu.sock' # or os.environ.get('QEMU_SOCK', '/tmp/qemu.sock') try: qmp = QEMUMonitorProtocol(sock_path) qmp.connect() # Send a QMP command result = qmp.command('query-status') print(result) finally: qmp.close()
Debug
Known issues
breakingPython 3.6 is the minimum required version; Python 2 is not supported. Using with Python <3.6 will cause syntax errors.
fix
Use Python >=3.6.
affects: <1.0? (pre-1.0 versions may have supported Python 2)
gotchaThe connect() method blocks until the connection is established. If QEMU is not ready or the socket path is wrong, it may hang indefinitely.
fix
Use connect() with a timeout (e.g., via socket timeout) or implement async connect; qmp does not natively support timeouts.
affects: all
gotchaCommands expecting a 'return' key in the response may fail if the QMP event is a 'QMP' greeting or an error. Always check the response for success.
fix
Always handle 'error' key in response dictionary, or use qmp.command() which raises QMPError on failure (but only for QMP-level errors).
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'qmp'
The library is not installed or the wrong package name is used (e.g., trying `import qemu`).
fix
Run `pip install qmp` and use `from qmp import QEMUMonitorProtocol`.
AttributeError: module 'qmp' has no attribute 'QEMUMonitorProtocol'
Trying to import from an old submodule path (e.g., `from qmp.qmp import QEMUMonitorProtocol`).
fix
Use `from qmp import QEMUMonitorProtocol` directly.
qmp.QMPError: [Errno 111] Connection refused
The QEMU socket path does not exist or QEMU is not running.
fix
Verify the socket path (e.g., check QEMU startup logs) and ensure QEMU is started with '-qmp unix:/tmp/qemu.sock,server,nowait'.
Upgrade
Version history
1.1.0latest on PyPI · released Jul 8, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Amazon
1
Resources
qmp — pip install qmp · libregistry