[dts] [PATCH 2/5] Change virtual machine default directory to host base_dir.
Yong Liu
yong.liu at intel.com
Thu Jun 4 08:28:36 CEST 2015
From: Marvin Liu <yong.liu at intel.com>
Add islive function in virt_base module to check whether vm is alive.
Signed-off-by: Marvin Liu <yong.liu at intel.com>
diff --git a/framework/virt_base.py b/framework/virt_base.py
index 12aa318..3daf42f 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -69,6 +69,8 @@ class VirtBase(object):
# replace dut session
self.host_session = self.host_dut.host_session
self.host_logger = self.host_dut.logger
+ # base_dir existed for host dut has prepared it
+ self.host_session.send_expect("cd %s" % self.host_dut.base_dir, "# ")
# init the host resouce pool for VM
self.virt_pool = self.host_dut.virt_pool
@@ -81,6 +83,7 @@ class VirtBase(object):
self.virt_type = self.get_virt_type()
self.params = []
+
# default call back function is None
self.callback = None
@@ -141,6 +144,7 @@ class VirtBase(object):
if key in param.keys():
param[key] = value
return
+
self.params.append({key: value})
def compose_boot_param(self):
@@ -193,6 +197,18 @@ class VirtBase(object):
"""
NotImplemented
+ def isalive(self):
+ """
+ Check whether VM existed.
+ """
+ vm_status = self.host_session.send_expect(
+ "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):
"""
Start VM and instantiate the VM with VirtDut.
--
1.9.3
More information about the dts
mailing list