diff options
author | pmikus <pmikus@cisco.com> | 2020-08-27 07:47:31 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2020-09-03 06:41:47 +0000 |
commit | 5c7cf5a09ec1cd7ebc4077981de84c4f18aa8738 (patch) | |
tree | 864d4fec2f4698650e073a19c7b91429ceae9751 /resources/libraries/python/QemuManager.py | |
parent | 3b2dcb0348e890950dfbc3fe4aec7008d4e1f63a (diff) |
Framework: Code aligments
+ Unifying code structures
- To easily plug another DUT
+ New PCI PassThrough templates
+ Improved perf stat on cores allocated in test.
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: I325f17b977314f93cb91818feddfddf3e607eb8a
Diffstat (limited to 'resources/libraries/python/QemuManager.py')
-rw-r--r-- | resources/libraries/python/QemuManager.py | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/resources/libraries/python/QemuManager.py b/resources/libraries/python/QemuManager.py index 66a21aa115..547250e283 100644 --- a/resources/libraries/python/QemuManager.py +++ b/resources/libraries/python/QemuManager.py @@ -107,6 +107,7 @@ class QemuManager: :param pinning: If True, then do also QEMU process pinning. :type pinning: bool """ + cpus = [] for machine, machine_affinity in \ zip(self.machines.values(), self.machines_affinity.values()): index = list(self.machines.values()).index(machine) @@ -114,6 +115,8 @@ class QemuManager: self.nodes[name] = machine.qemu_start() if pinning: machine.qemu_set_affinity(*machine_affinity) + cpus.extend(machine_affinity) + return ",".join(str(cpu) for cpu in cpus) def kill_all_vms(self, force=False): """Kill all added VMs in manager. @@ -176,3 +179,243 @@ class QemuManager: csum=kwargs[u"enable_csum"], gso=kwargs[u"enable_gso"] ) + + def _c_vpp_2vfpt_ip4base_plen24(self, **kwargs): + """Instantiate one VM with vpp_2vfpt_ip4base_plen24 configuration. + + :param kwargs: Named parameters. + :type kwargs: dict + """ + qemu_id = kwargs[u"qemu_id"] + name = kwargs[u"name"] + + self.machines[name] = QemuUtils( + node=self.nodes[kwargs[u"node"]], + qemu_id=qemu_id, + smp=len(self.machines_affinity[name]), + mem=4096, + vnf=kwargs[u"vnf"], + img=Constants.QEMU_VM_KERNEL + ) + self.machines[name].add_default_params() + self.machines[name].add_kernelvm_params() + if u"DUT1" in name: + self.machines[name].configure_kernelvm_vnf( + ip1=u"2.2.2.1/30", + ip2=u"1.1.1.2/30", + route1=u"20.0.0.0/24", + routeif1=u"avf-0/0/6/0", + nexthop1=u"2.2.2.2", + route2=u"10.0.0.0/24", + routeif2=u"avf-0/0/7/0", + nexthop2=u"1.1.1.1", + arpmac1=u"3c:fd:fe:d1:5c:d8", + arpip1=u"1.1.1.1", + arpif1=u"avf-0/0/7/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + else: + self.machines[name].configure_kernelvm_vnf( + ip1=u"3.3.3.2/30", + ip2=u"2.2.2.2/30", + route1=u"10.0.0.0/24", + routeif1=u"avf-0/0/7/0", + nexthop1=u"2.2.2.1", + route2=u"20.0.0.0/24", + routeif2=u"avf-0/0/6/0", + nexthop2=u"3.3.3.1", + arpmac1=u"3c:fd:fe:d1:5c:d9", + arpip1=u"3.3.3.1", + arpif1=u"avf-0/0/6/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if2"]) + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if1"]) + ) + + def _c_vpp_2vfpt_ip4scale2k_plen30(self, **kwargs): + """Instantiate one VM with vpp_2vfpt_ip4scale2k_plen30 configuration. + + :param kwargs: Named parameters. + :type kwargs: dict + """ + qemu_id = kwargs[u"qemu_id"] + name = kwargs[u"name"] + + self.machines[name] = QemuUtils( + node=self.nodes[kwargs[u"node"]], + qemu_id=qemu_id, + smp=len(self.machines_affinity[name]), + mem=4096, + vnf=kwargs[u"vnf"], + img=Constants.QEMU_VM_KERNEL + ) + self.machines[name].add_default_params() + self.machines[name].add_kernelvm_params() + if u"DUT1" in name: + self.machines[name].configure_kernelvm_vnf( + ip1=u"2.2.2.1/30", + ip2=u"1.1.1.2/30", + route1=u"20.0.0.0/30", + routeif1=u"avf-0/0/6/0", + nexthop1=u"2.2.2.2", + route2=u"10.0.0.0/30", + routeif2=u"avf-0/0/7/0", + nexthop2=u"1.1.1.1", + arpmac1=u"3c:fd:fe:d1:5c:d8", + arpip1=u"1.1.1.1", + arpif1=u"avf-0/0/7/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + else: + self.machines[name].configure_kernelvm_vnf( + ip1=u"3.3.3.2/30", + ip2=u"2.2.2.2/30", + route1=u"10.0.0.0/30", + routeif1=u"avf-0/0/7/0", + nexthop1=u"2.2.2.1", + route2=u"20.0.0.0/30", + routeif2=u"avf-0/0/6/0", + nexthop2=u"3.3.3.1", + arpmac1=u"3c:fd:fe:d1:5c:d9", + arpip1=u"3.3.3.1", + arpif1=u"avf-0/0/6/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if2"]) + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if1"]) + ) + + def _c_vpp_2vfpt_ip4scale20k_plen30(self, **kwargs): + """Instantiate one VM with vpp_2vfpt_ip4scale20k_plen30 configuration. + + :param kwargs: Named parameters. + :type kwargs: dict + """ + qemu_id = kwargs[u"qemu_id"] + name = kwargs[u"name"] + + self.machines[name] = QemuUtils( + node=self.nodes[kwargs[u"node"]], + qemu_id=qemu_id, + smp=len(self.machines_affinity[name]), + mem=4096, + vnf=kwargs[u"vnf"], + img=Constants.QEMU_VM_KERNEL + ) + self.machines[name].add_default_params() + self.machines[name].add_kernelvm_params() + if u"DUT1" in name: + self.machines[name].configure_kernelvm_vnf( + ip1=u"2.2.2.1/30", + ip2=u"1.1.1.2/30", + route1=u"20.0.0.0/30", + routeif1=u"avf-0/0/6/0", + nexthop1=u"2.2.2.2", + route2=u"10.0.0.0/30", + routeif2=u"avf-0/0/7/0", + nexthop2=u"1.1.1.1", + arpmac1=u"3c:fd:fe:d1:5c:d8", + arpip1=u"1.1.1.1", + arpif1=u"avf-0/0/7/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + else: + self.machines[name].configure_kernelvm_vnf( + ip1=u"3.3.3.2/30", + ip2=u"2.2.2.2/30", + route1=u"10.0.0.0/30", + routeif1=u"avf-0/0/7/0", + nexthop1=u"2.2.2.1", + route2=u"20.0.0.0/30", + routeif2=u"avf-0/0/6/0", + nexthop2=u"3.3.3.1", + arpmac1=u"3c:fd:fe:d1:5c:d9", + arpip1=u"3.3.3.1", + arpif1=u"avf-0/0/6/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if2"]) + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if1"]) + ) + + def _c_vpp_2vfpt_ip4scale200k_plen30(self, **kwargs): + """Instantiate one VM with vpp_2vfpt_ip4scale200k_plen30 configuration. + + :param kwargs: Named parameters. + :type kwargs: dict + """ + qemu_id = kwargs[u"qemu_id"] + name = kwargs[u"name"] + + self.machines[name] = QemuUtils( + node=self.nodes[kwargs[u"node"]], + qemu_id=qemu_id, + smp=len(self.machines_affinity[name]), + mem=4096, + vnf=kwargs[u"vnf"], + img=Constants.QEMU_VM_KERNEL + ) + self.machines[name].add_default_params() + self.machines[name].add_kernelvm_params() + if u"DUT1" in name: + self.machines[name].configure_kernelvm_vnf( + ip1=u"2.2.2.1/30", + ip2=u"1.1.1.2/30", + route1=u"20.0.0.0/30", + routeif1=u"avf-0/0/6/0", + nexthop1=u"2.2.2.2", + route2=u"10.0.0.0/30", + routeif2=u"avf-0/0/7/0", + nexthop2=u"1.1.1.1", + arpmac1=u"3c:fd:fe:d1:5c:d8", + arpip1=u"1.1.1.1", + arpif1=u"avf-0/0/7/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + else: + self.machines[name].configure_kernelvm_vnf( + ip1=u"3.3.3.2/30", + ip2=u"2.2.2.2/30", + route1=u"10.0.0.0/30", + routeif1=u"avf-0/0/7/0", + nexthop1=u"2.2.2.1", + route2=u"20.0.0.0/30", + routeif2=u"avf-0/0/6/0", + nexthop2=u"3.3.3.1", + arpmac1=u"3c:fd:fe:d1:5c:d9", + arpip1=u"3.3.3.1", + arpif1=u"avf-0/0/6/0", + queues=kwargs[u"queues"], + jumbo_frames=kwargs[u"jumbo"] + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if2"]) + ) + self.machines[name].add_vfio_pci_if( + pci=Topology.get_interface_pci_addr( + self.nodes[kwargs[u"node"]], kwargs[u"if1"]) + ) |