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

Commit b5028b0

Browse files
committed
libvirt: add clock config
Signed-off-by: Peng Tao <bergwolf@gmail.com>
1 parent f92b0b2 commit b5028b0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
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",

0 commit comments

Comments
 (0)