From 8a1a94321a26e34dc4c0b3ba9cd868487fa2c5ac Mon Sep 17 00:00:00 2001 From: Christian Trautman Date: Thu, 1 Sep 2016 02:44:35 -0400 Subject: 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 --- vnfs/qemu/qemu.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'vnfs/qemu/qemu.py') 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') -- cgit 1.2.3-korg