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

Commit cfc48da

Browse files
authored
Merge pull request #494 from bergwolf/clock
use acpi_pm as guest clocksource when kvm is not supported
2 parents fd00efa + db0f7a0 commit cfc48da

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hypervisor/libvirt/libvirt.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) {
448448
dom.SecLabel.Type = "none"
449449

450450
dom.CPU.Mode = "host-passthrough"
451+
cmdline := "console=ttyS0 panic=1 no_timer_check"
451452
if _, err := os.Stat("/dev/kvm"); os.IsNotExist(err) {
452453
dom.Type = "qemu"
453454
dom.CPU.Mode = "host-model"
@@ -456,6 +457,7 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) {
456457
Fallback: "allow",
457458
Content: "core2duo",
458459
}
460+
cmdline += " clocksource=acpi_pm notsc"
459461
}
460462

461463
if ctx.Boot.HotAddCpuMem {
@@ -626,7 +628,7 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) {
626628
} else {
627629
dom.OS.Kernel = boot.Kernel
628630
dom.OS.Initrd = boot.Initrd
629-
dom.OS.Cmdline = "console=ttyS0 panic=1 no_timer_check"
631+
dom.OS.Cmdline = cmdline
630632
}
631633

632634
data, err := xml.Marshal(dom)

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)