From b2e1c0b2d989b9f19d5b06140e7dbdd7648ad1cb Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Fri, 14 Oct 2022 10:15:20 +0800 Subject: [PATCH] fix(region): hugepage validate mem update --- pkg/compute/models/hosts.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 56a6d4ee0b..f26c59ca99 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -710,7 +710,10 @@ func (self *SHost) IsHugePage() bool { } func (self *SHost) GetMemoryOvercommitBound() float32 { - if self.MemCmtbound > 0 && self.IsHugePage() { + if self.IsHugePage() { + return 1.0 + } + if self.MemCmtbound > 0 { return self.MemCmtbound } return options.Options.DefaultMemoryOvercommitBound @@ -3654,8 +3657,8 @@ func (self *SHost) ValidateUpdateData(ctx context.Context, userCred mcclient.Tok return input, errors.Wrap(err, "inputUniquenessCheck") } - if self.IsHugePage() && (input.MemReserved != "" || input.MemCmtbound != nil) { - return input, errors.Errorf("host mem is hugepage, cannot update mem_reserved or mem_cmtbound") + if self.IsHugePage() && input.MemCmtbound != nil { + return input, errors.Errorf("host mem is hugepage, cannot update mem_cmtbound") } input.HostSizeAttributes, err = HostManager.ValidateSizeParams(input.HostSizeAttributes)