Skip to content

Commit 25f920c

Browse files
committed
stress_boot: Fixed the issue of unequal number of vCPUs when booting vm
Signed-off-by: Yiqian Wei <[email protected]>
1 parent a828766 commit 25f920c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

generic/tests/stress_boot.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from virttest import env_process
22
from virttest import error_context
33
from avocado.utils import process
4+
import math
45

56

67
@error_context.context_aware
@@ -22,13 +23,21 @@ def run(test, params, env):
2223

2324
host_cpu_cnt_cmd = params.get("host_cpu_cnt_cmd")
2425
host_cpu_num = int(process.getoutput(host_cpu_cnt_cmd).strip())
26+
if host_cpu_num <= int(params.get("max_vms")):
27+
test.cancel("No enough physical cpus to pin all guests")
2528
vm_cpu_num = host_cpu_num // int(params.get("max_vms"))
29+
if vm_cpu_num == 1:
30+
params["vcpu_sockets"] = 1
31+
params["vcpu_threads"] = 1
32+
params["vcpu_cores"] = 1
33+
else:
34+
vm_cpu_num = int(math.floor(float(vm_cpu_num) / 2) * 2)
2635

2736
host_mem_size_cmd = params.get("host_mem_size_cmd")
2837
host_mem_size = int(process.getoutput(host_mem_size_cmd).strip())
2938
vm_mem_size = host_mem_size // int(params.get("max_vms"))
3039

31-
params["smp"] = params["vcpu_maxcpus"] = vm_cpu_num
40+
params["vcpu_maxcpus"] = vm_cpu_num
3241
params["mem"] = vm_mem_size
3342

3443
params["start_vm"] = "yes"

0 commit comments

Comments
 (0)