This repository was archived by the owner on May 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -185,15 +185,14 @@ func (h hypervisor) machineType() string {
185185}
186186
187187func (h hypervisor ) defaultVCPUs () uint32 {
188- if h .DefaultVCPUs < 0 {
189- return uint32 (goruntime .NumCPU ())
188+ numCPUs := goruntime .NumCPU ()
189+
190+ if h .DefaultVCPUs < 0 || h .DefaultVCPUs > int32 (numCPUs ) {
191+ return uint32 (numCPUs )
190192 }
191193 if h .DefaultVCPUs == 0 { // or unspecified
192194 return defaultVCPUCount
193195 }
194- if h .DefaultVCPUs > 255 { // qemu supports max 255
195- return 255
196- }
197196
198197 return uint32 (h .DefaultVCPUs )
199198}
Original file line number Diff line number Diff line change @@ -33,10 +33,10 @@ firmware = "@FIRMWAREPATH@"
3333machine_accelerators="@MACHINEACCELERATORS@"
3434
3535# Default number of vCPUs per POD/VM:
36- # unspecified or 0 --> will be set to @DEFVCPUS@
37- # < 0 --> will be set to the actual number of physical cores
38- # > 0 <= 255 --> will be set to the specified number
39- # > 255 --> will be set to 255
36+ # unspecified or 0 --> will be set to @DEFVCPUS@
37+ # < 0 --> will be set to the actual number of physical cores
38+ # > 0 <= number of physical cores --> will be set to the specified number
39+ # > number of physical cores --> will be set to the actual number of physical cores
4040default_vcpus = -1
4141
4242
Original file line number Diff line number Diff line change @@ -668,9 +668,9 @@ func TestHypervisorDefaults(t *testing.T) {
668668 h .DefaultVCPUs = 2
669669 assert .Equal (h .defaultVCPUs (), uint32 (2 ), "default vCPU number is wrong" )
670670
671- // qemu supports max 255
672- h .DefaultVCPUs = 8086
673- assert .Equal (h .defaultVCPUs (), uint32 (255 ), "default vCPU number is wrong" )
671+ numCPUs := goruntime . NumCPU ()
672+ h .DefaultVCPUs = int32 ( numCPUs ) + 1
673+ assert .Equal (h .defaultVCPUs (), uint32 (numCPUs ), "default vCPU number is wrong" )
674674
675675 h .DefaultMemSz = 1024
676676 assert .Equal (h .defaultMemSz (), uint32 (1024 ), "default memory size is wrong" )
@@ -1017,7 +1017,7 @@ func TestUpdateRuntimeConfiguration(t *testing.T) {
10171017func TestUpdateRuntimeConfigurationVMConfig (t * testing.T ) {
10181018 assert := assert .New (t )
10191019
1020- vcpus := uint (8 )
1020+ vcpus := uint (2 )
10211021 mem := uint (2048 )
10221022
10231023 config := oci.RuntimeConfig {}
You can’t perform that action at this time.
0 commit comments