test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH 2/2] VT: Support cpu simulate topo in virtualization scenario module
Date: Mon, 21 Sep 2015 15:34:50 +0800	[thread overview]
Message-ID: <1442820890-4631-2-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1442820890-4631-1-git-send-email-yong.liu@intel.com>

From: Marvin Liu <yong.liu@intel.com>

Scene module add "cpu_topo" parameter which will be used as option of DUT instance.
"cpu_topo" should like "2S/5C/2T" mean that this virtual machine contain 20 lcores.
User can utilize "cpu_topo" and "cpu_pin" to make sure simulate topo same as real topo.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/virt_base.py b/framework/virt_base.py
index 16e6d24..4a445d1 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -224,7 +224,7 @@ class VirtBase(object):
         self.load_global_config()
         self.load_local_config(self.suite)
 
-    def start(self, load_config=True, set_target=True, auto_portmap=True, bind_dev=True):
+    def start(self, load_config=True, set_target=True, cpu_topo='', auto_portmap=True, bind_dev=True):
         """
         Start VM and instantiate the VM with VirtDut.
         """
@@ -238,7 +238,7 @@ class VirtBase(object):
             self._start_vm()
 
             # connect vm dut and init running environment
-            vm_dut = self.instantiate_vm_dut(set_target, auto_portmap)
+            vm_dut = self.instantiate_vm_dut(set_target, cpu_topo, auto_portmap)
         except Exception as vm_except:
             if self.handle_exception(vm_except):
                 print dts.RED("Handled expection " + str(type(vm_except)))
@@ -293,7 +293,7 @@ class VirtBase(object):
         """
         NotImplemented
 
-    def instantiate_vm_dut(self, set_target=True, auto_portmap=True, bind_dev=True):
+    def instantiate_vm_dut(self, set_target=True, cpu_topo='', auto_portmap=True, bind_dev=True):
         """
         Instantiate the Dut class for VM.
         """
@@ -317,7 +317,8 @@ class VirtBase(object):
                 serializer,
                 self.virt_type,
                 self.vm_name,
-                self.suite)
+                self.suite,
+                cpu_topo)
         except:
             raise exception.VirtDutConnectException
             return None
diff --git a/framework/virt_scene.py b/framework/virt_scene.py
index 7eb475d..896d86b 100644
--- a/framework/virt_scene.py
+++ b/framework/virt_scene.py
@@ -193,8 +193,19 @@ class VirtScene(object):
         else:
             model = 'host'
 
-        cores = self.host_dut.virt_pool.alloc_cpu(vm=vm_name, number=num,
-                                                  socket=numa)
+        cpu_topo = ''
+        if 'cpu_topo' in cpu_conf.keys():
+            cpu_topo = cpu_conf['cpu_topo']
+
+        pin_cores = []
+        if 'cpu_pin' in cpu_conf.keys():
+            pin_cores = cpu_conf['cpu_pin'].split()
+
+        if len(pin_cores):
+            cores = self.host_dut.virt_pool.alloc_cpu(vm=vm_name, corelist=pin_cores)
+        else:
+            cores = self.host_dut.virt_pool.alloc_cpu(vm=vm_name, number=num,
+                                                      socket=numa)
         core_cfg = ''
         for core in cores:
             core_cfg += '%s ' % core
@@ -203,6 +214,7 @@ class VirtScene(object):
         cpu_param['number'] = num
         cpu_param['model'] = model
         cpu_param['cpupin'] = core_cfg
+        cpu_param['cputopo'] = cpu_topo
 
         # replace with allocated cpus
         params['cpu'] = [cpu_param]
@@ -419,6 +431,12 @@ class VirtScene(object):
         # update vm name
         vm.params[index]['name'][0]['name'] = vm.vm_name
 
+    def get_cputopo(self, params):
+        for param in params:
+            if 'cpu' in param.keys():
+                cpu_topo = param['cpu'][0]['cputopo']
+                return cpu_topo
+
     def start_vms(self):
         self.vms = []
         if self.vm_type == 'kvm':
@@ -434,9 +452,12 @@ class VirtScene(object):
                 scene_params = self.vm_confs[vm_name]
                 # reload merged configurations
                 self.merge_params(vm, scene_params)
+                # get cpu topo
+                topo = self.get_cputopo(scene_params)
                 try:
                     vm_dut = vm.start(load_config=False, set_target=False,
-                                      auto_portmap=self.auto_portmap)
+                                      auto_portmap=self.auto_portmap,
+                                      cpu_topo=topo)
                     if vm_dut is None:
                         raise Exception("Set up VM ENV failed!")
 
-- 
1.9.3

      reply	other threads:[~2015-09-21  7:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21  7:34 [dts] [PATCH 1/2] Optimize virtual dut module for abstract cpu topo Yong Liu
2015-09-21  7:34 ` Yong Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442820890-4631-2-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).