From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 87915C54A for ; Thu, 18 Jun 2015 05:07:04 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 17 Jun 2015 20:07:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,636,1427785200"; d="scan'208";a="589977933" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 17 Jun 2015 20:07:03 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t5I372nL009073; Thu, 18 Jun 2015 11:07:02 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t5I36xZR016924; Thu, 18 Jun 2015 11:07:01 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t5I36xBd016920; Thu, 18 Jun 2015 11:06:59 +0800 From: Yong Liu To: dts@dpdk.org Date: Thu, 18 Jun 2015 11:06:41 +0800 Message-Id: <1434596804-16846-7-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1434596804-16846-1-git-send-email-yong.liu@intel.com> References: <1434596804-16846-1-git-send-email-yong.liu@intel.com> Subject: [dts] [dts 6/9] Support auto_map and set_target flag in vm initialization X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2015 03:07:05 -0000 From: Marvin Liu 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 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