title: 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?
body: <p>I have just found out that if you run QEMU with <code>-monitor telnet::45454,server,nowait -nographic</code>, then Ctrl-C kills the QEMU VM instead of generating SIGINT on the guest: <a href="https://unix.stackexchange.com/questions/167165/how-to-pass-ctrl-c-to-the-guest-when-running-qemu-with-nographic/436321#436321">How to pass Ctrl-C to the guest when running qemu with -nographic? | Unix &amp; Linux Stack Exchange</a></p>
  
  <p>However, I don't want to remove <code>-monitor</code> because it is convenient to automate monitor commands, e.g. it allows me to create a helper script that does:</p>
  
  <pre><code>echo 'savevm my_snap_id' |  telnet localhost 45454
  </code></pre>
  
  <p>Is there a way to both keep my <code>Ctrl-C</code> and <code>-monitor</code> working with <code>-nographic</code>?</p>
  
  <p>Full QEMU command:</p>
  
  <pre><code>qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2' -nographic -monitor telnet::45454,server,nowait
  </code></pre>
  
  <p>On QEMU 2.10.1, Ubuntu 17.10, full QEMU command:</p>
  
  <pre><code>./x86_64-softmmu/qemu-system-x86_64 \
  -append "root=/dev/sda console=ttyS0 nokaslr printk.time=y" \
  -drive file="${dir}/out/x86_64/buildroot/images/rootfs.ext2.qcow2,format=qcow2" \
  -kernel "${dir}/out/x86_64/buildroot/images/bzImage" \
  -nographic \
  </code></pre>
  
  <p>If I add:</p>
  
  <pre><code>-chardev stdio,id=s1,signal=off \
  -serial none -device isa-serial,chardev=s1
  </code></pre>
  
  <p>then <code>Ctrl+C</code> starts working as desired, but <code>Ctrl+A X</code> does not work to quit QEMU, which is annoying sometimes: I can use <code>telnet</code> to <code>quit</code>, but it requires more typing / automation.</p>
  
  <p><a href="http://lists.nongnu.org/archive/html/qemu-discuss/2018-04/msg00006.html" rel="noreferrer">http://lists.nongnu.org/archive/html/qemu-discuss/2018-04/msg00006.html</a></p>