Skip to content

Commit 39f842d

Browse files
committed
incusd/isntance/qemu: On standalone systems, cap hotplug memory to system
Closes #2234 Signed-off-by: Stéphane Graber <[email protected]>
1 parent 7f792e6 commit 39f842d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/server/instance/drivers/driver_qemu.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4202,6 +4202,16 @@ func (d *qemu) addCPUMemoryConfig(conf *[]cfg.Section, cpuType string, cpuInfo *
42024202
maxMemoryBytes = 1024 * 1024 * 1024 * 1024
42034203
}
42044204

4205+
// On standalone systems, further cap to the system's total memory.
4206+
if !d.state.ServerClustered {
4207+
totalMemory, err := linux.DeviceTotalMemory()
4208+
if err != nil {
4209+
return err
4210+
}
4211+
4212+
maxMemoryBytes = totalMemory
4213+
}
4214+
42054215
// Allow the user to go past any expected limit.
42064216
if maxMemoryBytes < memSizeBytes {
42074217
maxMemoryBytes = memSizeBytes

0 commit comments

Comments
 (0)