fix(host): add guest max mem size options (#24333)

This commit is contained in:
wanyaoqi
2026-02-26 20:26:28 +08:00
committed by GitHub
parent e3adcba461
commit b72ee232e4
2 changed files with 11 additions and 3 deletions
+9 -3
View File
@@ -258,17 +258,23 @@ func (m *SGuestManager) InitQemuMaxCpus(machineCaps []monitor.MachineInfo, kvmMa
func (m *SGuestManager) InitQemuMaxMems(maxMems uint) {
if m.host.IsX8664() {
if maxMems > arch.X86_MAX_MEM_MB {
if options.HostOptions.GuestMaxMemSizeMb > 0 {
arch.X86_MAX_MEM_MB = uint(options.HostOptions.GuestMaxMemSizeMb)
} else if maxMems > arch.X86_MAX_MEM_MB {
arch.X86_MAX_MEM_MB = maxMems
}
}
if m.host.IsAarch64() {
if maxMems > arch.ARM_MAX_MEM_MB {
if options.HostOptions.GuestMaxMemSizeMb > 0 {
arch.ARM_MAX_MEM_MB = uint(options.HostOptions.GuestMaxMemSizeMb)
} else if maxMems > arch.ARM_MAX_MEM_MB {
arch.ARM_MAX_MEM_MB = maxMems
}
}
if m.host.IsRiscv64() {
if maxMems > arch.RISCV_MAX_MEM_MB {
if options.HostOptions.GuestMaxMemSizeMb > 0 {
arch.RISCV_MAX_MEM_MB = uint(options.HostOptions.GuestMaxMemSizeMb)
} else if maxMems > arch.RISCV_MAX_MEM_MB {
arch.RISCV_MAX_MEM_MB = maxMems
}
}
+2
View File
@@ -245,6 +245,8 @@ type SHostOptions struct {
EnableQemuDebugLog bool `help:"enable qemu debug logs" default:"false"`
ResetDiskTmpDir string `help:"auto reset disk after guest shutdown will write disk to tmpdir"`
GuestMaxMemSizeMb int `help:"guest maximal mem size, default 0 is not set" default:"0"`
// container related endpoint
// EnableContainerRuntime bool `help:"enable container runtime" default:"false"`
ContainerRuntimeEndpoint string `help:"endpoint of container runtime service" default:"unix:///var/run/onecloud/containerd/containerd.sock"`