[dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip

Xie, WeiX weix.xie at intel.com
Thu Jun 4 11:26:48 CEST 2020


Tested-by:  Xie,WeiX < weix.xie at intel.com>

Regards,
Xie Wei

-----Original Message-----
From: Ma, LihongX 
Sent: Thursday, June 4, 2020 9:38 AM
To: dts at dpdk.org; Xie, WeiX <weix.xie at intel.com>
Cc: Ma, LihongX <lihongx.ma at intel.com>
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 <lihongx.ma at intel.com>
---
 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestVmHotplug.log
Type: application/octet-stream
Size: 7263124 bytes
Desc: TestVmHotplug.log
URL: <http://mails.dpdk.org/archives/dts/attachments/20200604/2e738814/attachment-0001.obj>


More information about the dts mailing list