summaryrefslogtreecommitdiffstats
path: root/vnfs
diff options
context:
space:
mode:
authorChristian Trautman <ctrautma@redhat.com>2016-09-01 02:44:35 -0400
committerChristian Trautman <ctrautma@redhat.com>2016-09-01 02:44:35 -0400
commit8a1a94321a26e34dc4c0b3ba9cd868487fa2c5ac (patch)
treecc85308c160a2c194baf3ab2f3ec7853b2bf6ab2 /vnfs
parentcd22516b0f625e87ef100a7937d3ba9ba8f155e7 (diff)
vhost_affin_fixup: Change vhost thread from regex to pgrep usage
Change vhost affinity process lookup to use pgrep instead of ugly error prone regex method as suggested. Change-Id: I8cac00a7f2d26ba1ce1815535a198f578159222c Signed-off-by: Christian Trautman <ctrautma@redhat.com>
Diffstat (limited to 'vnfs')
-rw-r--r--vnfs/qemu/qemu.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/vnfs/qemu/qemu.py b/vnfs/qemu/qemu.py
index dd9ad818..2093cb3b 100644
--- a/vnfs/qemu/qemu.py
+++ b/vnfs/qemu/qemu.py
@@ -247,14 +247,13 @@ class IVnfQemu(IVnf):
:return: None
"""
self._logger.info('Affinitizing VHOST Net threads.')
- args1 = ['ps', 'ax']
+ args1 = ['pgrep', 'vhost-']
process1 = subprocess.Popen(args1, stdout=subprocess.PIPE,
shell=False)
out = process1.communicate()[0]
- processes = list()
- for line in out.decode(locale.getdefaultlocale()[1]).split('\n'):
- if re.search('\[vhost-(\d+)', line):
- processes.append(re.match('\s*(\d+)', line).group(1))
+ processes = out.decode(locale.getdefaultlocale()[1]).split('\n')
+ if processes[-1] == '':
+ processes.pop() # pgrep may return an extra line with no data
self._logger.info('Found %s vhost net threads...', len(processes))
cpumap = S.getValue('VSWITCH_VHOST_CPU_MAP')