Skip to content

Commit

Permalink
fix(region): optional vcpu when change vm config (#18825)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Nov 30, 2023
1 parent a5c5f4f commit 127711a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/compute/guests.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ type ServerChangeConfigInput struct {
// cpu卡槽数
CpuSockets *int `json:"cpu_sockets"`
// cpu大小
VcpuCount int `json:"vcpu_count"`
VcpuCount *int `json:"vcpu_count"`
// 内存大小, 1024M, 1G
VmemSize string `json:"vmem_size"`

Expand Down
6 changes: 3 additions & 3 deletions pkg/compute/models/guest_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2731,10 +2731,10 @@ func (self *SGuest) PerformChangeConfig(ctx context.Context, userCred mcclient.T
}
}
} else {
if input.VcpuCount != self.VcpuCount {
if input.VcpuCount != nil && *input.VcpuCount != self.VcpuCount {
cpuChanged = true
addCpu = input.VcpuCount - self.VcpuCount
confs.Add(jsonutils.NewInt(int64(input.VcpuCount)), "vcpu_count")
addCpu = *input.VcpuCount - self.VcpuCount
confs.Add(jsonutils.NewInt(int64(*input.VcpuCount)), "vcpu_count")
}
if len(input.VmemSize) > 0 {
if !regutils.MatchSize(input.VmemSize) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcclient/cloudpods/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (self *SInstance) DeployVM(ctx context.Context, name string, username strin
func (self *SInstance) ChangeConfig(ctx context.Context, opts *cloudprovider.SManagedVMChangeConfig) error {
input := api.ServerChangeConfigInput{}
input.VmemSize = fmt.Sprintf("%dM", opts.MemoryMB)
input.VcpuCount = opts.Cpu
input.VcpuCount = &opts.Cpu
input.InstanceType = opts.InstanceType
_, err := self.host.zone.region.perform(&modules.Servers, self.Id, "change-config", input)
return err
Expand Down

0 comments on commit 127711a

Please sign in to comment.