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