Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit db0f7a0

Browse files
committed
qemu: set clocksource to acpi_pm when kvm is not present
tsc is not reliable in this case, especially if hyperd runs inside a virtual machine itself, as in the hykins use case. Signed-off-by: Peng Tao <[email protected]>
1 parent 96c529f commit db0f7a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hypervisor/qemu/qemu_amd64.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
3838
cpuParams = strconv.Itoa(boot.CPU)
3939
}
4040

41+
cmdline := "console=ttyS0 panic=1 no_timer_check"
4142
params := []string{
4243
"-machine", machineClass + ",accel=kvm,usb=off", "-global", "kvm-pit.lost_tick_policy=discard", "-cpu", "host"}
4344
if _, err := os.Stat("/dev/kvm"); os.IsNotExist(err) {
4445
glog.V(1).Info("kvm not exist change to no kvm mode")
4546
params = []string{"-machine", machineClass + ",usb=off", "-cpu", "core2duo"}
47+
cmdline += " clocksource=acpi_pm notsc"
4648
}
4749

4850
if boot.Bios != "" && boot.Cbfs != "" {
@@ -52,13 +54,13 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
5254
} else if boot.Bios != "" {
5355
params = append(params,
5456
"-bios", boot.Bios,
55-
"-kernel", boot.Kernel, "-initrd", boot.Initrd, "-append", "console=ttyS0 panic=1 no_timer_check")
57+
"-kernel", boot.Kernel, "-initrd", boot.Initrd, "-append", cmdline)
5658
} else if boot.Cbfs != "" {
5759
params = append(params,
5860
"-drive", fmt.Sprintf("if=pflash,file=%s,readonly=on", boot.Cbfs))
5961
} else {
6062
params = append(params,
61-
"-kernel", boot.Kernel, "-initrd", boot.Initrd, "-append", "console=ttyS0 panic=1 no_timer_check")
63+
"-kernel", boot.Kernel, "-initrd", boot.Initrd, "-append", cmdline)
6264
}
6365

6466
params = append(params,

0 commit comments

Comments
 (0)