linuxkit / linuxkit

A toolkit for building secure, portable and lean operating systems for containers
Apache License 2.0
8.29k stars 1.02k forks source link

Hang at tsc setup during boot in qemu 3.1 OS X #3320

Closed mt-inside closed 5 years ago

mt-inside commented 5 years ago

Description

The example linuxkit.yml from the git repo builds on my OS X machine, but does not run properly under qemu; it hangs during kernel boot.

$ git clone linuxkit # 9d4ebc8ad (HEAD -> master, origin/master, origin/HEAD) Merge pull request #3319 from rn/kern-up $ linuxkit build linuxkit.yml $ linuxkit run qemu linuxkit

Describe the results you received: The last three printk() lines are:

[ 3.093435] tsc: Refined TSC clocksource calibration: 3095.995 MHz [ 3.097516] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x2ca08088042, max_idle_ns: 440795310813 ns [ 3.104493] clocksource: Switched to clocksource tsc

then an infinite hang.

Describe the results you expected: Kernel should boot, then fork init for userspace startup.

Additional information you deem important (e.g. issue happens only occasionally): Happens all the time

Linuxkit git master, built locally: linuxkit version linuxkit version v0.6+ commit: 9d4ebc8adae8c9d8ec4ec389acf1adab153df5a1

Qemu (homebrew): qemu-system-x86_64 --version QEMU emulator version 3.1.0 Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers

OS X: uname -a Darwin eadrax.lan 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64

mt-inside commented 5 years ago

Have confirmed that this doesn't happen when running qemu direct as:

qemu-system-x86_64 -m 512M -cdrom mykit.iso -serial mon:stdio

Both 3.1 as above, and

QEMU emulator version 3.1.91 (v4.0.0-rc1-49-g230ce19814-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
mt-inside commented 5 years ago

So, linuxkit run qemu runs the following:

qemu-system-x86_64 -smp 1 -m 1024 -pidfile mykit-state/qemu.pid -machine q35,accel=hvf:tcg -object rng-random,id=rng0 -device virtio-rng-pci,rng=rng0 -kernel mykit-kernel -initrd mykit-initrd.img -append "console=tty0 console=ttyS0 console=ttyAMA0" -device virtio-net-pci,netdev=t0,mac=16:5d:89:63:8e:97 -netdev user,id=t0 -nographic

Removing the accel=hvf:tcg option fixes this.

mt-inside commented 5 years ago

Equally, leaving acceleration using HVF but removing -object rng-random,id=rng0 -device virtio-rng-pci,rng=rng0 fixes this - it seem the use of both together causes this problem. Verified booting from kernel+initrd or iso-bios

justincormack commented 5 years ago

Can we file a bug on qemu for this please.

mt-inside commented 5 years ago

I don't really feel qualified; @rn will you be able to do this if you have some insight into what the bug actually is?

rn commented 5 years ago

I probably won't have time to collect detailed info for a bug report to qemu..