From 05f108f9bf0a036565af444f5ae709dc12ac2967 Mon Sep 17 00:00:00 2001
From: Martin Klozik <martinx.klozik@intel.com>
Date: Mon, 12 Feb 2018 14:20:45 +0000
Subject: trex: Tests with T-Rex in VM

Patch introduces a set of testcases with T-Rex running inside VM.

JIRA: VSPERF-560

Change-Id: I5b0a0220a2d72428ae1210ee9590d39abdfb9c1d
Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Signed-off-by: RadoslawX Glombiowski <radoslawx.glombiowski@intel.com>
Reviewed-by: Al Morton <acmorton@att.com>
Reviewed-by: Christian Trautman <ctrautma@redhat.com>
Reviewed-by: Sridhar Rao <sridhar.rao@spirent.com>
---
 vnfs/qemu/qemu.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'vnfs/qemu')

diff --git a/vnfs/qemu/qemu.py b/vnfs/qemu/qemu.py
index 8e3d44de..a0128f44 100644
--- a/vnfs/qemu/qemu.py
+++ b/vnfs/qemu/qemu.py
@@ -222,7 +222,13 @@ class IVnfQemu(IVnf):
             stdin=proc.stdout)
         proc.wait()
 
-        for cpu in range(0, int(S.getValue('GUEST_SMP')[self._number])):
+        # calculate the number of CPUs in SMP topology specified by GUEST_SMP
+        # e.g. "sockets=2,cores=3", "4", etc.
+        cpu_nr = 1
+        for i in re.findall(r'\d', S.getValue('GUEST_SMP')[self._number]):
+            cpu_nr = cpu_nr * int(i)
+        # pin each GUEST's core to host core based on configured BINDING
+        for cpu in range(0, cpu_nr):
             match = None
             guest_thread_binding = S.getValue('GUEST_THREAD_BINDING')[self._number]
             if guest_thread_binding is None:
-- 
cgit