Skip to content

Commit

Permalink
fixed inspekt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rh-jugraham committed Sep 26, 2024
1 parent 5494f8f commit dffdfe2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions libvirt/tests/src/cpu/vcpu_max_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def run(test, params, env):
"""
Test that the vm can start with vcpus which is equal to host online cpu number
Test that the vm can start with vcpus which is equal to host online cpu number
and vm topology is consistent to those configured.
Steps:
Expand Down Expand Up @@ -46,7 +46,7 @@ def run(test, params, env):
# cores = vcpus_num // number of clusters
if sockets_param == "one":
sockets_list = [1]

# many_clusters case
if clusters_param == "many":
# Ensure that vcpus_num is evenly divisble by the number of clusters
Expand All @@ -64,8 +64,8 @@ def run(test, params, env):
# many_cores_per_socket
# Ensure that vcpus_num is evenly divible by the number of cores
else:
# many_clusters case
# sockets = vcpus_num // number of cores // number of clusters
# many_clusters case
# sockets = vcpus_num // number of cores // number of clusters
if clusters_param == "many":
# defaulting to either 2 or 3 cores
cores = 2 if vcpus_num % 2 == 0 else 3
Expand Down Expand Up @@ -118,31 +118,31 @@ def set_and_check_topology(test, params, env, vcpus_num, sockets, cores, cluster
if vm.is_alive():
vm.destroy()
vmxml.placement = vcpus_placement

if clusters > 1:
# Set manually
vmcpu_xml = vmxml["cpu"]
vmcpu_xml["topology"] = {
"sockets": str(sockets),
"clusters": str(clusters),
"cores":str(cores),
"threads":"1"}
"cores": str(cores),
"threads": "1"}
vmxml["cpu"] = vmcpu_xml
vmxml["vcpu"] = vcpus_num
vmxml.sync()

else:
# Set using set_vm_vcpus helper function
vmxml.set_vm_vcpus(
vm_name,
vcpus_num,
sockets=sockets,
cores=cores,
vm_name,
vcpus_num,
sockets=sockets,
cores=cores,
threads=1,
add_topology=True
)
logging.debug("Defined guest with '%s' vcpu(s), '%s' socket(s), and '%s' core(s), and '%s' cluster(s)",
str(vcpus_num), str(sockets), str(cores), str(clusters))
logging.debug("Defined guest with '%s' vcpu(s), '%s' socket(s), and '%s' core(s), and '%s' cluster(s)",
str(vcpus_num), str(sockets), str(cores), str(clusters))

# Start guest agent in vm
try:
Expand Down Expand Up @@ -182,7 +182,7 @@ def set_and_check_topology(test, params, env, vcpus_num, sockets, cores, cluster
ret_coreid = session.cmd_output(cmd_coreid).strip()
if (str(vcpu) != ret_coreid):
test.fail("In the vm kernel file, the coreid for vcpu %s should not be %s" % (vcpu, ret_coreid))

# Check vcpu cluster number

cmd_clusterid = 'cat /sys/devices/system/cpu/cpu*/topology/cluster_id | sort | uniq -c | wc -l'
Expand All @@ -200,7 +200,7 @@ def set_and_check_topology(test, params, env, vcpus_num, sockets, cores, cluster
test.fail("In the vm kernel file, the cluster cpu list should be %s, not %s" % (str(sockets * clusters), ret_cluster_cpu_list))

session.close()

finally:
# Recover VM
if vm.is_alive():
Expand Down

0 comments on commit dffdfe2

Please sign in to comment.