FIX: Use vhost macs when testpmd_mac forwarding used in VM
[csit.git] / resources / libraries / python / QemuManager.py
index 6f5db6e..ad205c8 100644 (file)
@@ -18,7 +18,7 @@ from collections import OrderedDict
 from resources.libraries.python.Constants import Constants
 from resources.libraries.python.CpuUtils import CpuUtils
 from resources.libraries.python.QemuUtils import QemuUtils
-from resources.libraries.python.topology import NodeType
+from resources.libraries.python.topology import NodeType, Topology
 
 __all__ = ["QemuManager"]
 
@@ -62,10 +62,18 @@ class QemuManager(object):
                 name = '{node}_{qemu_id}'.format(node=node, qemu_id=qemu_id)
                 sock1 = '/var/run/vpp/sock-{qemu_id}-1'.format(qemu_id=qemu_id)
                 sock2 = '/var/run/vpp/sock-{qemu_id}-2'.format(qemu_id=qemu_id)
-                vif1_mac = kwargs['tg_if1_mac'] if nf_node == 1 \
-                        else '52:54:00:00:{id:02x}:02'.format(id=qemu_id - 1)
-                vif2_mac = kwargs['tg_if2_mac'] if nf_node == nf_nodes \
-                        else '52:54:00:00:{id:02x}:01'.format(id=qemu_id + 1)
+                vif1_mac = Topology.get_interface_mac(
+                    self.nodes[node], 'vhost{idx}'.format(
+                        idx=(nf_chain - 1) * nf_nodes * 2 + nf_node * 2 - 1)) \
+                    if kwargs['vnf'] == 'testpmd_mac' \
+                    else kwargs['tg_if1_mac'] if nf_node == 1 \
+                    else '52:54:00:00:{id:02x}:02'.format(id=qemu_id - 1)
+                vif2_mac = Topology.get_interface_mac(
+                    self.nodes[node], 'vhost{idx}'.format(
+                        idx=(nf_chain - 1) * nf_nodes * 2 + nf_node * 2)) \
+                    if kwargs['vnf'] == 'testpmd_mac' \
+                    else kwargs['tg_if2_mac'] if nf_node == nf_nodes \
+                    else '52:54:00:00:{id:02x}:01'.format(id=qemu_id + 1)
 
                 self.machines_affinity[name] = CpuUtils.get_affinity_nf(
                     nodes=self.nodes, node=node, nf_chains=nf_chains,
@@ -113,11 +121,6 @@ class QemuManager(object):
             if pinning:
                 machine.qemu_set_affinity(*machine_affinity)
 
-    def set_scheduler_all_vms(self):
-        """Set CFS scheduler policy on all VMs in manager."""
-        for machine in self.machines.values():
-            machine.qemu_set_scheduler_policy()
-
     def kill_all_vms(self, force=False):
         """Kill all added VMs in manager.