If we put serial init to vm.create(), we could not re-get available session
after close it.
This patch just changes serial to be same as ssh/nc/telnet.

Signed-off-by: Amos Kong <[email protected]>
---
 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index a860437..c609bd0 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -731,14 +731,6 @@ class VM:
 
             logging.debug("VM appears to be alive with PID %s", self.get_pid())
 
-            # Establish a session with the serial console -- requires a version
-            # of netcat that supports -U
-            self.serial_console = kvm_subprocess.kvm_shell_session(
-                "nc -U %s" % self.get_serial_console_filename(),
-                auto_close=False,
-                output_func=kvm_utils.log_line,
-                output_params=("serial-%s.log" % name,))
-
             return True
 
         finally:
@@ -1147,6 +1139,14 @@ class VM:
         linesep = eval("'%s'" % self.params.get("shell_linesep", r"\n"))
         status_test_command = self.params.get("status_test_command", "")
 
+        # Establish a session with the serial console -- requires a version
+        # of netcat that supports -U
+        self.serial_console = kvm_subprocess.kvm_shell_session(
+            "nc -U %s" % self.get_serial_console_filename(),
+            auto_close=False,
+            output_func=kvm_utils.log_line,
+            output_params=("serial-%s.log" % self.name,))
+
         if self.serial_console:
             self.serial_console.set_linesep(linesep)
             self.serial_console.set_status_test_command(status_test_command)
@@ -1159,6 +1159,8 @@ class VM:
         if kvm_utils._remote_login(self.serial_console, username, password,
                                    prompt, timeout):
             return self.serial_console
+        else:
+            self.serial_console.close()
 
 
     def send_key(self, keystr):

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to