qmp-intro.txt 2.1 KB
Newer Older
L
Luiz Capitulino 已提交
1
                          QEMU Machine Protocol
L
Luiz Capitulino 已提交
2 3 4
                          =====================

Introduction
L
Luiz Capitulino 已提交
5
------------
L
Luiz Capitulino 已提交
6

L
Luiz Capitulino 已提交
7 8
The QEMU Machine Protocol (QMP) allows applications to operate a
QEMU instance.
L
Luiz Capitulino 已提交
9

L
Luiz Capitulino 已提交
10
QMP is JSON[1] based and features the following:
L
Luiz Capitulino 已提交
11 12

- Lightweight, text-based, easy to parse data format
L
Luiz Capitulino 已提交
13 14
- Asynchronous messages support (ie. events)
- Capabilities Negotiation
L
Luiz Capitulino 已提交
15

L
Luiz Capitulino 已提交
16
For detailed information on QMP's usage, please, refer to the following files:
L
Luiz Capitulino 已提交
17

L
Luiz Capitulino 已提交
18
o qmp-spec.txt      QEMU Machine Protocol current specification
19
o qemu-qmp-ref.html QEMU QMP commands and events (auto-generated at build-time)
L
Luiz Capitulino 已提交
20 21 22 23 24 25

[1] http://www.json.org

Usage
-----

L
Luiz Capitulino 已提交
26 27
You can use the -qmp option to enable QMP. For example, the following
makes QMP available on localhost port 4444:
L
Luiz Capitulino 已提交
28

L
Luiz Capitulino 已提交
29
$ qemu [...] -qmp tcp:localhost:4444,server,nowait
L
Luiz Capitulino 已提交
30

L
Luiz Capitulino 已提交
31 32 33 34
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:
L
Luiz Capitulino 已提交
35

L
Luiz Capitulino 已提交
36 37 38
$ 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
L
Luiz Capitulino 已提交
39

L
Luiz Capitulino 已提交
40
Please, refer to QEMU's manpage for more information.
L
Luiz Capitulino 已提交
41 42 43 44

Simple Testing
--------------

L
Luiz Capitulino 已提交
45
To manually test QMP one can connect with telnet and issue commands by hand:
L
Luiz Capitulino 已提交
46 47

$ telnet localhost 4444
L
Luiz Capitulino 已提交
48
Trying 127.0.0.1...
L
Luiz Capitulino 已提交
49 50
Connected to localhost.
Escape character is '^]'.
L
Luiz Capitulino 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64
{
    "QMP": {
        "version": {
            "qemu": {
                "micro": 50, 
                "minor": 6, 
                "major": 1
            }, 
            "package": ""
        }, 
        "capabilities": [
        ]
    }
}
L
Luiz Capitulino 已提交
65

L
Luiz Capitulino 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
{ "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
-------------
L
Luiz Capitulino 已提交
85

S
Stefan Hajnoczi 已提交
86
http://wiki.qemu-project.org/QMP