Skip to content

Commit

Permalink
Add vcpu hotplug validation on domstats output
Browse files Browse the repository at this point in the history
domstats output provides guest vcpu details, this
patch adds an method to test it for vcpu hotplug
validation.

Signed-off-by: Satheesh Rajendran <[email protected]>
  • Loading branch information
Satheesh Rajendran committed Jan 11, 2019
1 parent 0dcc39c commit 81d2858
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions virttest/utils_hotplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,45 @@ def get_cpustats(vm, cpu=None):
return cpustats


def get_domstats(vm, key):
"""
Get VM's domstats output value for given keyword
:param vm: VM object
:param key: keyword for which value is needed
:return: value string
"""
domstats_output = virsh.domstats(vm.name)
for item in results_stdout_52lts(domstats_output).strip().split():
if key in item:
return item.split("=")[1]


def check_vcpu_domstats(vm, exp_vcpu):
"""
Check the cpu values from domstats output
:param vm: VM object
:param exp_vcpu: dict of expected vcpus
:return: True if exp_vcpu matches the domstats output, False if not
"""
status = True
cur_vcpu = int(get_domstats(vm, "vcpu.current"))
max_vcpu = int(get_domstats(vm, "vcpu.maximum"))
if vm.is_alive():
exp_cur_vcpu = exp_vcpu['cur_live']
else:
exp_cur_vcpu = exp_vcpu['cur_config']
if exp_cur_vcpu != cur_vcpu:
status = False
logging.error("Mismatch in current vcpu in domstats output, "
"Expected: %s Actual: %s", exp_cur_vcpu, cur_vcpu)
if exp_vcpu['max_config'] != max_vcpu:
status = False
logging.error("Mismatch in maximum vcpu in domstats output, Expected:"
" %s Actual: %s", exp_vcpu['max_config'], max_vcpu)

return status


def check_vcpu_value(vm, exp_vcpu, vcpupin=None, option="", guest_agent=False):
"""
Check domain vcpu, including vcpucount, vcpuinfo, vcpupin, vcpu number and
Expand Down Expand Up @@ -470,6 +509,9 @@ def check_vcpu_value(vm, exp_vcpu, vcpupin=None, option="", guest_agent=False):
# 1.6 Check guest numa
if not guest_numa_check(vm, exp_vcpu):
final_result = False
# 1.7 Check virsh domstats output
if not check_vcpu_domstats(vm, exp_vcpu):
final_result = False

return final_result

Expand Down

0 comments on commit 81d2858

Please sign in to comment.