From: lihong <lihongx.ma@intel.com>
To: dts@dpdk.org, weix.xie@intel.com
Cc: lihong <lihongx.ma@intel.com>
Subject: [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip
Date: Thu, 4 Jun 2020 09:38:20 +0800 [thread overview]
Message-ID: <1591234700-19815-3-git-send-email-lihongx.ma@intel.com> (raw)
In-Reply-To: <1591234700-19815-1-git-send-email-lihongx.ma@intel.com>
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@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 prev parent reply other threads:[~2020-06-04 9:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 1:38 [dts] [PATCH V1 0/2] fix issue of ssh vm lihong
2020-06-04 1:38 ` [dts] [PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py lihong
2020-06-05 7:48 ` Xie, WeiX
2020-06-04 1:38 ` lihong [this message]
2020-06-04 9:26 ` [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip Xie, WeiX
2020-06-11 12:17 ` [dts] [PATCH V1 0/2] fix issue of ssh vm Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1591234700-19815-3-git-send-email-lihongx.ma@intel.com \
--to=lihongx.ma@intel.com \
--cc=dts@dpdk.org \
--cc=weix.xie@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).