Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change guest cpu topology checking method #5736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,21 @@ def prepare_vm_xml(test_obj):
return vmxml


def verify_vm_cpu_info(vm_session, test_obj, cpu_info_type, cmd):
def verify_vm_cpu_info(test_obj):
"""
Verify vm's cpu information

:param vm_session: vm session
:param test_obj: NumaTest object
:param cpu_info_type: str, specified cpu info type, like 'cores', 'threads'
:param cmd: str, the command used to check the cpu info
"""
status, output = vm_session.cmd_status_output(cmd, timeout=300)
if status:
test_obj.test.error("Can't get cpu info with command '%s'" % cmd)
cpu_info = eval(test_obj.params.get('cpu_topology'))[cpu_info_type]
if cpu_info_type == 'cores':
dies = eval(test_obj.params.get('cpu_topology'))['dies']
cpu_info = str(int(cpu_info) * int(dies))
if cpu_info != output.strip():
test_obj.test.fail('Guest cpu %s is expected '
'to be %s, but found %s' % (cpu_info_type,
cpu_info,
output.strip()))
else:
test_obj.test.log.debug("Step: check vm cpu %s "
"to be '%s': PASS", cpu_info_type, cpu_info)
vm_topology = test_obj.vm.get_cpu_topology_in_vm()
expect_topology = eval(test_obj.params.get('cpu_topology'))
expect_topology['cores'] = str(int(expect_topology['cores']) * int(expect_topology['dies']))
for key in expect_topology:
if expect_topology[key] != vm_topology[key]:
test_obj.test.fail('Guest cpu %s is expected '
'to be %s, but found %s' % (key,
expect_topology[key],
vm_topology[key]))


def verify_vm_numa_node(vm_session, test_obj):
Expand Down Expand Up @@ -163,12 +154,7 @@ def run_default(test_obj):
test_obj.test.log.debug("After vm is started, vm xml:\n"
"%s", vm_xml.VMXML.new_from_dumpxml(test_obj.vm.name))
vm_session = test_obj.vm.wait_for_login()
cmds = {'sockets': 'cat /proc/cpuinfo|grep "physical id"|sort -u|wc -l',
'cores': 'cat /proc/cpuinfo|grep "core id"|sort|uniq|wc -l',
'dies': 'cat /sys/devices/system/cpu/cpu*/topology/die_id|sort|uniq|wc -l',
'threads': 'lscpu|grep Thread|cut -d":" -f2'}
for cpu_info_type, cpu_cmd in cmds.items():
verify_vm_cpu_info(vm_session, test_obj, cpu_info_type, cpu_cmd)
verify_vm_cpu_info(test_obj)
verify_vm_numa_node(vm_session, test_obj)
verify_dmesg_vm_numa_mem(vm_session, test_obj)

Expand Down