如何在没有 libvirt 的远程 Ubuntu/Debian Linux 服务器上运行无头 qemu?

问题描述

我尝试了什么?

qemu-system-x86_64 -hda hdd.img -m 1G -net nic,macaddr=MACADDR -net bridge,br=BRIDGE -enable-kvm -nographic -daemonize

qemu-system-x86_64 -hda hdd.img -m 1G -net nic,br=BRIDGE -enable-kvm -display none -daemonize

qemu-system-x86_64 -hda hdd.img -m 1G -net nic,br=BRIDGE -enable-kvm -nographic -serial mon:stdio -append 'console=ttyS0'

MACADDR 和 BRIDGE 在我的系统中定义。

我使用了 -display none -daemonize 但它失败并出现错误

qemu-system-x86_64: -nographic cannot be used with -daemonize

我也试过 -nographic -serial mon:stdio -append 'console=ttyS0' 但也失败了:

Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-iscsi.so
Note: only modules from the same build can be loaded.
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-curl.so
Note: only modules from the same build can be loaded.
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-rbd.so
Note: only modules from the same build can be loaded.
Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-dmg.so
Note: only modules from the same build can be loaded.

所以我的问题是

如何在远程 Linux 服务器上运行没有 libvirt 的无头 qemu?

提前致谢。

解决方法

这不是您问题的完整答案,但我可以看到一些可能引导您朝着正确方向前进的事情。

首先,尝试运行 QEMU,不要让它无头,也不要守护它。 “无法初始化模块”问题表明您在 qemu-system-x86_64 二进制文件与其尝试加载的动态加载模块之间存在不匹配。这与无头运行无关,因此您可以单独修复它。

其次,您应该停止尝试使用“-nographic”。这是一个“方便”的选项,可以同时做很多事情:它把串行端口和监视器放在控制台上,它禁用显示输出,它不给客人一个图形设备,等等。您最好使用多个单独的选项来完成您想要的个别事情。 (例如,“-display none”表示“不要设置 GUI 窗口”)。

第三,您应该弄清楚您希望控制台输出的位置:“-serial mon:stdio”表示您想将串行端口发送到您的终端,但“-daemonize”表示您不想发送任何到你的终端。如果两者都做,QEMU 不会抱怨,但它们并没有真正有意义。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...