Skip to content

Commit

Permalink
client.shared.base_utils.py: Added function to get the cpu affinity o…
Browse files Browse the repository at this point in the history
…f vcpu

Signed-off-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
  • Loading branch information
Satheesh Rajendran authored and lmr committed Jul 31, 2012
1 parent 3e9dba2 commit 060d791
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/shared/base_utils.py
Expand Up @@ -2008,6 +2008,18 @@ 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 convert_data_size(size, default_sufix='B'):
'''
Convert data size from human readable units to an int of arbitrary size.
Expand Down

0 comments on commit 060d791

Please sign in to comment.