Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(region,host): cpu mem max #16264

Open
wants to merge 1 commit into
base: release/3.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/compute/models/skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ func (self *SServerSkuManager) ValidateCreateData(ctx context.Context, userCred
return input, httperrors.NewOutOfRangeError("cpu_core_count should be range of 1~256")
}

if input.MemorySizeMB < 512 || input.MemorySizeMB > 1024*512 {
return input, httperrors.NewOutOfRangeError("memory_size_mb, shoud be range of 512~%d", 1024*512)
if input.MemorySizeMB < 512 || input.MemorySizeMB > 1024*1024 {
return input, httperrors.NewOutOfRangeError("memory_size_mb, shoud be range of 512~%d", 1024*1024)
}

if len(input.InstanceTypeCategory) == 0 {
Expand Down
12 changes: 10 additions & 2 deletions pkg/hostman/guestman/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,11 @@ func (o baseOptions_x86_64) SMP(cpus uint) string {
}

func (o baseOptions_x86_64) Memory(sizeMB uint64) string {
return fmt.Sprintf("-m %dM,slots=4,maxmem=524288M", sizeMB)
maxMem := options.HostOptions.MaxMemorySizeMb
if maxMem == 0 {
maxMem = 524288
}
return fmt.Sprintf("-m %dM,slots=4,maxmem=%dM", sizeMB, maxMem)
}

func (o baseOptions_x86_64) Cdrom(cdromPath string, osName string, isQ35 bool, disksLen int) []string {
Expand Down Expand Up @@ -542,7 +546,11 @@ func (o baseOptions_aarch64) SMP(cpus uint) string {
}

func (o baseOptions_aarch64) Memory(sizeMB uint64) string {
return fmt.Sprintf("-m %dM,slots=4,maxmem=262144M", sizeMB)
maxMem := options.HostOptions.MaxMemorySizeMb
if maxMem == 0 {
maxMem = 262144
}
return fmt.Sprintf("-m %dM,slots=4,maxmem=%dM", sizeMB, maxMem)
}

func (o baseOptions_aarch64) Cdrom(cdromPath string, osName string, isQ35 bool, disksLen int) []string {
Expand Down
6 changes: 3 additions & 3 deletions pkg/hostman/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ type SHostBaseOptions struct {
HostCpuPassthrough bool `default:"true" help:"if it is true, set qemu cpu type as -cpu host, otherwise, qemu64. default is true"`
LiveMigrateCpuThrottleMax int64 `default:"99" help:"live migrate auto converge cpu throttle max"`

DefaultQemuVersion string `help:"Default qemu version" default:"4.2.0"`
DefaultQemuVersion string `help:"Default qemu version" default:"4.2.0"`
MaxMemorySizeMb int64 `help:"Max memory size mb"`
MaxHotplugVCpuCount int `help:"maximal possible vCPU count that the platform kvm supports"`
}

type SHostOptions struct {
Expand Down Expand Up @@ -187,8 +189,6 @@ type SHostOptions struct {
LocalBackupTempPath string `help:"the local temporary directory for backup" default:"/opt/cloud/workspace/run/backups"`

BinaryMemcleanPath string `help:"execute binary memclean path" default:"/opt/yunion/bin/memclean"`

MaxHotplugVCpuCount int `help:"maximal possible vCPU count that the platform kvm supports"`
}

var (
Expand Down