# QEMU Machine Protocol (QMP) socket Start QEMU with QMP UNIX socket and connect: ```bash ./qemu-system-x86_64.exe -qmp unix:test.socket,server,nowait ... nc -U test.socket qmp-shell test.socket # see https://github.com/0xef53/qmp-shell ``` Or start QEMU with QMP TCP socket and connect: ```bash ./qemu-system-x86_64.exe -qmp tcp:127.0.0.1:12345,server,nowait ... nc localhost 12345 ``` # Examples After you open the socket, the first command is always: ```json { "execute": "qmp_capabilities" } ``` Then you can either execute human or machine friendly commands. ## Human friendly commands examples ```json { "execute": "human-monitor-command", "arguments": { "command-line": "help" } } ``` ## Machine friendly commands examples ```json { "execute": "query-qmp-schema" } { "execute": "query-machines" } { "execute": "query-pci" } { "execute": "device-list-properties", "arguments": { "typename": "vmxnet3" } } { "execute": "qom-list", "arguments": { "path": "/" } } { "execute": "qom-list", "arguments": { "path": "/machine" } } { "execute": "qom-get", "arguments": { "path": "/machine", "property": "type" } } { "execute": "qom-list", "arguments": { "path": "/machine/i440fx" } } { "execute": "qom-get", "arguments": { "path": "/machine/i440fx", "property": "type" } } { "execute": "qom-list", "arguments": { "path": "/machine/i440fx/pci.0" } } { "execute": "qom-get", "arguments": { "path": "/machine/i440fx/pci.0", "property": "type" } } { "execute": "qom-list", "arguments": { "path": "/machine/i440fx/pci.0/child[3]" } } { "execute": "qom-get", "arguments": { "path": "/machine/i440fx/pci.0/child[3]", "property": "type" } } { "execute": "qom-get", "arguments": { "path": "/machine/i440fx/pci.0/child[3]", "property": "mac" } } { "execute": "qom-get", "arguments": { "path": "/machine/i440fx/pci.0/child[3]", "property": "netdev" } } { "execute": "qom-get", "arguments": { "path": "/machine/i440fx/pci.0/child[3]", "property": "legacy-addr" } } { "execute": "qom-list", "arguments": { "path": "/machine/peripheral-anon" } } { "execute": "qom-list", "arguments": { "path": "/machine/peripheral-anon/device[0]" } } { "execute": "qom-get", "arguments": { "path": "/machine/peripheral-anon/device[0]", "property": "type" } } { "execute": "qom-get", "arguments": { "path": "/machine/peripheral-anon/device[0]", "property": "mac" } } { "execute": "qom-get", "arguments": { "path": "/machine/peripheral-anon/device[0]", "property": "netdev" } } ``` # References * https://github.com/qemu/qemu/blob/v4.2.0/qapi/net.json * https://github.com/qemu/qemu/blob/v4.2.0/scripts/qmp/qom-tree * https://github.com/qemu/qemu/tree/v4.2.0/python/qemu * https://github.com/0xef53/qmp-shell