From: Satheesh Rajendran <[email protected]> cpu_affinity_by_task(): to get the cpu affinity of vcpu count_cpu(): to get the number of host cpus
Signed-off-by: Satheesh Rajendran <[email protected]> --- client/shared/base_utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/client/shared/base_utils.py b/client/shared/base_utils.py index b262f5d..5c365cd 100644 --- a/client/shared/base_utils.py +++ b/client/shared/base_utils.py @@ -2008,6 +2008,27 @@ def display_data_size(size): return '%.2f %s' % (size, prefixes[i]) +def cpu_affinity_by_task(pid,vcpu_pid): + """ + This function returns the allowed cpus from the proc entry + for each vcpu's through its task id for a pid(of a VM) + """ + + cmd = "cat /proc/%s/task/%s/status|grep Cpus_allowed:| awk '{print $2}'" % (pid,vcpu_pid) + output = system_output(cmd, ignore_status=False) + return output + + +def count_cpu(): + """ + This function returns the number of host cpus + """ + + cmd = "cat /proc/cpuinfo|grep -c processor" + output = system_output(cmd, ignore_status=False) + return output + + def convert_data_size(size, default_sufix='B'): ''' Convert data size from human readable units to an int of arbitrary size. -- 1.7.10.4 _______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
