I configured Qemu's grub the following way:

GRUB_TERMINAL="serial console"

and run the qemu process with the -nographic command line option. These enables to use the current terminal for the serial console and qemu monitor console. However now, anytime I press Ctrl+C inside the running VM, it is intercepted by qemu and shuts the process down.

How am I supposed to pass Ctrl+C or any other keystroke involving CTRL in Qemu?


In your shell, before you run qemu, run "stty intr ^]" to change the interrupt key from ^c to ctrl-]

That way, ctrl-c will be passed through to qemu, but you can still interrupt qemu itself by pressing ctrl-]

  • 2
    To override Ctrl-Z (backgrounding) too, there is stty susp ^]. For Ctrl-\ (quit), use stty quit ^]. With multiple definitions for a single char, this is the order of precedence: intr quit susp. – Lekensteyn Aug 7 '15 at 12:49

You can try using the sendkey command using -monitor stdio. Though apparently the -display none -serial mon:stdio option should pass Ctrl + c through to the guest.

You can also create a monitor socket, like this:

qemu -display none -monitor unix:/tmp/qemu-monitor,server,nowait

And then, connect to the monitor to use sendkey with socat like this:

socat - UNIX-CONNECT:/tmp/qemu-monitor

You can now send your keys, like this:

(qemu) sendkey ctrl-c
sendkey ctrl-c
  • Thanks. Could you tell me how can I 'jump' into qemy monitor console (ie. what keystroke should I press), if I run qemu in the PuTTY terminal? – Mark Nov 11 '14 at 12:42
  • In GUI - Ctrl + Alt then Shift + 2 to switch to the monitor, or Shift-1 to switch back to guest OS. That doesn't work in console. There you can use the socket approach, and open up another screen window and connect to it via socat. You can also use -monitor stdio to redirect to your terminal instead. – Criveti Mihai Nov 11 '14 at 12:51

Remove -monitor or add -serial mon:stdio

As of QEMU 2.10.1, Ubuntu 17.10, Ctrl-C does get passed by default to the guest without problem when using -nographic.

However, if you also use the -monitor option, behavior changes, and the Ctrl-C kills QEMU instead.

This is how -monitor would normally be used: How to switch to the QEMU control panel with -nographics? | Super User

If you need -monitor, you can get Ctrl+C back with -serial mon:stdio: How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest and quit with Ctrl+A X? | Stack Overflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.