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

Commit fd00efa

Browse files
authored
Merge pull request #492 from bergwolf/clock
unify guest time keeping
2 parents f92b0b2 + 7907fb4 commit fd00efa

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

hypervisor/libvirt/libvirt.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,27 @@ type qemucmd struct {
372372
Value string `xml:"value,attr"`
373373
}
374374

375+
type clock struct {
376+
Offset string `xml:"offset,attr"`
377+
Timer []timer `xml:"timer,omitempty"`
378+
}
379+
380+
type timer struct {
381+
Name string `xml:"name,attr"`
382+
Track string `xml:"track,attr,omitempty"`
383+
Tickpolicy string `xml:"tickpolicy,attr,omitempty"`
384+
CatchUp catchup `xml:"catchup,omitempty"`
385+
Frequency uint32 `xml:"frequency,attr,omitempty"`
386+
Mode string `xml:"mode,attr,omitempty"`
387+
Present string `xml:"present,attr,omitempty"`
388+
}
389+
390+
type catchup struct {
391+
Threshold uint `xml:"threshold,attr,omitempty"`
392+
Slew uint `xml:"slew,attr,omitempty"`
393+
Limit uint `xml:"limit,attr,omitempty"`
394+
}
395+
375396
type commandlines struct {
376397
Cmds []qemucmd `xml:"qemu:arg"`
377398
}
@@ -392,6 +413,7 @@ type domain struct {
392413
OnCrash string `xml:"on_crash"`
393414
Devices device `xml:"devices"`
394415
SecLabel seclab `xml:"seclabel"`
416+
Clock clock `xml:"clock"`
395417
CommandLine commandlines `xml:"qemu:commandline"`
396418
}
397419

@@ -480,6 +502,9 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) {
480502
dom.OnReboot = "destroy"
481503
dom.OnCrash = "destroy"
482504

505+
dom.Clock.Offset = "utc"
506+
dom.Clock.Timer = append(dom.Clock.Timer, timer{Name: "rtc", Track: "guest", Tickpolicy: "catchup"})
507+
483508
pcicontroller := controller{
484509
Type: "pci",
485510
Index: "0",

hypervisor/qemu/qemu_amd64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
6363

6464
params = append(params,
6565
"-realtime", "mlock=off", "-no-user-config", "-nodefaults", "-no-hpet",
66-
"-rtc", "base=utc,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
66+
"-rtc", "base=utc,clock=vm,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
6767
"-m", memParams, "-smp", cpuParams)
6868

6969
if boot.BootToBeTemplate || boot.BootFromTemplate {

hypervisor/qemu/qemu_arm64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
8484
return append(params,
8585
"-kernel", boot.Kernel, "-initrd", boot.Initrd, "-append", "console=ttyAMA0 panic=1",
8686
"-realtime", "mlock=off", "-no-user-config", "-nodefaults",
87-
"-rtc", "base=utc,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
87+
"-rtc", "base=utc,clock=vm,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
8888
"-m", memParams, "-smp", cpuParams,
8989
"-device", "pci-bridge,chassis_nr=1,id=pci.0",
9090
"-qmp", fmt.Sprintf("unix:%s,server,nowait", qc.qmpSockName), "-serial", fmt.Sprintf("unix:%s,server,nowait", ctx.ConsoleSockName),

hypervisor/qemu/qemu_ppc64le.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
4545
"-machine", "pseries,accel=kvm,usb=off", "-global", "kvm-pit.lost_tick_policy=discard", "-cpu", "host",
4646
"-kernel", boot.Kernel, "-initrd", boot.Initrd,
4747
"-realtime", "mlock=off", "-no-user-config", "-nodefaults",
48-
"-rtc", "base=utc,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
48+
"-rtc", "base=utc,clock=vm,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
4949
"-m", memParams, "-smp", cpuParams,
5050
"-qmp", fmt.Sprintf("unix:%s,server,nowait", qc.qmpSockName), "-serial", fmt.Sprintf("unix:%s,server,nowait", ctx.ConsoleSockName),
5151
"-device", "virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x2", "-device", "virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3",

hypervisor/qemu/qemu_s390x.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
3939
"-kernel", boot.Kernel, "-initrd", boot.Initrd,
4040
"-append", "\"console=ttyS1 panic=1 no_timer_check\"",
4141
"-realtime", "mlock=off", "-no-user-config", "-nodefaults", "-enable-kvm",
42-
"-rtc", "base=utc,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
42+
"-rtc", "base=utc,clock=vm,driftfix=slew", "-no-reboot", "-display", "none", "-boot", "strict=on",
4343
"-m", memParams, "-smp", cpuParams,
4444
"-qmp", fmt.Sprintf("unix:%s,server,nowait", qc.qmpSockName),
4545
"-chardev", fmt.Sprintf("socket,id=charconsole0,path=%s,server,nowait", ctx.ConsoleSockName),

0 commit comments

Comments
 (0)