How to quit the QEMU monitor when not using a GUI?

I'm running QEMU on Linux without GUI.

After running starting my custom kernel with QEMU, I can't kill and return to host by pressing Ctrl+C.

Is there any way to get back to host OS?


Ctrl-A X

For -nographic just enter:

Ctrl-A X

which means

  1. first press Ctrl + A (A is just key a, not the alt key),
  2. then release the keys,
  3. afterwards press X.

Alternatively:

  • enter the QEMU monitor with Ctrl-A C and then type:

    quit
    

    and press enter. See also: https://stackoverflow.com/questions/14165158/how-to-switch-to-qemu-monitor-console-when-running-with-curses

  • use the QEMU monitor (same as Ctral-A C) with telnet:

    qemu-system-x86_64 -monitor telnet::45454,server,nowait -serial mon:stdio
    

    and on a host terminal:

    telnet localhost 45454
    

    and then quit from there.

    -serial mon:stdio is required to keep Ctrl+C working: https://stackoverflow.com/questions/49716931/how-to-run-qemu-with-nographic-and-monitor-but-still-be-able-to-send-ctrlc-to/49751144#49751144

  • shut down the VM from guest normally, e.g. with a powerdown command from a Linux guest shell if you are able. This or course goes through the normal shutdown sequence instead of immediately killing the VM, but sometimes it is just the simplest approach.

    It does not work for all machines however: https://stackoverflow.com/questions/31990487/how-to-cleanly-exit-qemu-after-executing-bare-metal-program-without-user-interve

Tested in Ubuntu 17.10, QEMU 2.10.1.


To close a QEMU process in your shell:

ctrl+a, then x


Press Cntl-Alt-2 and then use the close button on the menu.

enter image description here

You can find more useful shortcuts here