2013-09-10 23:15:49 +02:00
|
|
|
QEMU Machine Protocol
|
2009-11-27 01:59:06 +01:00
|
|
|
=====================
|
|
|
|
|
|
|
|
Introduction
|
2013-09-10 23:15:49 +02:00
|
|
|
------------
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
The QEMU Machine Protocol (QMP) allows applications to operate a
|
|
|
|
QEMU instance.
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
QMP is JSON[1] based and features the following:
|
2009-12-18 16:25:02 +01:00
|
|
|
|
|
|
|
- Lightweight, text-based, easy to parse data format
|
2010-08-20 21:42:32 +02:00
|
|
|
- Asynchronous messages support (ie. events)
|
|
|
|
- Capabilities Negotiation
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2010-08-20 21:42:32 +02:00
|
|
|
For detailed information on QMP's usage, please, refer to the following files:
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
o qmp-spec.txt QEMU Machine Protocol current specification
|
2017-01-13 15:41:35 +01:00
|
|
|
o qemu-qmp-ref.html QEMU QMP commands and events (auto-generated at build-time)
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2017-11-21 13:04:35 +01:00
|
|
|
[1] https://www.json.org
|
2009-11-27 01:59:06 +01:00
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
You can use the -qmp option to enable QMP. For example, the following
|
|
|
|
makes QMP available on localhost port 4444:
|
2010-08-20 21:42:32 +02:00
|
|
|
|
2021-02-16 20:10:24 +01:00
|
|
|
$ qemu [...] -qmp tcp:localhost:4444,server=on,wait=off
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
However, for more flexibility and to make use of more options, the -mon
|
|
|
|
command-line option should be used. For instance, the following example
|
|
|
|
creates one HMP instance (human monitor) on stdio and one QMP instance
|
|
|
|
on localhost port 4444:
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
$ qemu [...] -chardev stdio,id=mon0 -mon chardev=mon0,mode=readline \
|
2021-02-16 20:10:24 +01:00
|
|
|
-chardev socket,id=mon1,host=localhost,port=4444,server=on,wait=off \
|
2013-09-10 23:15:49 +02:00
|
|
|
-mon chardev=mon1,mode=control,pretty=on
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2010-08-20 21:42:32 +02:00
|
|
|
Please, refer to QEMU's manpage for more information.
|
2009-12-18 16:25:02 +01:00
|
|
|
|
|
|
|
Simple Testing
|
|
|
|
--------------
|
|
|
|
|
2010-08-20 21:42:32 +02:00
|
|
|
To manually test QMP one can connect with telnet and issue commands by hand:
|
2009-11-27 01:59:06 +01:00
|
|
|
|
|
|
|
$ telnet localhost 4444
|
2009-12-18 16:25:02 +01:00
|
|
|
Trying 127.0.0.1...
|
2009-11-27 01:59:06 +01:00
|
|
|
Connected to localhost.
|
|
|
|
Escape character is '^]'.
|
2013-09-10 23:15:49 +02:00
|
|
|
{
|
|
|
|
"QMP": {
|
|
|
|
"version": {
|
|
|
|
"qemu": {
|
2018-07-03 10:53:29 +02:00
|
|
|
"micro": 0,
|
|
|
|
"minor": 0,
|
|
|
|
"major": 3
|
|
|
|
},
|
|
|
|
"package": "v3.0.0"
|
|
|
|
},
|
2013-09-10 23:15:49 +02:00
|
|
|
"capabilities": [
|
2018-07-03 10:53:29 +02:00
|
|
|
"oob"
|
2013-09-10 23:15:49 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2010-08-20 21:42:32 +02:00
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
{ "execute": "qmp_capabilities" }
|
|
|
|
{
|
|
|
|
"return": {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{ "execute": "query-status" }
|
|
|
|
{
|
|
|
|
"return": {
|
|
|
|
"status": "prelaunch",
|
|
|
|
"singlestep": false,
|
|
|
|
"running": false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-11 10:36:04 +01:00
|
|
|
Please refer to docs/interop/qemu-qmp-ref.* for a complete command
|
2018-02-11 10:36:05 +01:00
|
|
|
reference, generated from qapi/qapi-schema.json.
|
2013-09-10 23:15:49 +02:00
|
|
|
|
|
|
|
QMP wiki page
|
|
|
|
-------------
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2017-11-21 13:04:35 +01:00
|
|
|
https://wiki.qemu.org/QMP
|