Skip to content

Commit

Permalink
stress_boot: Fixed the issue of unequal number of vCPUs when booting vm
Browse files Browse the repository at this point in the history
Signed-off-by: Yiqian Wei <[email protected]>
  • Loading branch information
yiqianwei committed Sep 25, 2024
1 parent a828766 commit 25f920c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion generic/tests/stress_boot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from virttest import env_process
from virttest import error_context
from avocado.utils import process
import math


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

host_cpu_cnt_cmd = params.get("host_cpu_cnt_cmd")
host_cpu_num = int(process.getoutput(host_cpu_cnt_cmd).strip())
if host_cpu_num <= int(params.get("max_vms")):
test.cancel("No enough physical cpus to pin all guests")
vm_cpu_num = host_cpu_num // int(params.get("max_vms"))
if vm_cpu_num == 1:
params["vcpu_sockets"] = 1
params["vcpu_threads"] = 1
params["vcpu_cores"] = 1
else:
vm_cpu_num = int(math.floor(float(vm_cpu_num) / 2) * 2)

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

params["smp"] = params["vcpu_maxcpus"] = vm_cpu_num
params["vcpu_maxcpus"] = vm_cpu_num
params["mem"] = vm_mem_size

params["start_vm"] = "yes"
Expand Down

0 comments on commit 25f920c

Please sign in to comment.