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 23, 2024
1 parent 994bc3f commit 6f12821
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 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 Down Expand Up @@ -28,7 +29,13 @@ def run(test, params, env):
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
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)
params["vcpu_maxcpus"] = vm_cpu_num
params["mem"] = vm_mem_size

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

0 comments on commit 6f12821

Please sign in to comment.