test suite reviews and discussions
 help / color / mirror / Atom feed
From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dts] [PATCH 3/7] framework virt_base: add vm status concept
Date: Thu, 14 Jul 2016 21:17:29 +0800	[thread overview]
Message-ID: <1468502253-1276-4-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1468502253-1276-1-git-send-email-yong.liu@intel.com>

1. Add vm status concept, default status is running. Status will be
changed after hypervisor module detected status change.
2. Add new function support connect vm dut after migration done.

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

diff --git a/framework/virt_base.py b/framework/virt_base.py
index efad384..5cd2854 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -43,6 +43,10 @@ from settings import CONFIG_ROOT_PATH
 from virt_dut import VirtDut
 from utils import remove_old_rsa_key
 
+ST_NOTSTART = "NOTSTART"
+ST_PAUSE = "PAUSE"
+ST_RUNNING = "RUNNING"
+ST_UNKNOWN = "UNKNOWN"
 
 class VirtBase(object):
     """
@@ -86,6 +90,9 @@ class VirtBase(object):
         # default call back function is None
         self.callback = None
 
+        # vm status is running by default, only be changed in internal module
+        self.vm_status = ST_RUNNING
+
     def get_virt_type(self):
         """
         Get the virtual type, such as KVM, XEN or LIBVIRT.
@@ -224,7 +231,7 @@ class VirtBase(object):
         self.load_global_config()
         self.load_local_config(self.suite)
 
-    def start(self, load_config=True, set_target=True, cpu_topo='', bind_dev=True):
+    def start(self, load_config=True, set_target=True, cpu_topo=''):
         """
         Start VM and instantiate the VM with VirtDut.
         """
@@ -237,8 +244,12 @@ class VirtBase(object):
             # start virutal machine
             self._start_vm()
 
-            # connect vm dut and init running environment
-            vm_dut = self.instantiate_vm_dut(set_target, cpu_topo)
+            if self.vm_status is ST_RUNNING:
+                # connect vm dut and init running environment
+                vm_dut = self.instantiate_vm_dut(set_target, cpu_topo)
+            else:
+                vm_dut = None
+
         except Exception as vm_except:
             if self.handle_exception(vm_except):
                 print dts.RED("Handled expection " + str(type(vm_except)))
@@ -251,6 +262,25 @@ class VirtBase(object):
             return None
         return vm_dut
 
+    def migrated_start(self, set_target=True, cpu_topo=''):
+        """
+        Instantiate the VM after migration done
+        There's no need to load param and start VM because VM has been started
+        """
+        try:
+            if self.vm_status is ST_PAUSE:
+                # connect backup vm dut and it just inherited from host
+                vm_dut = self.instantiate_vm_dut(set_target, cpu_topo, bind_dev=False)
+        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)))
+
+            return None
+
+        return vm_dut
+
     def handle_exception(self, vm_except):
         # show exception back trace
         exc_type, exc_value, exc_traceback = sys.exc_info()
@@ -357,10 +387,19 @@ class VirtBase(object):
         """
         Stop the VM.
         """
-        self.vm_dut.close()
-        self.vm_dut.logger.logger_exit()
-        self.vm_dut = None
+        # vm_dut may not init in migration case
+        if getattr(self, 'vm_dut', None):
+            if self.vm_status is ST_RUNNING:
+                self.vm_dut.close()
+            else:
+                # when vm is not running, not close session forcely
+                self.vm_dut.close(force=True)
+
+            self.vm_dut.logger.logger_exit()
+            self.vm_dut = None
+
         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:[~2016-07-14 13:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 13:17 [dts] [PATCH 0/7] support vhost live migration automation Marvin Liu
2016-07-14 13:17 ` [dts] [PATCH 1/7] framework: support close ssh session without logout Marvin Liu
2016-07-14 13:17 ` [dts] [PATCH 2/7] framework tester: fix typo issue Marvin Liu
2016-07-14 13:17 ` Marvin Liu [this message]
2016-07-14 13:17 ` [dts] [PATCH 4/7] framework qemu_kvm: support migration and serial port Marvin Liu
2016-07-14 13:17 ` [dts] [PATCH 5/7] conf: add configuration file for vhost_user_live_migration suite Marvin Liu
2016-07-14 13:17 ` [dts] [PATCH 6/7] test_plans: add test plan " Marvin Liu
2016-07-14 13:17 ` [dts] [PATCH 7/7] tests: add " Marvin 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=1468502253-1276-4-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).