Tuesday, April 12, 2022

[SOLVED] How to run headless qemu without libvirt on a remote Ubuntu/Debian Linux server?

Issue

What I have tried?

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, macaddr=MACADDR -net bridge,br=BRIDGE -enable-kvm -display none -daemonize

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

MACADDR and BRIDGE are defined in my system.

I used -display none -daemonize but it failed with error

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

I also tried -nographic -serial mon:stdio -append 'console=ttyS0' but that also failed with error:

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.

So my question is

How to run headless qemu without libvirt on a remote Linux server?

Thanks in advance.


Solution

This isn't a full answer to your question, but I can see some things that might steer you in the right direction.

First, try to run QEMU without making it headless and without daemonizing it. The "Failed to initialize module" problems indicate that you have a mismatch between the qemu-system-x86_64 binary and the dynamically loaded modules it is trying to load. This isn't related to running headless, so you can fix it separately.

Secondly, you should stop trying to use '-nographic'. This is a "convenience" option that does a lot of things all at once: it puts the serial port and monitor on the console, it disables the display output, it doesn't give the guest a graphics device, and so on. You'll be better off using multiple separate options which do the individual things you want. (For instance, "-display none" says "don't put up a GUI window").

Thirdly, you should figure out where you want your console output to go: "-serial mon:stdio" implies you want to send the serial port to your terminal, but "-daemonize" implies you don't want to send anything to your terminal. QEMU won't complain if you do both, but they don't really make sense together.



Answered By - Peter Maydell
Answer Checked By - Marilyn (WPSolving Volunteer)