Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@imperialguy
Forked from rgl/qemu-qmp.md
Created December 31, 2020 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imperialguy/39ad33f802c10a795a301e79887e7dae to your computer and use it in GitHub Desktop.
Save imperialguy/39ad33f802c10a795a301e79887e7dae to your computer and use it in GitHub Desktop.
qemu qmp

QEMU Machine Protocol (QMP) socket

Start QEMU with QMP UNIX socket and connect:

qemu-system-x86_64 -qmp unix:test.socket,server,nowait ...
nc -U test.socket
qmp-shell test.socket    # use the raw qmp interface. see https://github.com/0xef53/qmp-shell
qmp-shell -H test.socket # use the human interface.   see https://github.com/0xef53/qmp-shell

Or start QEMU with QMP TCP socket and connect:

qemu-system-x86_64 -qmp tcp:127.0.0.1:12345,server,nowait ...
nc localhost 12345

Examples

After you open the socket, the first command is always:

{ "execute": "qmp_capabilities" }

Then you can either execute human or machine friendly commands.

Human friendly commands examples

{ "execute": "human-monitor-command", "arguments": { "command-line": "help" } }
{ "execute": "human-monitor-command", "arguments": { "command-line": "info version" } }
{ "execute": "human-monitor-command", "arguments": { "command-line": "info network" } }
{ "execute": "human-monitor-command", "arguments": { "command-line": "info qtree" } }

Machine friendly commands examples

{ "execute": "query-qmp-schema" }

{ "execute": "query-machines" }

{ "execute": "query-version" }
{ "execute": "query-name" }
{ "execute": "query-status" }
{ "execute": "query-kvm" }
{ "execute": "query-pci" }

{ "execute": "device-list-properties", "arguments": { "typename": "vmxnet3" } }

{ "execute": "qom-list-types" }

{ "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" } }

{ "execute": "qom-get", "arguments": { "path": "/machine/peripheral/nic0", "property": "type" } }
{ "execute": "qom-get", "arguments": { "path": "/machine/peripheral/nic0", "property": "mac" } }

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment