How to use QMP, send command remotely to qemu

To use qmp and send command to qemu from another process, start qemu by

qemu-kvm -m 4096m -hda win7.img -chardev socket,id=qmp,path=/tmp/test.qmp,server,nowait -mon chardev=qmp,mode=control 

This will create a file /tmp/test.gmp for interchange the command. Then you can start another terminal and invoke

cat command.txt |socat - /tmp/test.qmp 


{ "execute": "qmp_capabilities" }
{ "execute": "query-status" }
{ "execute": "query-commands" }
{ "execute": "stop" }
{ "execute": "screendump","arguments":{"filename":"peter.png"}  }
{ "execute": "cont" }
{ "execute": "human-monitor-command", "arguments": { "command-line": "info registers" } } 

!!! remark, must invoke { “execute”: “qmp_capabilities” } before invoke any qmp command

read count : 1662


  1. Thanks, great tip !!!! This allowed me to workaround one of my problems. Long live FOSS people ! You/we’re great!