Skip to content

Commit af86468

Browse files
committed
incusd/instance/qemu: rtc base localtime for windows
Closes #1752 Signed-off-by: JUN JIE NAN <[email protected]>
1 parent 2505c88 commit af86468

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/server/instance/drivers/driver_qemu.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,11 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
15001500
}
15011501
}
15021502

1503+
rtcBase := "base=utc"
1504+
if d.windowsOS() {
1505+
rtcBase = "base=localtime"
1506+
}
1507+
15031508
cpuType := "host"
15041509

15051510
// Handle CPU flags.
@@ -1586,6 +1591,7 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
15861591
"-name", d.Name(),
15871592
"-uuid", instUUID,
15881593
"-daemonize",
1594+
"-rtc", rtcBase,
15891595
"-cpu", cpuType,
15901596
"-nographic",
15911597
"-serial", "chardev:console",
@@ -3340,11 +3346,16 @@ func (d *qemu) deviceBootPriorities(base int) (map[string]int, error) {
33403346
return sortedDevs, nil
33413347
}
33423348

3349+
// windowsOS return whether the image is windows OS.
3350+
func (d *qemu) windowsOS() bool {
3351+
return strings.Contains(strings.ToLower(d.expandedConfig["image.os"]), "windows")
3352+
}
3353+
33433354
// generateQemuConfig generates the QEMU configuration.
33443355
func (d *qemu) generateQemuConfig(cpuInfo *cpuTopology, mountInfo *storagePools.MountInfo, busName string, vsockFD int, devConfs []*deviceConfig.RunConfig, fdFiles *[]*os.File) ([]monitorHook, error) {
33453356
var monHooks []monitorHook
33463357

3347-
isWindows := strings.Contains(strings.ToLower(d.expandedConfig["image.os"]), "windows")
3358+
isWindows := d.windowsOS()
33483359
conf := qemuBase(&qemuBaseOpts{d.Architecture(), util.IsTrue(d.expandedConfig["security.iommu"])})
33493360

33503361
err := d.addCPUMemoryConfig(&conf, cpuInfo)

0 commit comments

Comments
 (0)