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
|
2010-08-20 21:42:32 +02:00
|
|
|
o qmp-commands.txt QMP supported commands (auto-generated at build-time)
|
2010-05-31 19:43:31 +02:00
|
|
|
o qmp-events.txt List of available asynchronous events
|
2009-11-27 01:59:06 +01:00
|
|
|
|
|
|
|
[1] http://www.json.org
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-09-10 23:15:49 +02:00
|
|
|
$ qemu [...] -qmp tcp:localhost:4444,server,nowait
|
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 \
|
|
|
|
-chardev socket,id=mon1,host=localhost,port=4444,server,nowait \
|
|
|
|
-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": {
|
|
|
|
"micro": 50,
|
|
|
|
"minor": 6,
|
|
|
|
"major": 1
|
|
|
|
},
|
|
|
|
"package": ""
|
|
|
|
},
|
|
|
|
"capabilities": [
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Please, refer to the qapi-schema.json file for a complete command reference.
|
|
|
|
|
|
|
|
QMP wiki page
|
|
|
|
-------------
|
2009-11-27 01:59:06 +01:00
|
|
|
|
2013-10-11 14:52:38 +02:00
|
|
|
http://wiki.qemu-project.org/QMP
|