From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 1F4B51B8AF for ; Tue, 15 May 2018 12:06:49 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F3F151529; Tue, 15 May 2018 03:06:48 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (unknown [10.169.106.172]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 36B493F23C; Tue, 15 May 2018 03:06:48 -0700 (PDT) From: Phil Yang To: dts@dpdk.org Cc: nd@arm.com, phil.yang@arm.com, yong.liu@intel.com Date: Tue, 15 May 2018 18:06:18 +0800 Message-Id: <1526378779-10530-1-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH 1/2] framework/qemu_kvm: fix vm control session failure 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: Tue, 15 May 2018 10:06:50 -0000 For telnet vm control, it will continuously fail to login to vm when it doesn't read login prompt during first time connection. So extend the connection time to get more output each time. For socket vm control, added LOGIN_PROMPT into the login status check for other platform. Keep the connection longer to avoid failure and reconnection. Signed-off-by: Phil Yang --- framework/qemu_kvm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index ec33669..57d16f6 100644 --- a/framework/qemu_kvm.py +++ b/framework/qemu_kvm.py @@ -979,7 +979,7 @@ class QEMUKvm(VirtBase): Connect to serial port and return connected session for usage if connected failed will return None """ - shell_reg = r"(\s*)\[(.*)\]# " + shell_reg = r"(.*)# " try: if getattr(self, 'control_session', None) is None: self.control_session = self.host_session @@ -987,7 +987,7 @@ class QEMUKvm(VirtBase): self.control_session.send_command("nc -U %s" % self.serial_path) # login message not ouput if timeout too small - out = self.control_session.send_command("", timeout=5).replace('\r', '').replace('\n', '') + out = self.control_session.send_command("", timeout=15).replace('\r', '').replace('\n', '') if len(out) == 0: raise StartVMFailedException("Can't get output from [%s:%s]" % (self.host_dut.crb['My IP'], self.vm_name)) @@ -1025,7 +1025,7 @@ class QEMUKvm(VirtBase): Connect to serial port and return connected session for usage if connected failed will return None """ - shell_reg = r"(\s*)\[(.*)\]# " + shell_reg = r"(.*)# " scan_cmd = "lsof -i:%d | grep telnet | awk '{print $2}'" % self.serial_port try: @@ -1034,9 +1034,10 @@ class QEMUKvm(VirtBase): self.control_session = self.host_session self.control_session.send_expect("telnet localhost %d" % self.serial_port, "Connected to localhost", timeout=self.OPERATION_TIMEOUT) + time.sleep(5) # output will be empty if timeout too small - out = self.control_session.send_command("", timeout=5).replace('\r', '').replace('\n', '') + out = self.control_session.send_command("", timeout=10).replace('\r', '').replace('\n', '') # if no output from serial port, either connection close or system hang if len(out) == 0: @@ -1058,7 +1059,7 @@ class QEMUKvm(VirtBase): return True # login into Redhat os, not sure can work on all distributions - if "x86_64 on an x86_64" not in out: + if ("x86_64 on an x86_64" not in out) and (self.LOGIN_PROMPT not in out): print RED("[%s:%s] not ready for login" % (self.host_dut.crb['My IP'], self.vm_name)) return False else: -- 2.7.4