Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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

- Super User 15/05/24, 11:57 AM

OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn
more
Sign in with Google

Use your Google Account


to sign in to Stack
Exchange
How to quit the QEMU monitor when not using a GUI?
No more passwords to
Asked 7 years, 11 months ago Modified today Viewed 119k times
remember. Signing in is fast,
simple and secure.
I'm running QEMU on Linux without GUI.
Continue
After running starting my custom kernel with QEMU, I can't kill and return to host by
81 pressing Ctrl+C.

Is there any way to get back to host OS?

qemu

Share Improve this question edited May 22, 2017 at 5:52 asked Jun 10, 2016 at 22:48
Follow Ciro Santilli triple fault
OurBigBook.com 943 1 6 8
11.7k 6 69 64

5 Answers Sorted by: Highest score (default)

Ctrl-A x

For -nographic just enter:


146
By clicking “Accept all cookies”, you agree Stack Exchange
Ctrl-A x
can store cookies on your device and disclose information in
accordance with our Cookie Policy.
which means
Accept all cookies Necessary cookies only
1. first press Ctrl + A (A is just key a , not the alt key),
Customize
2. then release settings
the keys,

3. afterwards press X (lowercase x; no Shift, case matters).

https://superuser.com/questions/1087859/how-to-quit-the-qemu-monitor-when-not-using-a-gui Page 1 of 4
How to quit the QEMU monitor when not using a GUI? - Super User 15/05/24, 11:57 AM

Alternatively:

enter the QEMU monitor with Ctrl-A C 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 Ctrl-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 of 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.

Share Improve this answer edited 13 mins ago answered May 22, 2017 at 5:50
Follow Ciro Santilli
OurBigBook.com
11.7k 6 69 64

The example in the other answer is clearer "ctrl+a, then x" – vharron Sep 25, 2019 at 21:17

1 @vharron yes, my amazing explanation skills have finally been surpassed


– Ciro Santilli OurBigBook.com Sep 25, 2019 at 21:19

The telnet trick worked for me, as my qemu was being started on a port. – Codigo Morsa Feb
7, 2023 at 22:40

1 qemu.org/docs/master/system/mux-chardev.html – Samuel Harmer Sep 28, 2023 at 7:20

https://superuser.com/questions/1087859/how-to-quit-the-qemu-monitor-when-not-using-a-gui Page 2 of 4
How to quit the QEMU monitor when not using a GUI? - Super User 15/05/24, 11:57 AM

To close a QEMU process in your shell:

ctrl+a , then x
15
Share Improve this answer Follow answered Dec 20, 2017 at 9:55
Noich
251 2 4

When using -nographics and -monitor need to include -serial mon:stdio que keep ctrl+a
working. stackoverflow.com/questions/49716931/… – arvati Jul 3, 2020 at 10:41

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

You can find more useful shortcuts here

Share Improve this answer edited Oct 29, 2019 at 23:46 answered Oct 29, 2019 at 19:23
Follow Ramhound YanivGK
42.9k 35 106 136 191 1 2

2 I found the Ctrl part unnecessary. Alt-2 does the job. – Jet Blue Sep 16, 2020 at 23:03

Ok, found a solution.

1. Opened new terminal session: ctrl+alt+f2


3
2. Used ps to find PID of previous tty: ps -fu

3. Killed previous tty: kill -HUP PID

https://superuser.com/questions/1087859/how-to-quit-the-qemu-monitor-when-not-using-a-gui Page 3 of 4
How to quit the QEMU monitor when not using a GUI? - Super User 15/05/24, 11:57 AM

Share Improve this answer Follow answered Jun 10, 2016 at 23:21
triple fault
943 1 6 8

6 This is a really inferior solution to the most upvoted answer here. I will not downvote the
answer, since it was entered before the better solutions. – EFraim Aug 21, 2018 at 8:05

Not necessarily inferior, it still caters to situations where the CtrlA,X way doesn't work, eg
when qemu gets stuck trying to bring up an OS. It's just an alternate answer. – Mendhak Oct
15, 2023 at 11:21

This is just in addition to other answers, where ctrl-a x works but you've aliased over
it. If you're like me, you're using tmux with ctrl-b replaced with ctrl-a , which is why
2 you can't use ctrl-a x . A simple solution to this is to use tmux's send-keys utility to
send ctrl-a x to qemu.

In a running tmux window, press ctrl-a : to bring up the tmux prompt, then type
send-keys C-a x Enter and qemu will quit.

Share Improve this answer Follow answered Jul 11, 2021 at 4:15
kjp
21 1

https://superuser.com/questions/1087859/how-to-quit-the-qemu-monitor-when-not-using-a-gui Page 4 of 4

You might also like