Distro linux requires nographic but it does not go along with daemonize
mazzy89 opened this issue · 16 comments
I have a distro Linux image that in order to be run with QEMU requires -nographic
flag. If I use it together with daemonize
, QEMU does not start and errors out saying that both flags cannot be used.
The problem is that by removing daemonize
, the cmd.Run()
hangs. I know that actually it does not hangs and it runs QEMU but it does not display anything because by design there is nothing attached to the cmd
standard output and standard error.
I've tried to run it only with daemonize
but I got the error:
ERRO[0098] Unable to launch /usr/bin/qemu-system-x86_64: exit status 1
ERRO[0098] Unable to init server: Could not connect: Connection refused
gtk initialization failed
I've also tried to pass -vga none
but it did not work.
I faced a similar issue with debian > 9, can you try with -vga virtio
?
unfortunately, it did not help
INFO[0097] launching /usr/bin/qemu-system-x86_64 with: [-name flatcar_production_qemu -enable-kvm -daemonize -cpu host,pmu=off -machine type=q35,accel=kvm -device virtio-net-pci,netdev=tap-eth0,mac=2e:ad:13:f4:64:85 -netdev tap,id=tap-eth0,ifname=tap-eth0,script=no,downscript=no -drive if=virtio,file=flatcar_production_qemu_image.img -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -qmp unix:/tmp/qmp-socket,server,nowait -m 1024M -smp cpus=1 -vga virtio]
ERRO[0097] Unable to launch /usr/bin/qemu-system-x86_64: exit status 1
ERRO[0097] Unable to init server: Could not connect: Connection refused
gtk initialization failed
One thing still not clear is how kata runs qemu using daemonize and nographic both set to true https://github.com/kata-containers/runtime/blob/master/virtcontainers/qemu.go#L488
I made some progress. I've added -display none
and -vga none
and QEMU now seems to start. so these are the parameters
INFO[0099] launching /usr/bin/qemu-system-x86_64 with: [-name flatcar_production_qemu -enable-kvm -daemonize -cpu host,pmu=off -machine type=q35,accel=kvm -device virtio-net-pci,netdev=tap-eth0,mac=9e:75:51:a9:3c:da -netdev tap,id=tap-eth0,ifname=tap-eth0,script=no,downscript=no -drive if=virtio,file=flatcar_production_qemu_image.img -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -qmp unix:/tmp/qmp-socket,server,nowait -m 1024M -smp cpus=1 -display none -vga none
@devimc can you advise a way to read the output in particular the boot process of the OS?
In Kata we use these options: -vga none -no-user-config -nodefaults -nographic -daemonize
@devimc can you advise a way to read the output in particular the boot process of the OS?
I guess you have two options:
-
append
console=ttyS0
to the kernel command line and-serial file:/tmp/serial.log
to the QEMU command line -
append
-device virtconsole,chardev=charconsole0,id=console0 -chardev socket,id=charconsole0,path=console.sock,server,nowait
to the QEMU command line and runsocat - unix-connect:console.sock
ASAP!
In Kata we use these options: -vga none -no-user-config -nodefaults -nographic -daemonize
I see. Running with those flags runs perfectly. So no need to pass -display none
.
I will try your recommendations.
I liked the idea to listen from the unix socket but QEMU did not like that
qemu-system-x86_64: -device virtconsole,chardev=charconsole0,id=console0: No 'virtio-serial-bus' bus found for device 'virtconsole'
Launch config
INFO[0000] launching /usr/bin/qemu-system-x86_64 with: [-name flatcar_production_qemu -enable-kvm -daemonize -cpu host,pmu=off -machine type=q35,accel=kvm -device virtio-net-pci,netdev=tap-eth0,mac=4e:bd:43:b6:95:b3 -netdev tap,id=tap-eth0,ifname=tap-eth0,script=no,downscript=no -drive if=virtio,file=flatcar_production_qemu_image.img -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -qmp unix:/tmp/qmp-socket,server,nowait -m 1024M -smp cpus=1 -no-user-config -nodefaults -nographic -vga none -device virtconsole,chardev=charconsole0,id=console0 -chardev socket,id=charconsole0,path=console.sock,server,nowait
sorry I forgot to include the pci device -device virtio-serial-pci,id=serial0
@devimc I've tried to create the CharDev
charDev := qemu.CharDevice{
Backend: qemu.Socket,
Driver: qemu.VirtioSerial,
ID: "charconsole0",
DeviceID: "console0",
Path: consoleUDS,
Transport: qemu.TransportPCI,
}
but always missing -device virtio-serial-pci,id=serial0
do you have any recommendations how to create that using the struct rather than passing the params by string?
I think I found a way to make this via structs as you do in kata-containers https://github.com/kata-containers/runtime/blob/d5acbad6d6021dd41ccd12d68aa6c9aa0d6744d7/virtcontainers/qemu_arch_base.go#L318
removing nowait
the func LaunchQemu
blocks and does not return. Is Kata able to capture the full logs from the beginning?
Is Kata able to capture the full logs from the beginning?
No, and I'm not sure if that is possible since nowait
is asynchronous
Yeah makes sense. Indeed I've tried and it does not work. it's ok. it's a kind of acceptable trade-off. We can close this for me. Thanks a lot @devimc for the support here.
you're welcome. closing issue