23.7. QEMU monitor
The QEMU monitor is a magic terminal that allows you to send text commands to the QEMU VM itself: https://en.wikibooks.org/wiki/QEMU/Monitor
While QEMU is running, on another terminal, run:
./qemu-monitor
or send one command such as info qtree
and quit the monitor:
./qemu-monitor info qtree
or equivalently:
echo 'info qtree' | ./qemu-monitor
Source: qemu-monitor
qemu-monitor
uses the -monitor
QEMU command line option, which makes the monitor listen from a socket.
Alternatively, we can also enter the QEMU monitor from inside -nographics
QEMU text mode with:
Ctrl-A C
and go back to the terminal with:
Ctrl-A C
When in graphic mode, we can do it from the GUI:
Ctrl-Alt ?
where ?
is a digit 1
, or 2
, or, 3
, etc. depending on what else is available on the GUI: serial, parallel and frame buffer.
Finally, we can also access QEMU monitor commands directly from GDB step debug with the monitor
command:
./run-gdb
then inside that shell:
monitor info qtree
This way you can use both QEMU monitor and GDB commands to inspect the guest from inside a single shell! Pretty awesome.
In general, ./qemu-monitor
is the best option, as it:
-
works on both modes
-
allows to use the host Bash history to re-run one off commands
-
allows you to search the output of commands on your host shell even when in graphic mode
Getting everything to work required careful choice of QEMU command line options: