Skip to content

Commit f0f9a23

Browse files
authored
Merge pull request #1767 from nanjj/rtcbase
incusd/instance/qemu: rtc base localtime for windows
2 parents e6e2a2b + 4a56581 commit f0f9a23

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

doc/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ RESTful
234234
RHEL
235235
rootfs
236236
RSA
237+
RTC
237238
rST
238239
runtime
239240
SATA

doc/howto/instances_create.md

+10
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ The list of supported clouds and instance types can be found at [`https://github
111111

112112
### Launch a VM that boots from an ISO
113113

114+
```{note}
115+
When creating a Windows virtual machine, make sure to set the `image.os` property to something starting with `Windows`.
116+
Doing so will tell Incus to expect Windows to be running inside of the virtual machine and to tweak behavior accordingly.
117+
118+
This notably will cause:
119+
- Some unsupported virtual devices to be disabled
120+
- The {abbr}`RTC (Real Time Clock)` clock to be based on system local time rather than UTC
121+
- IOMMU handling to switch to an Intel IOMMU controller
122+
```
123+
114124
To launch a VM that boots from an ISO, you must first create a VM.
115125
Let's assume that we want to create a VM and install it from the ISO image.
116126
In this scenario, use the following command to create an empty VM:

internal/server/instance/drivers/driver_qemu.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,11 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
16241624
}
16251625
}
16261626

1627+
// Set RTC to localtime on Windows.
1628+
if d.isWindows() {
1629+
qemuArgs = append(qemuArgs, "-rtc", "base=localtime")
1630+
}
1631+
16271632
// SMBIOS only on x86_64 and aarch64.
16281633
if d.architectureSupportsUEFI(d.architecture) {
16291634
qemuArgs = append(qemuArgs, "-smbios", "type=2,manufacturer=LinuxContainers,product=Incus")
@@ -3340,11 +3345,16 @@ func (d *qemu) deviceBootPriorities(base int) (map[string]int, error) {
33403345
return sortedDevs, nil
33413346
}
33423347

3348+
// isWindows returns whether the VM is Windows.
3349+
func (d *qemu) isWindows() bool {
3350+
return strings.Contains(strings.ToLower(d.expandedConfig["image.os"]), "windows")
3351+
}
3352+
33433353
// generateQemuConfig generates the QEMU configuration.
33443354
func (d *qemu) generateQemuConfig(cpuInfo *cpuTopology, mountInfo *storagePools.MountInfo, busName string, vsockFD int, devConfs []*deviceConfig.RunConfig, fdFiles *[]*os.File) ([]monitorHook, error) {
33453355
var monHooks []monitorHook
33463356

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

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

0 commit comments

Comments
 (0)