test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1 0/2] fix issue of ssh vm
@ 2020-06-04  1:38 lihong
  2020-06-04  1:38 ` [dts] [PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py lihong
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: lihong @ 2020-06-04  1:38 UTC (permalink / raw)
  To: dts, weix.xie; +Cc: lihong


lihong (2):
  QMP: optimization file qemu-ga-client and qmp.py
  framework/qemu_kvm: check the ssh service status before get vm ip

 dep/QMP/qemu-ga-client | 10 ++++++----
 dep/QMP/qmp.py         |  4 ++--
 framework/qemu_kvm.py  |  9 +++++++++
 3 files changed, 17 insertions(+), 6 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dts] [PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py
  2020-06-04  1:38 [dts] [PATCH V1 0/2] fix issue of ssh vm lihong
@ 2020-06-04  1:38 ` lihong
  2020-06-05  7:48   ` Xie, WeiX
  2020-06-04  1:38 ` [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip lihong
  2020-06-11 12:17 ` [dts] [PATCH V1 0/2] fix issue of ssh vm Tu, Lijuan
  2 siblings, 1 reply; 6+ messages in thread
From: lihong @ 2020-06-04  1:38 UTC (permalink / raw)
  To: dts, weix.xie; +Cc: lihong

1. modify code to support python3
2. return None string if file not exist when use cat command

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 dep/QMP/qemu-ga-client | 10 ++++++----
 dep/QMP/qmp.py         |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/dep/QMP/qemu-ga-client b/dep/QMP/qemu-ga-client
index 46676c3..caf44b1 100755
--- a/dep/QMP/qemu-ga-client
+++ b/dep/QMP/qemu-ga-client
@@ -68,7 +68,7 @@ class QemuGuestAgentClient:
 
     def __file_read_all(self, handle):
         eof = False
-        data = ''
+        data = b''
         while not eof:
             ret = self.qga.file_read(handle=handle, count=1024)
             _data = base64.b64decode(ret['buf-b64'])
@@ -77,7 +77,10 @@ class QemuGuestAgentClient:
         return data
 
     def read(self, path):
-        handle = self.qga.file_open(path=path)
+        try:
+            handle = self.qga.file_open(path=path)
+        except:
+            return ''
         try:
             data = self.__file_read_all(handle)
         finally:
@@ -162,7 +165,6 @@ class QemuGuestAgentClient:
         except self.qga.timeout:
             return
 
-
 def _cmd_cat(client, args):
     if len(args) != 1:
         print('Invalid argument')
@@ -259,7 +261,7 @@ def main(address, cmd, args):
 
     try:
         client = QemuGuestAgentClient(address)
-    except QemuGuestAgent.error, e:
+    except QemuGuestAgent.error as e:
         import errno
 
         print(e)
diff --git a/dep/QMP/qmp.py b/dep/QMP/qmp.py
index 9e6f4cf..430887d 100755
--- a/dep/QMP/qmp.py
+++ b/dep/QMP/qmp.py
@@ -108,7 +108,7 @@ class QEMUMonitorProtocol:
                 been closed
         """
         try:
-            self.__sock.sendall(json.dumps(qmp_cmd))
+            self.__sock.sendall(str.encode(json.dumps(qmp_cmd)))
         except socket.error as err:
             if err[0] == errno.EPIPE:
                 return
@@ -135,7 +135,7 @@ class QEMUMonitorProtocol:
         if not ret:
             return
         else:
-            if 'error' in ret:
+            if 'error' in ret.keys():
                 raise Exception(ret['error']['desc'])
             return ret['return']
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip
  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-04  1:38 ` lihong
  2020-06-04  9:26   ` Xie, WeiX
  2020-06-11 12:17 ` [dts] [PATCH V1 0/2] fix issue of ssh vm Tu, Lijuan
  2 siblings, 1 reply; 6+ messages in thread
From: lihong @ 2020-06-04  1:38 UTC (permalink / raw)
  To: dts, weix.xie; +Cc: lihong

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip
  2020-06-04  1:38 ` [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip lihong
@ 2020-06-04  9:26   ` Xie, WeiX
  0 siblings, 0 replies; 6+ messages in thread
From: Xie, WeiX @ 2020-06-04  9:26 UTC (permalink / raw)
  To: Ma, LihongX, dts

[-- Attachment #1: Type: text/plain, Size: 2245 bytes --]

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 <weix.xie@intel.com>
Cc: Ma, LihongX <lihongx.ma@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@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


[-- Attachment #2: TestVmHotplug.log --]
[-- Type: application/octet-stream, Size: 7263124 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dts] [PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py
  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
  0 siblings, 0 replies; 6+ messages in thread
From: Xie, WeiX @ 2020-06-05  7:48 UTC (permalink / raw)
  To: Ma, LihongX, dts

[-- Attachment #1: Type: text/plain, Size: 2578 bytes --]

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 <weix.xie@intel.com>
Cc: Ma, LihongX <lihongx.ma@intel.com>
Subject: [dts][PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py

1. modify code to support python3
2. return None string if file not exist when use cat command

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 dep/QMP/qemu-ga-client | 10 ++++++----
 dep/QMP/qmp.py         |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/dep/QMP/qemu-ga-client b/dep/QMP/qemu-ga-client index 46676c3..caf44b1 100755
--- a/dep/QMP/qemu-ga-client
+++ b/dep/QMP/qemu-ga-client
@@ -68,7 +68,7 @@ class QemuGuestAgentClient:
 
     def __file_read_all(self, handle):
         eof = False
-        data = ''
+        data = b''
         while not eof:
             ret = self.qga.file_read(handle=handle, count=1024)
             _data = base64.b64decode(ret['buf-b64']) @@ -77,7 +77,10 @@ class QemuGuestAgentClient:
         return data
 
     def read(self, path):
-        handle = self.qga.file_open(path=path)
+        try:
+            handle = self.qga.file_open(path=path)
+        except:
+            return ''
         try:
             data = self.__file_read_all(handle)
         finally:
@@ -162,7 +165,6 @@ class QemuGuestAgentClient:
         except self.qga.timeout:
             return
 
-
 def _cmd_cat(client, args):
     if len(args) != 1:
         print('Invalid argument')
@@ -259,7 +261,7 @@ def main(address, cmd, args):
 
     try:
         client = QemuGuestAgentClient(address)
-    except QemuGuestAgent.error, e:
+    except QemuGuestAgent.error as e:
         import errno
 
         print(e)
diff --git a/dep/QMP/qmp.py b/dep/QMP/qmp.py index 9e6f4cf..430887d 100755
--- a/dep/QMP/qmp.py
+++ b/dep/QMP/qmp.py
@@ -108,7 +108,7 @@ class QEMUMonitorProtocol:
                 been closed
         """
         try:
-            self.__sock.sendall(json.dumps(qmp_cmd))
+            self.__sock.sendall(str.encode(json.dumps(qmp_cmd)))
         except socket.error as err:
             if err[0] == errno.EPIPE:
                 return
@@ -135,7 +135,7 @@ class QEMUMonitorProtocol:
         if not ret:
             return
         else:
-            if 'error' in ret:
+            if 'error' in ret.keys():
                 raise Exception(ret['error']['desc'])
             return ret['return']
 
--
2.7.4


[-- Attachment #2: TestVmHotplug.log --]
[-- Type: application/octet-stream, Size: 7263124 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dts] [PATCH V1 0/2] fix issue of ssh vm
  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-04  1:38 ` [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip lihong
@ 2020-06-11 12:17 ` Tu, Lijuan
  2 siblings, 0 replies; 6+ messages in thread
From: Tu, Lijuan @ 2020-06-11 12:17 UTC (permalink / raw)
  To: Ma, LihongX, dts, Xie, WeiX; +Cc: Ma, LihongX

Applied the series, thanks

-----Original Message-----
From: dts <dts-bounces@dpdk.org> On Behalf Of lihong
Sent: 2020年6月4日 9:38
To: dts@dpdk.org; Xie, WeiX <weix.xie@intel.com>
Cc: Ma, LihongX <lihongx.ma@intel.com>
Subject: [dts] [PATCH V1 0/2] fix issue of ssh vm


lihong (2):
  QMP: optimization file qemu-ga-client and qmp.py
  framework/qemu_kvm: check the ssh service status before get vm ip

 dep/QMP/qemu-ga-client | 10 ++++++----
 dep/QMP/qmp.py         |  4 ++--
 framework/qemu_kvm.py  |  9 +++++++++
 3 files changed, 17 insertions(+), 6 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-11 12:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip lihong
2020-06-04  9:26   ` Xie, WeiX
2020-06-11 12:17 ` [dts] [PATCH V1 0/2] fix issue of ssh vm Tu, Lijuan

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).