diff --git a/pkg/hostman/guestman/guestman.go b/pkg/hostman/guestman/guestman.go index dd8d51f8af..f4fb096431 100644 --- a/pkg/hostman/guestman/guestman.go +++ b/pkg/hostman/guestman/guestman.go @@ -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 } } diff --git a/pkg/hostman/options/options.go b/pkg/hostman/options/options.go index f9469d2788..26d1b72cdb 100644 --- a/pkg/hostman/options/options.go +++ b/pkg/hostman/options/options.go @@ -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"`