Tested-by: Xie,WeiX < weix.xie@intel.com> Regards, Xie Wei -----Original Message----- From: Ma, LihongX Sent: Thursday, June 4, 2020 9:38 AM To: dts@dpdk.org; Xie, WeiX Cc: Ma, LihongX Subject: [dts][PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip If the vm os version is relatively new, the ip allocation may be before the ssh service start. So add the action of check the ssh service status before get vm ip. Signed-off-by: lihong --- framework/qemu_kvm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index 757737e..421ee3e 100644 --- a/framework/qemu_kvm.py +++ b/framework/qemu_kvm.py @@ -1829,6 +1829,11 @@ class QEMUKvm(VirtBase): if self.control_type == "qga": # wait few seconds for network ready time.sleep(5) + # before get the ip, check the ssh service is ok + # if the ssh service if ready, the file /run/sshd.pid will store the pid + out = self.control_session.send_expect(self.qga_cmd_head + "cat /run/sshd.pid" , "#", timeout=self.OPERATION_TIMEOUT) + if out == '': + return "Failed" out = self.control_session.send_expect(self.qga_cmd_head + "ifconfig" , "#", timeout=self.OPERATION_TIMEOUT) else: pci = "00:1f.0" @@ -1838,6 +1843,10 @@ class QEMUKvm(VirtBase): if self.nic_model == "virtio": pci += "/virtio*/" + # before get the ip, check the ssh service is ok + out = self.control_session.send_expect("ls /run/sshd.pid", "# ", timeout=self.OPERATION_TIMEOUT, verify=True) + if isinstance(out, int): + return "Failed" intf = self.control_session.send_expect("ls -1 /sys/bus/pci/devices/0000:%s/net" %pci, "#", timeout=self.OPERATION_TIMEOUT) out = self.control_session.send_expect("ifconfig %s" % intf, "#", timeout=self.OPERATION_TIMEOUT) if "10.0.2" not in out: -- 2.7.4