2013-09-11 05:15:49 +08:00
|
|
|
QEMU Machine Protocol
|
2009-11-27 08:59:06 +08:00
|
|
|
=====================
|
|
|
|
|
|
|
|
Introduction
|
2013-09-11 05:15:49 +08:00
|
|
|
------------
|
2009-11-27 08:59:06 +08:00
|
|
|
|
2013-09-11 05:15:49 +08:00
|
|
|
The QEMU Machine Protocol (QMP) allows applications to operate a
|
|
|
|
QEMU instance.
|
2009-11-27 08:59:06 +08:00
|
|
|
|
2013-09-11 05:15:49 +08:00
|
|
|
QMP is JSON[1] based and features the following:
|
2009-12-18 23:25:02 +08:00
|
|
|
|
|
|
|
- Lightweight, text-based, easy to parse data format
|
2010-08-21 03:42:32 +08:00
|
|
|
- Asynchronous messages support (ie. events)
|
|
|
|
- Capabilities Negotiation
|
2009-11-27 08:59:06 +08:00
|
|
|
|
2010-08-21 03:42:32 +08:00
|
|
|
For detailed information on QMP's usage, please, refer to the following files:
|
2009-11-27 08:59:06 +08:00
|
|
|
|
2013-09-11 05:15:49 +08:00
|
|
|
o qmp-spec.txt QEMU Machine Protocol current specification
|
2010-08-21 03:42:32 +08:00
|
|
|
o qmp-commands.txt QMP supported commands (auto-generated at build-time)
|
2010-06-01 01:43:31 +08:00
|
|
|
o qmp-events.txt List of available asynchronous events
|
2009-11-27 08:59:06 +08:00
|
|
|
|
|
|
|
[1] http://www.json.org
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
2013-09-11 05:15:49 +08:00
|
|
|
You can use the -qmp option to enable QMP. For example, the following
|
|
|
|
makes QMP available on localhost port 4444:
|
2010-08-21 03:42:32 +08:00
|
|
|
|
2013-09-11 05:15:49 +08:00
|
|
|
$ qemu [...] -qmp tcp:localhost:4444,server,nowait
|
2009-11-27 08:59:06 +08:00
|
|
|
|
2013-09-11 05:15:49 +08: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 08:59:06 +08:00
|
|
|
|
2013-09-11 05:15:49 +08: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 08:59:06 +08:00
|
|
|
|
2010-08-21 03:42:32 +08:00
|
|
|
Please, refer to QEMU's manpage for more information.
|
2009-12-18 23:25:02 +08:00
|
|
|
|
|
|
|
Simple Testing
|
|
|
|
--------------
|
|
|
|
|
2010-08-21 03:42:32 +08:00
|
|
|
To manually test QMP one can connect with telnet and issue commands by hand:
|
2009-11-27 08:59:06 +08:00
|
|
|
|
|
|
|
$ telnet localhost 4444
|
2009-12-18 23:25:02 +08:00
|
|
|
Trying 127.0.0.1...
|
2009-11-27 08:59:06 +08:00
|
|
|
Connected to localhost.
|
|
|
|
Escape character is '^]'.
|
2013-09-11 05:15:49 +08:00
|
|
|
{
|
|
|
|
"QMP": {
|
|
|
|
"version": {
|
|
|
|
"qemu": {
|
|
|
|
"micro": 50,
|
|
|
|
"minor": 6,
|
|
|
|
"major": 1
|
|
|
|
},
|
|
|
|
"package": ""
|
|
|
|
},
|
|
|
|
"capabilities": [
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2010-08-21 03:42:32 +08:00
|
|
|
|
2013-09-11 05:15:49 +08:00
|
|
|
{ "execute": "qmp_capabilities" }
|
|
|
|
{
|
|
|
|
"return": {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{ "execute": "query-status" }
|
|
|
|
{
|
|
|
|
"return": {
|
|
|
|
"status": "prelaunch",
|
|
|
|
"singlestep": false,
|
|
|
|
"running": false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Please, refer to the qapi-schema.json file for a complete command reference.
|
|
|
|
|
|
|
|
QMP wiki page
|
|
|
|
-------------
|
2009-11-27 08:59:06 +08:00
|
|
|
|
2013-10-11 20:52:38 +08:00
|
|
|
http://wiki.qemu-project.org/QMP
|