我刚刚发现,如果使用来运行QEMU -monitor telnet::45454,server,nowait -nographic,那么Ctrl-C会杀死QEMU VM而不是在来宾上生成SIGINT:使用-nographic运行qemu时如何将Ctrl-C传递给来宾?| Unix和Linux堆栈交换
但是,我不想删除-monitor它,因为它使监视命令自动化非常方便,例如,它允许我创建一个执行以下操作的帮助程序脚本:
echo 'savevm my_snap_id' | telnet localhost 45454
Run Code Online (Sandbox Code Playgroud)
有没有办法让我Ctrl-C和我保持-monitor合作-nographic?
完整的QEMU命令:
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
Run Code Online (Sandbox Code Playgroud)
在QEMU 2.10.1,Ubuntu 17.10上,完整的QEMU命令:
./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 \
Run Code Online (Sandbox Code Playgroud)
如果我添加:
-chardev stdio,id=s1,signal=off \
-serial none -device isa-serial,chardev=s1
Run Code Online (Sandbox Code Playgroud)
然后Ctrl+C根据需要开始工作,但Ctrl+A X不能退出QEMU,这有时很烦人:我可以使用telnetto quit,但是它需要更多的键入/自动化操作。
http://lists.nongnu.org/archive/html/qemu-discuss/2018-04/msg00006.html
添加-serial mon:stdio和删除其他-serial选项
以下内容满足我的所有要求:
./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
Run Code Online (Sandbox Code Playgroud)
或对于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 \
Run Code Online (Sandbox Code Playgroud)
在QEMU 9d2a09063922757ec3640d93f6b35921ab95b1c2(版本v2.12.0-rc2)上进行了测试。
| 归档时间: |
|
| 查看次数: |
3898 次 |
| 最近记录: |