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?

后端 未结 1 505
心在旅途
心在旅途 2021-01-05 20:49

I have just found out that if you run QEMU with -monitor telnet::45454,server,nowait -nographic, then Ctrl-C kills the QEMU VM instead of generating SIGINT on t

相关标签:
1条回答
  • 2021-01-05 21:06

    Add -serial mon:stdio and remove other -serial options

    The following satisfies all my requirements:

    ./x86_64-softmmu/qemu-system-x86_64 \
      -append 'root=/dev/vda nopat nokaslr norandmaps printk.devkmsg=on printk.time=y console=ttyS0' \
      -drive file="${dir}/out/x86_64/buildroot/images/rootfs.ext2.qcow2,if=virtio,format=qcow2" \
      -kernel "${dir}/out/x86_64/buildroot/images/bzImage" \
      -nographic \
      -monitor telnet::45454,server,nowait \
      -serial mon:stdio
    

    Or for aarch64:

    ./aarch64-softmmu/qemu-system-aarch64 \
      -M virt \
      -append 'root=/dev/vda nokaslr norandmaps printk.devkmsg=on printk.time=y' \
      -cpu cortex-a57 \
      -drive file="${dir}/out/aarch64/buildroot/images/rootfs.ext2.qcow2,if=virtio,format=qcow2" \
      -kernel "${dir}/out/aarch64/buildroot/images/Image" \
      -monitor telnet::45454,server,nowait \
      -nographic \
      -serial mon:stdio \
    

    Tested on QEMU 9d2a09063922757ec3640d93f6b35921ab95b1c2 (post v2.12.0-rc2).

    0 讨论(0)
提交回复
热议问题