test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [dts 6/9] Support auto_map and set_target flag in vm initialization
Date: Thu, 18 Jun 2015 11:06:41 +0800	[thread overview]
Message-ID: <1434596804-16846-7-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1434596804-16846-1-git-send-email-yong.liu@intel.com>

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

When auto_map flag is True, virt dut will use ping6 function detect network
topology automatically. When set_target flag is False, will not build and use
dpdk in vm dut.

Optimize configuration file load routine and vm start, stop routine.

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

diff --git a/framework/virt_base.py b/framework/virt_base.py
index 3daf42f..9a0035d 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -45,11 +45,10 @@ from utils import remove_old_rsa_key
 
 
 class VirtBase(object):
-
     """
-    Basic module for customer special virtual type. This module implement functions
-    configurated and composed the VM boot command. With these function, we can get
-    and set the VM boot command, and instantiate the VM.
+    Basic module for customer special virtual type. This module implement
+    functions configurated and composed the VM boot command. With these
+    function, we can get and set the VM boot command, and instantiate the VM.
     """
 
     def __init__(self, dut, vm_name, suite_name):
@@ -202,22 +201,29 @@ class VirtBase(object):
         Check whether VM existed.
         """
         vm_status = self.host_session.send_expect(
-            "ps aux | grep qemu | grep 'name %s '| grep -v grep" % self.vm_name, "# ")
+            "ps aux | grep qemu | grep 'name %s '| grep -v grep"
+            % self.vm_name, "# ")
 
         if self.vm_name in vm_status:
             return True
         else:
             return False
 
-    def start(self):
+    def load_config(self):
+        """
+        Load configurations for VM
+        """
+        # load global and suite configuration file
+        self.load_global_config()
+        self.load_local_config(self.suite)
+
+    def start(self, load_config=True, set_target=True, auto_portmap=True):
         """
         Start VM and instantiate the VM with VirtDut.
         """
         try:
-            # load global and suite configuration file
-            self.load_global_config()
-            self.load_local_config(self.suite)
-
+            if load_config is True:
+                self.load_config()
             # compose boot command for different hypervisors
             self.compose_boot_param()
 
@@ -225,12 +231,12 @@ class VirtBase(object):
             self._start_vm()
 
             # connect vm dut and init running environment
-            vm_dut = self.instantiate_vm_dut()
+            vm_dut = self.instantiate_vm_dut(set_target, auto_portmap)
         except Exception as vm_except:
             if self.handle_exception(vm_except):
                 print dts.RED("Handled expection " + str(type(vm_except)))
             else:
-                print dts.RED("Unhandled expection " + str(type(vm_except)) + " !!!")
+                print dts.RED("Unhandled expection " + str(type(vm_except)))
 
             if callable(self.callback):
                 self.callback()
@@ -268,13 +274,19 @@ class VirtBase(object):
         else:
             return False
 
-    def __start_vm(self):
+    def _start_vm(self):
         """
         Start VM.
         """
         NotImplemented
 
-    def instantiate_vm_dut(self):
+    def _stop_vm(self):
+        """
+        Stop VM.
+        """
+        NotImplemented
+
+    def instantiate_vm_dut(self, set_target=True, auto_portmap=True):
         """
         Instantiate the Dut class for VM.
         """
@@ -290,6 +302,7 @@ class VirtBase(object):
 
         try:
             vm_dut = VirtDut(
+                self,
                 crb,
                 serializer,
                 self.virt_type,
@@ -316,9 +329,10 @@ class VirtBase(object):
 
         try:
             # setting up dpdk in vm, must call at last
-            vm_dut.prerequisites(dts.Package, dts.Patches)
-            target = self.host_dut.target
-            vm_dut.set_target(target)
+            vm_dut.prerequisites(dts.Package, dts.Patches, auto_portmap)
+            if set_target:
+                target = self.host_dut.target
+                vm_dut.set_target(target)
         except:
             raise exception.VirtDutInitException(vm_dut)
             return None
@@ -329,7 +343,8 @@ class VirtBase(object):
         """
         Stop the VM.
         """
-        NotImplemented
+        self._stop_vm()
+        self.virt_pool.free_all_resource(self.vm_name)
 
     def register_exit_callback(self, callback):
         """
-- 
1.9.3

  parent reply	other threads:[~2015-06-18  3:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  3:06 [dts] [dts 0/9] Support virtual scenarios Yong Liu
2015-06-18  3:06 ` [dts] [dts 1/9] Optimize config load module with proper execption raised Yong Liu
2015-06-18  3:06 ` [dts] [dts 2/9] Implement virtual scenario module Yong Liu
2015-06-18  3:06 ` [dts] [dts 3/9] Support virtual scenario in dts main process Yong Liu
2015-06-18  3:06 ` [dts] [dts 4/9] Optimize network topology discovery routine in virtual scenario Yong Liu
2015-06-18  3:06 ` [dts] [dts 5/9] Optimize set_target function for " Yong Liu
2015-06-18  3:06 ` Yong Liu [this message]
2015-06-18  3:06 ` [dts] [dts 7/9] Optimize VF devices creation and network devices pass-through function Yong Liu
2015-06-18  3:06 ` [dts] [dts 8/9] Optimize ssh_pexpect and virt_resource module Yong Liu
2015-06-18  3:06 ` [dts] [dts 9/9] Add three typical virtual scenario configuration files Yong Liu

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=1434596804-16846-7-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).