X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FQemuManager.py;h=6f5db6ecbbde90d0037e05096bb4b54dba4e5223;hp=0ea6164cb7a3d65bb7fcdd2c29d451e9ba4e8e5e;hb=780b65d82863effd53ccb0e0150c29d22522c61d;hpb=f6e9d58ecd95789e0b3292983fafff223ec75a2c diff --git a/resources/libraries/python/QemuManager.py b/resources/libraries/python/QemuManager.py index 0ea6164cb7..6f5db6ecbb 100644 --- a/resources/libraries/python/QemuManager.py +++ b/resources/libraries/python/QemuManager.py @@ -15,61 +15,14 @@ from collections import OrderedDict -from robot.libraries.BuiltIn import BuiltIn - 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, Topology +from resources.libraries.python.topology import NodeType __all__ = ["QemuManager"] -def get_affinity_vm(nodes, node, nf_chains=1, nf_nodes=1, nf_chain=1, nf_node=1, - cpu_count_int=1, vnf_count_int=1): - """Get affinity of VM. Result will be used to compute the amount of - CPUs and also affinity. - - :param node: SUT nodes. - :param node: DUT node. - :param nf_chains: Number of NF chains. - :param nf_nodes: Number of NF nodes in chain. - :param nf_chain: Chain ID. - :param nf_node: Node ID. - :param cpu_count_int: Amount of Dataplane threads of vswitch. - :param vnf_count_int: Amount of Dataplane threads of vnf. - :type nodes: dict - :type node: dict - :type nf_chains: int - :type nf_nodes: int - :type nf_chain: int - :type nf_node: int - :type cpu_count_int: int - :type vnf_count_int: int - :returns: List of CPUs allocated to VM. - :rtype: list - """ - sut_sc = 1 - dut_mc = 1 - dut_dc = cpu_count_int - skip_cnt = sut_sc + dut_mc + dut_dc - dtc = vnf_count_int - - interface_list = [] - interface_list.append( - BuiltIn().get_variable_value('${{{node}_if1}}'.format(node=node))) - interface_list.append( - BuiltIn().get_variable_value('${{{node}_if2}}'.format(node=node))) - - cpu_node = Topology.get_interfaces_numa_node(nodes[node], *interface_list) - - nf_cpus = CpuUtils.cpu_slice_of_list_for_nf( - node=nodes[node], cpu_node=cpu_node, chains=nf_chains, - nodeness=nf_nodes, chain_id=nf_chain, node_id=nf_node, mtcr=2, dtcr=1, - dtc=dtc, skip_cnt=skip_cnt) - - return nf_cpus - class QemuManager(object): """QEMU lifecycle management class""" @@ -97,8 +50,9 @@ class QemuManager(object): nf_chains = int(kwargs['nf_chains']) nf_nodes = int(kwargs['nf_nodes']) queues = kwargs['rxq_count_int'] if kwargs['auto_scale'] else 1 - cpu_count_int = kwargs['cpu_count_int'] - vnf_count_int = kwargs['cpu_count_int'] if kwargs['auto_scale'] else 1 + vs_dtc = kwargs['vs_dtc'] + nf_dtc = kwargs['vs_dtc'] if kwargs['auto_scale'] else kwargs['nf_dtc'] + nf_dtcr = kwargs['nf_dtcr'] if isinstance(kwargs['nf_dtcr'], int) else 2 img = Constants.QEMU_VM_KERNEL @@ -113,10 +67,10 @@ class QemuManager(object): vif2_mac = 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] = get_affinity_vm( + self.machines_affinity[name] = CpuUtils.get_affinity_nf( nodes=self.nodes, node=node, nf_chains=nf_chains, nf_nodes=nf_nodes, nf_chain=nf_chain, nf_node=nf_node, - cpu_count_int=cpu_count_int, vnf_count_int=vnf_count_int) + vs_dtc=vs_dtc, nf_dtc=nf_dtc, nf_dtcr=nf_dtcr) self.machines[name] = QemuUtils( node=self.nodes[node], qemu_id=qemu_id, @@ -131,10 +85,10 @@ class QemuManager(object): jumbo_frames=kwargs['jumbo']) self.machines[name].qemu_add_vhost_user_if( sock1, jumbo_frames=kwargs['jumbo'], queues=queues, - queue_size=1024) + queue_size=kwargs['perf_qemu_qsz']) self.machines[name].qemu_add_vhost_user_if( sock2, jumbo_frames=kwargs['jumbo'], queues=queues, - queue_size=1024) + queue_size=kwargs['perf_qemu_qsz']) def construct_vms_on_all_nodes(self, **kwargs): """Construct 1..Mx1..N VMs(s) with specified name on all nodes.