All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] Redirct and make use of the guest serial console
@ 2010-05-11  9:03 Jason Wang
  2010-05-11  9:03 ` [PATCH v2 01/10] KVM test: Introduce prompt assist Jason Wang
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

The guest console is useful for failure troubleshooting especially for
the one who has calltrace. And as we plan to push the network related
test in the next few weeks, we found the serial session in more
reliable during the network testing. So this patchset logs the guest
serial throught the redirectied serial of guest and also enable the
ability to log into guest through serial console. I only open the
serial console for linux, I would do some investigation on windows
guests. 

Change from v1:

- Coding style improvement according to the suggestions from Michael Goldish
- Improve the username sending handling in remote_login()
- Change the matching re of login to [Ll]ogin:\s*$
- Check whether vm have already dead in dumpping thread
- Return none rather than raise exception when met unknown shell_client
- Keep tty0 for all linux guests
- Enable the serial console in unattended installation
- Add a helper to check whether the panic information was occured 
- Keep the porcess() at its original location in preprocess()

---

Jason Wang (10):
      KVM test: Introduce prompt assist
      KVM test: Send the username in remote_login()
      KVM test: Make the login re suitable for serial console
      KVM test: Redirect the serial to the unix domain socket
      KVM test: Log the content from guest serial console
      KVM test: Return none when met unknown type in kvm_vm.remote_login().
      KVM test: Introduce local_login()
      KVM test: Enable the serial console for all linux guests
      KVM test: Enable the serial console during unattended installation
      KVM test: Add a helper to search the panic in the log


 client/tests/kvm/kvm_preprocessing.py        |   59 ++++++++++++++++++++++++++
 client/tests/kvm/kvm_utils.py                |   32 ++++++++++----
 client/tests/kvm/kvm_vm.py                   |   49 ++++++++++++++++++----
 client/tests/kvm/scripts/check_serial.py     |   41 ++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample       |   16 ++++---
 client/tests/kvm/unattended/Fedora-10.ks     |    2 -
 client/tests/kvm/unattended/Fedora-11.ks     |    2 -
 client/tests/kvm/unattended/Fedora-12.ks     |    2 -
 client/tests/kvm/unattended/Fedora-8.ks      |    2 -
 client/tests/kvm/unattended/Fedora-9.ks      |    2 -
 client/tests/kvm/unattended/OpenSUSE-11.xml  |    1 
 client/tests/kvm/unattended/RHEL-3-series.ks |    2 -
 client/tests/kvm/unattended/RHEL-4-series.ks |    2 -
 client/tests/kvm/unattended/RHEL-5-series.ks |    2 -
 client/tests/kvm/unattended/SLES-11.xml      |    1 
 15 files changed, 183 insertions(+), 32 deletions(-)
 create mode 100644 client/tests/kvm/scripts/check_serial.py

-- 
Signature

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

* [PATCH v2 01/10] KVM test: Introduce prompt assist
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
@ 2010-05-11  9:03 ` Jason Wang
  2010-05-12 22:00   ` Lucas Meneghel Rodrigues
  2010-05-11  9:03 ` [PATCH v2 02/10] KVM test: Send the username in remote_login() Jason Wang
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

We need to send an assist string to a session in order to get the
prompt when re-connecting to session through serial. This patch sends
assist string before matching the prompt in remote_login().

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_utils.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 25f3c8c..11f2b1a 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -451,7 +451,8 @@ def check_kvm_source_dir(source_dir):
 # The following are functions used for SSH, SCP and Telnet communication with
 # guests.
 
-def remote_login(command, password, prompt, linesep="\n", timeout=10):
+def remote_login(command, password, prompt, linesep="\n", timeout=10,
+                 prompt_assist=None):
     """
     Log into a remote host (guest) using SSH or Telnet. Run the given command
     using kvm_spawn and provide answers to the questions asked. If timeout
@@ -468,7 +469,8 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10):
     @param timeout: The maximal time duration (in seconds) to wait for each
             step of the login procedure (i.e. the "Are you sure" prompt, the
             password prompt, the shell prompt, etc)
-
+    @param prompt_assist: An assistant string sent before the pattern
+            matching in order to get the prompt for some kinds of shell_client.
     @return Return the kvm_spawn object on success and None on failure.
     """
     sub = kvm_subprocess.kvm_shell_session(command,
@@ -479,6 +481,9 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10):
 
     logging.debug("Trying to login with command '%s'" % command)
 
+    if prompt_assist is not None:
+        sub.sendline(prompt_assist)
+
     while True:
         (match, text) = sub.read_until_last_line_matches(
                 [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"^\s*[Ll]ogin:\s*$",


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

* [PATCH v2 02/10] KVM test: Send the username in remote_login()
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
  2010-05-11  9:03 ` [PATCH v2 01/10] KVM test: Introduce prompt assist Jason Wang
@ 2010-05-11  9:03 ` Jason Wang
  2010-05-11  9:03 ` [PATCH v2 03/10] KVM test: Make the login re suitable for serial console Jason Wang
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

In order to let the serial console work, we must let the
remote_login() send the username when met the username prompt. This
patch fails the progress if if it met the username prompt twice.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_utils.py |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 11f2b1a..2800fae 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -451,7 +451,7 @@ def check_kvm_source_dir(source_dir):
 # The following are functions used for SSH, SCP and Telnet communication with
 # guests.
 
-def remote_login(command, password, prompt, linesep="\n", timeout=10,
+def remote_login(command, username, password, prompt, linesep="\n", timeout=10,
                  prompt_assist=None):
     """
     Log into a remote host (guest) using SSH or Telnet. Run the given command
@@ -462,6 +462,7 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10,
     @brief: Log into a remote host (guest) using SSH or Telnet.
 
     @param command: The command to execute (e.g. "ssh root@localhost")
+    @param username: The username to send in reply to a username prompt
     @param password: The password to send in reply to a password prompt
     @param prompt: The shell prompt that indicates a successful login
     @param linesep: The line separator to send instead of "\\n"
@@ -471,6 +472,7 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10,
             password prompt, the shell prompt, etc)
     @param prompt_assist: An assistant string sent before the pattern
             matching in order to get the prompt for some kinds of shell_client.
+            
     @return Return the kvm_spawn object on success and None on failure.
     """
     sub = kvm_subprocess.kvm_shell_session(command,
@@ -478,6 +480,7 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10,
                                            prompt=prompt)
 
     password_prompt_count = 0
+    login_prompt_count = 0
 
     logging.debug("Trying to login with command '%s'" % command)
 
@@ -505,9 +508,15 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10,
                 sub.close()
                 return None
         elif match == 2:  # "login:"
-            logging.debug("Got unexpected login prompt")
-            sub.close()
-            return None
+            if login_prompt_count == 0:
+                logging.debug("Got username prompt; sending '%s'" % username)
+                sub.sendline(username)
+                login_prompt_count += 1
+                continue
+            else:
+                logging.debug("Got username prompt again")
+                sub.close()
+                return None
         elif match == 3:  # "Connection closed"
             logging.debug("Got 'Connection closed'")
             sub.close()
@@ -644,7 +653,7 @@ def ssh(host, port, username, password, prompt, linesep="\n", timeout=10):
     command = ("ssh -o UserKnownHostsFile=/dev/null "
                "-o PreferredAuthentications=password -p %s %s@%s" %
                (port, username, host))
-    return remote_login(command, password, prompt, linesep, timeout)
+    return remote_login(command, username, password, prompt, linesep, timeout)
 
 
 def telnet(host, port, username, password, prompt, linesep="\n", timeout=10):
@@ -661,7 +670,7 @@ def telnet(host, port, username, password, prompt, linesep="\n", timeout=10):
     @return: kvm_spawn object on success and None on failure.
     """
     command = "telnet -l %s %s %s" % (username, host, port)
-    return remote_login(command, password, prompt, linesep, timeout)
+    return remote_login(command, username, password, prompt, linesep, timeout)
 
 
 def netcat(host, port, username, password, prompt, linesep="\n", timeout=10):
@@ -678,7 +687,7 @@ def netcat(host, port, username, password, prompt, linesep="\n", timeout=10):
     @return: kvm_spawn object on success and None on failure.
     """
     command = "nc %s %s" % (host, port)
-    return remote_login(command, password, prompt, linesep, timeout)
+    return remote_login(command, username, password, prompt, linesep, timeout)
 
 
 # The following are utility functions related to ports.

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

* [PATCH v2 03/10] KVM test: Make the login re suitable for serial console
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
  2010-05-11  9:03 ` [PATCH v2 01/10] KVM test: Introduce prompt assist Jason Wang
  2010-05-11  9:03 ` [PATCH v2 02/10] KVM test: Send the username in remote_login() Jason Wang
@ 2010-05-11  9:03 ` Jason Wang
  2010-05-11  9:03 ` [PATCH v2 04/10] KVM test: Redirect the serial to the unix domain socket Jason Wang
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

Current matching re ^\s*[Ll]ogin:\s*$ is not suitable for the serial
console, so change it to [Ll]ogin:\s*$.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 2800fae..5cb3efb 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -489,7 +489,7 @@ def remote_login(command, username, password, prompt, linesep="\n", timeout=10,
 
     while True:
         (match, text) = sub.read_until_last_line_matches(
-                [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"^\s*[Ll]ogin:\s*$",
+                [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"[Ll]ogin:\s*$",
                  r"[Cc]onnection.*closed", r"[Cc]onnection.*refused",
                  r"[Pp]lease wait", prompt],
                  timeout=timeout, internal_timeout=0.5)

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

* [PATCH v2 04/10] KVM test: Redirect the serial to the unix domain socket
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (2 preceding siblings ...)
  2010-05-11  9:03 ` [PATCH v2 03/10] KVM test: Make the login re suitable for serial console Jason Wang
@ 2010-05-11  9:03 ` Jason Wang
  2010-05-11  9:03 ` [PATCH v2 05/10] KVM test: Log the content from guest serial console Jason Wang
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

This patch redirect the guest serial to the unix domain socket which
would be used by the following patches to dump its content or use it
as a session.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 6bc7987..8f4753f 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -116,17 +116,20 @@ class VM:
         self.address_cache = address_cache
         self.pci_assignable = None
 
-        # Find available monitor filename
+        # Find available filenames for monitor and guest serial redirection
         while True:
-            # The monitor filename should be unique
+            # The filenames should be unique
             self.instance = (time.strftime("%Y%m%d-%H%M%S-") +
                              kvm_utils.generate_random_string(4))
-            self.monitor_file_name = os.path.join("/tmp",
-                                                  "monitor-" + self.instance)
-            if not os.path.exists(self.monitor_file_name):
-                break
-
 
+            names = [os.path.join("/tmp", type + self.instance) for type in
+                     "monitor-", "serial-"]
+            if True in [os.path.exists(file) for file in names]:
+                continue
+            else:
+                [self.monitor_file_name, self.serial_file_name] = names
+                break
+                                                         
     def clone(self, name=None, params=None, root_dir=None, address_cache=None):
         """
         Return a clone of the VM object with optionally modified parameters.
@@ -316,6 +319,8 @@ class VM:
             for pci_id in self.pa_pci_ids:
                 qemu_cmd += " -pcidevice host=%s" % pci_id
 
+        qemu_cmd += " -serial unix:%s,server,nowait" % self.serial_file_name
+
         return qemu_cmd

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

* [PATCH v2 05/10] KVM test: Log the content from guest serial console
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (3 preceding siblings ...)
  2010-05-11  9:03 ` [PATCH v2 04/10] KVM test: Redirect the serial to the unix domain socket Jason Wang
@ 2010-05-11  9:03 ` Jason Wang
  2010-05-11  9:03 ` [PATCH v2 06/10] KVM test: Return none when met unknown type in kvm_vm.remote_login() Jason Wang
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

This patch tries to get the content of guest serial and log it into
the debug directoy of the testcase through a dedicated thread which is
created in the preprocessing and ended in the postprocessing. The
params of serial_mode must be set to "dump" in order to make use of
this feature.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_preprocessing.py  |   59 +++++++++++++++++++++++++++++++-
 client/tests/kvm/tests_base.cfg.sample |    1 +
 2 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 4b9290c..0a33d24 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -1,4 +1,5 @@
 import sys, os, time, commands, re, logging, signal, glob, threading, shutil
+import socket, select
 from autotest_lib.client.bin import test, utils
 from autotest_lib.client.common_lib import error
 import kvm_vm, kvm_utils, kvm_subprocess, ppm_utils
@@ -13,7 +14,8 @@ except ImportError:
 
 _screendump_thread = None
 _screendump_thread_termination_event = None
-
+_serialdump_thread = None
+_serialdump_thread_termination_event = None
 
 def preprocess_image(test, params):
     """
@@ -267,6 +269,16 @@ def preprocess(test, params, env):
                                               args=(test, params, env))
         _screendump_thread.start()
 
+    # Start the serial dump thread
+    if params.get("serial_mode") == "dump":
+        logging.debug("Starting serialdump thread")
+        global _serialdump_thread, _serialdump_thread_termination_event
+        _serialdump_thread_termination_event = threading.Event()
+        _serialdump_thread = threading.Thread(target=_dump_serial_console,
+                                              args=(test, params, env))
+        _serialdump_thread.start()
+
+
 
 def postprocess(test, params, env):
     """
@@ -286,6 +298,13 @@ def postprocess(test, params, env):
         _screendump_thread_termination_event.set()
         _screendump_thread.join(10)
 
+    # Terminate the serialdump thread
+    global _serialdump_thread, _serialdump_thread_termination_event
+    if _serialdump_thread:
+        logging.debug("Terminating serialdump thread...")
+        _serialdump_thread_termination_event.set()
+        _serialdump_thread.join(10)
+
     # Warn about corrupt PPM files
     for f in glob.glob(os.path.join(test.debugdir, "*.ppm")):
         if not ppm_utils.image_verify_ppm_file(f):
@@ -450,3 +469,41 @@ def _take_screendumps(test, params, env):
         if _screendump_thread_termination_event.isSet():
             break
         _screendump_thread_termination_event.wait(delay)
+
+def _dump_serial_console(test, params, env):
+    global _serialdump_thread_termination_event
+    rs = []
+    files = {}
+
+    while True:
+        for vm in kvm_utils.env_get_all_vms(env):
+            if not vm in files and not vm.is_dead():
+                try:
+                    serial_socket = socket.socket(socket.AF_UNIX,
+                                                  socket.SOCK_STREAM)
+                    serial_socket.setblocking(False)
+                    serial_socket.connect(vm.serial_file_name)
+                except:
+                    logging.debug("Could not connect to serial socket for %s" %
+                                  vm.name)
+                    continue
+                rs.append(serial_socket)
+                serial_dump_filename = os.path.join(test.debugdir,
+                                                    "serial-%s" % vm.name)
+                files[vm] = [serial_socket, file(serial_dump_filename, "a+")]
+
+        r, w, x = select.select(rs, [], [], 0.5)
+        for vm in files.keys():
+            (s ,d) = files[vm]
+            if s in r:
+                data = s.recv(16384)
+                if not data:
+                    rs.remove(s)
+                    files.pop(vm)
+                else:
+                    d.write(data)
+                
+        if _serialdump_thread_termination_event.isSet():
+            break
+
+            
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 9f82ffb..169a69e 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -13,6 +13,7 @@ start_vm = yes
 kill_vm = no
 kill_vm_gracefully = yes
 kill_unresponsive_vms = yes
+serial_mode = dump
 
 # Screendump specific stuff
 convert_ppm_files_to_png_on_error = yes

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

* [PATCH v2 06/10] KVM test: Return none when met unknown type in kvm_vm.remote_login().
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (4 preceding siblings ...)
  2010-05-11  9:03 ` [PATCH v2 05/10] KVM test: Log the content from guest serial console Jason Wang
@ 2010-05-11  9:03 ` Jason Wang
  2010-05-11  9:04 ` [PATCH v2 07/10] KVM test: Introduce local_login() Jason Wang
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:03 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

None is returned when met the unknown type of shell_client in
kvm_vm.remote_login() in order to avoid the traceback.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_vm.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 8f4753f..cfebfc1 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -806,7 +806,10 @@ class VM:
         elif client == "nc":
             session = kvm_utils.netcat(address, port, username, password,
                                        prompt, linesep, timeout)
-
+        else:
+            logging.error("Unknown shell_client type %s" % client)
+            return None
+            
         if session:
             session.set_status_test_command(self.params.get("status_test_"
                                                             "command", ""))


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

* [PATCH v2 07/10] KVM test: Introduce local_login()
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (5 preceding siblings ...)
  2010-05-11  9:03 ` [PATCH v2 06/10] KVM test: Return none when met unknown type in kvm_vm.remote_login() Jason Wang
@ 2010-05-11  9:04 ` Jason Wang
  2010-05-11  9:04 ` [PATCH v2 08/10] KVM test: Enable the serial console for all linux guests Jason Wang
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:04 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

This patch introduces a new method which is used to log into the guest
through the guest serial console. The serial_mode must be set to
"session" in order to make use of this patch. Serial does not support
cocurrent sessions, so it doest not aim at replacing the regular
remote shell servers. But it would be useful for the network related
test which may cause the network unresponsive such as driver
load/unload or some kinds of network stress testing.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index cfebfc1..b7151c5 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -815,7 +815,32 @@ class VM:
                                                             "command", ""))
         return session
 
+    def local_login(self, timeout=240):
+        """
+        Log into the guest via serial console
+        If timeout expires while waiting for output from the guest (e.g. a
+        password prompt or a shell prompt) -- fail.
+        """
+
+        serial_mode = self.params.get("serial_mode")
+        username = self.params.get("username", "")
+        password = self.params.get("password", "")
+        prompt = self.params.get("shell_prompt", "[\#\$]")
+        linesep = eval("'%s'" % self.params.get("shell_linesep", r"\n"))
 
+        if serial_mode != "session":
+            logging.debug("serial_mode is not session")
+            return None
+        else:
+            command = "nc -U %s"  % self.serial_file_name
+            assist = self.params.get("prompt_assist", "")
+            session = kvm_utils.remote_login(command, username, password, prompt,
+                                             linesep, timeout, assist)
+            if session:
+                session.set_status_test_command(self.params.get("status_test_"
+                                                                "command", ""))
+            return session
+            
     def copy_files_to(self, local_path, remote_path, nic_index=0, timeout=300):
         """
         Transfer files to the guest.

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

* [PATCH v2 08/10] KVM test: Enable the serial console for all linux guests
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (6 preceding siblings ...)
  2010-05-11  9:04 ` [PATCH v2 07/10] KVM test: Introduce local_login() Jason Wang
@ 2010-05-11  9:04 ` Jason Wang
  2010-05-11  9:04 ` [PATCH v2 09/10] KVM test: Enable the serial console during unattended installation Jason Wang
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:04 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

As we have the ability to dump the content from serial console or use
a session through it, we need to redirect the console to serial
through unattended files to make use of it. The patch also keep the
tty0 accroding to the suggestion of Michael Goldish.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/unattended/Fedora-10.ks     |    2 +-
 client/tests/kvm/unattended/Fedora-11.ks     |    2 +-
 client/tests/kvm/unattended/Fedora-12.ks     |    2 +-
 client/tests/kvm/unattended/Fedora-8.ks      |    2 +-
 client/tests/kvm/unattended/Fedora-9.ks      |    2 +-
 client/tests/kvm/unattended/OpenSUSE-11.xml  |    1 +
 client/tests/kvm/unattended/RHEL-3-series.ks |    2 +-
 client/tests/kvm/unattended/RHEL-4-series.ks |    2 +-
 client/tests/kvm/unattended/RHEL-5-series.ks |    2 +-
 client/tests/kvm/unattended/SLES-11.xml      |    1 +
 10 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/client/tests/kvm/unattended/Fedora-10.ks b/client/tests/kvm/unattended/Fedora-10.ks
index 61e59d7..8da9eec 100644
--- a/client/tests/kvm/unattended/Fedora-10.ks
+++ b/client/tests/kvm/unattended/Fedora-10.ks
@@ -11,7 +11,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 clearpart --all --initlabel
 autopart
diff --git a/client/tests/kvm/unattended/Fedora-11.ks b/client/tests/kvm/unattended/Fedora-11.ks
index 0be7d06..ef978e8 100644
--- a/client/tests/kvm/unattended/Fedora-11.ks
+++ b/client/tests/kvm/unattended/Fedora-11.ks
@@ -10,7 +10,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 
 clearpart --all --initlabel
diff --git a/client/tests/kvm/unattended/Fedora-12.ks b/client/tests/kvm/unattended/Fedora-12.ks
index 0be7d06..ef978e8 100644
--- a/client/tests/kvm/unattended/Fedora-12.ks
+++ b/client/tests/kvm/unattended/Fedora-12.ks
@@ -10,7 +10,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 
 clearpart --all --initlabel
diff --git a/client/tests/kvm/unattended/Fedora-8.ks b/client/tests/kvm/unattended/Fedora-8.ks
index f4a872d..e9a4c53 100644
--- a/client/tests/kvm/unattended/Fedora-8.ks
+++ b/client/tests/kvm/unattended/Fedora-8.ks
@@ -11,7 +11,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 clearpart --all --initlabel
 autopart
diff --git a/client/tests/kvm/unattended/Fedora-9.ks b/client/tests/kvm/unattended/Fedora-9.ks
index f4a872d..e9a4c53 100644
--- a/client/tests/kvm/unattended/Fedora-9.ks
+++ b/client/tests/kvm/unattended/Fedora-9.ks
@@ -11,7 +11,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 clearpart --all --initlabel
 autopart
diff --git a/client/tests/kvm/unattended/OpenSUSE-11.xml b/client/tests/kvm/unattended/OpenSUSE-11.xml
index 7dd44fa..64140bf 100644
--- a/client/tests/kvm/unattended/OpenSUSE-11.xml
+++ b/client/tests/kvm/unattended/OpenSUSE-11.xml
@@ -50,6 +50,7 @@
         <module>edd</module>
       </initrd_module>
     </initrd_modules>
+    <append>console=ttyS0,115200 console=tty0</append>
     <loader_type>grub</loader_type>
     <sections config:type="list"/>
   </bootloader>
diff --git a/client/tests/kvm/unattended/RHEL-3-series.ks b/client/tests/kvm/unattended/RHEL-3-series.ks
index 884b386..dab32f5 100644
--- a/client/tests/kvm/unattended/RHEL-3-series.ks
+++ b/client/tests/kvm/unattended/RHEL-3-series.ks
@@ -10,7 +10,7 @@ rootpw 123456
 firewall --enabled --ssh
 timezone America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 clearpart --all --initlabel
 autopart
 reboot
diff --git a/client/tests/kvm/unattended/RHEL-4-series.ks b/client/tests/kvm/unattended/RHEL-4-series.ks
index ce4a430..4816aa8 100644
--- a/client/tests/kvm/unattended/RHEL-4-series.ks
+++ b/client/tests/kvm/unattended/RHEL-4-series.ks
@@ -11,7 +11,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 clearpart --all --initlabel
 autopart
diff --git a/client/tests/kvm/unattended/RHEL-5-series.ks b/client/tests/kvm/unattended/RHEL-5-series.ks
index f4a872d..e9a4c53 100644
--- a/client/tests/kvm/unattended/RHEL-5-series.ks
+++ b/client/tests/kvm/unattended/RHEL-5-series.ks
@@ -11,7 +11,7 @@ firewall --enabled --ssh
 selinux --enforcing
 timezone --utc America/New_York
 firstboot --disable
-bootloader --location=mbr
+bootloader --location=mbr --append="console=ttyS0,115200 console=tty0"
 zerombr
 clearpart --all --initlabel
 autopart
diff --git a/client/tests/kvm/unattended/SLES-11.xml b/client/tests/kvm/unattended/SLES-11.xml
index 93e5685..4109f93 100644
--- a/client/tests/kvm/unattended/SLES-11.xml
+++ b/client/tests/kvm/unattended/SLES-11.xml
@@ -49,6 +49,7 @@
         <module>edd</module>
       </initrd_module>
     </initrd_modules>
+    <append>console=ttyS0,115200 console=tty0</append>
     <loader_type>grub</loader_type>
     <sections config:type="list"/>
   </bootloader>

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

* [PATCH v2 09/10] KVM test: Enable the serial console during unattended installation
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (7 preceding siblings ...)
  2010-05-11  9:04 ` [PATCH v2 08/10] KVM test: Enable the serial console for all linux guests Jason Wang
@ 2010-05-11  9:04 ` Jason Wang
  2010-05-11  9:04 ` [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log Jason Wang
  2010-05-25 14:50 ` [PATCH v2 00/10] Redirct and make use of the guest serial console Lucas Meneghel Rodrigues
  10 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:04 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

This patch enable the serial console during unattended installation
for all linux guests.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/tests_base.cfg.sample |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 169a69e..3c0933e 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -452,7 +452,7 @@ variants:
                     pxe_initrd = "initrd.img"
                     tftp = "images/tftpboot"
                     extra_params += " -bootp /pxelinux.0 -boot cn"
-                    kernel_args = "ks=floppy nicdelay=60"
+                    kernel_args = "ks=floppy nicdelay=60 console=ttyS0,115200 console=tty0"
 
                 variants:
                     - 8.32:
@@ -592,7 +592,7 @@ variants:
                     pxe_initrd = "initrd"
                     tftp = "images/tftpboot"
                     extra_params += " -bootp /pxelinux.0 -boot cn"
-                    kernel_args = "autoyast=floppy"
+                    kernel_args = "autoyast=floppy console=ttyS0,115200 console=tty0"
                     post_install_delay = 10
 
                 variants:
@@ -674,7 +674,7 @@ variants:
                     pxe_image = "linux"
                     pxe_initrd = "initrd"
                     extra_params += " -bootp /pxelinux.0 -boot n"
-                    kernel_args = "autoyast=floppy"
+                    kernel_args = "autoyast=floppy console=ttyS0,115200 console=tty0"
                     post_install_delay = 10
 
                 variants:
@@ -733,7 +733,7 @@ variants:
                     pxe_initrd = "initrd.img"
                     tftp = "images/tftpboot"
                     extra_params += " -bootp /pxelinux.0 -boot cn"
-                    kernel_args = "ks=floppy nicdelay=60"
+                    kernel_args = "ks=floppy nicdelay=60 console=ttyS0,115200 console=tty0"
 
                 variants:
                     - 3.9.i386:

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

* [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (8 preceding siblings ...)
  2010-05-11  9:04 ` [PATCH v2 09/10] KVM test: Enable the serial console during unattended installation Jason Wang
@ 2010-05-11  9:04 ` Jason Wang
  2010-05-12  9:44   ` Michael Goldish
  2010-05-25 14:50 ` [PATCH v2 00/10] Redirct and make use of the guest serial console Lucas Meneghel Rodrigues
  10 siblings, 1 reply; 17+ messages in thread
From: Jason Wang @ 2010-05-11  9:04 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm

This checker serves as the post_command to find the panic information
in the file which contains the content of guest serial console.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/scripts/check_serial.py |   41 ++++++++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample   |    7 ++++-
 2 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 client/tests/kvm/scripts/check_serial.py

diff --git a/client/tests/kvm/scripts/check_serial.py b/client/tests/kvm/scripts/check_serial.py
new file mode 100644
index 0000000..969bbe3
--- /dev/null
+++ b/client/tests/kvm/scripts/check_serial.py
@@ -0,0 +1,41 @@
+import os, sys, glob, re
+
+
+class SerialCheckerError(Exception):
+    """
+    Simple wrapper for the builtin Exception class.
+    """
+    pass
+
+
+class SerialChecker(object):
+    """
+    Serach the panic or other keywords in the guest serial.
+    """
+    def __init__(self):
+        """
+        Gets params from environment variables and sets class attributes.
+        """
+        client_dir =  os.environ['AUTODIR']
+        self.pattern = os.environ['KVM_TEST_search_pattern']
+        self.shortname = os.environ['KVM_TEST_shortname']
+        self.debugdir = os.path.join(client_dir, "results/default/kvm.%s/debug" \
+                                     % self.shortname)
+        self.serial_files = glob.glob(os.path.join(self.debugdir, 'serial*'))
+
+
+    def check(self):
+        """
+        Check whether the pattern were found in the serial files
+        """
+        fail = [ f for f in self.serial_files if
+                 re.findall(self.pattern, file(f).read(), re.I) ]
+        if fail:
+            print "%s is found in %s" % (self.pattern, fail)
+            raise SerialCheckerError("Error found during the check, Please" \
+                                     " check the log")
+
+
+if __name__ == "__main__":
+    checker = SerialChecker()
+    checker.check()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 3c0933e..3ac8f0d 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -52,6 +52,10 @@ address_index = 0
 # Misc
 profilers = kvm_stat
 
+# pattern serach in guest serial console
+serach_pattern = panic
+post_command = "python scripts/check_serial.py"
+post_command_noncritical = no
 
 # Tests
 variants:
@@ -1314,10 +1318,9 @@ virtio|virtio_blk|e1000|balloon_check:
 variants:
     - @qcow2:
         image_format = qcow2
-        post_command = " python scripts/check_image.py;"
+        post_command = " python scripts/check_image.py; python scripts/check_serial.py"
         remove_image = no
         post_command_timeout = 600
-        post_command_noncritical = yes
     - vmdk:
         only Fedora Ubuntu Windows
         only smp2


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

* Re: [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log
  2010-05-11  9:04 ` [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log Jason Wang
@ 2010-05-12  9:44   ` Michael Goldish
  2010-05-17  7:28     ` Jason Wang
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Goldish @ 2010-05-12  9:44 UTC (permalink / raw)
  To: Jason Wang; +Cc: lmr, autotest, kvm

On 05/11/2010 12:04 PM, Jason Wang wrote:
> This checker serves as the post_command to find the panic information
> in the file which contains the content of guest serial console.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  client/tests/kvm/scripts/check_serial.py |   41 ++++++++++++++++++++++++++++++
>  client/tests/kvm/tests_base.cfg.sample   |    7 ++++-
>  2 files changed, 46 insertions(+), 2 deletions(-)
>  create mode 100644 client/tests/kvm/scripts/check_serial.py
> 
> diff --git a/client/tests/kvm/scripts/check_serial.py b/client/tests/kvm/scripts/check_serial.py
> new file mode 100644
> index 0000000..969bbe3
> --- /dev/null
> +++ b/client/tests/kvm/scripts/check_serial.py
> @@ -0,0 +1,41 @@
> +import os, sys, glob, re
> +
> +
> +class SerialCheckerError(Exception):
> +    """
> +    Simple wrapper for the builtin Exception class.
> +    """
> +    pass
> +
> +
> +class SerialChecker(object):
> +    """
> +    Serach the panic or other keywords in the guest serial.
> +    """
> +    def __init__(self):
> +        """
> +        Gets params from environment variables and sets class attributes.
> +        """
> +        client_dir =  os.environ['AUTODIR']
> +        self.pattern = os.environ['KVM_TEST_search_pattern']
> +        self.shortname = os.environ['KVM_TEST_shortname']
> +        self.debugdir = os.path.join(client_dir, "results/default/kvm.%s/debug" \

I think the final backslash is unnecessary.

> +                                     % self.shortname)
> +        self.serial_files = glob.glob(os.path.join(self.debugdir, 'serial*'))
> +
> +
> +    def check(self):
> +        """
> +        Check whether the pattern were found in the serial files
> +        """
> +        fail = [ f for f in self.serial_files if
> +                 re.findall(self.pattern, file(f).read(), re.I) ]
> +        if fail:
> +            print "%s is found in %s" % (self.pattern, fail)
> +            raise SerialCheckerError("Error found during the check, Please" \

Same here.

> +                                     " check the log")
> +
> +
> +if __name__ == "__main__":
> +    checker = SerialChecker()
> +    checker.check()

I wonder why we need a class.  Why not just put all the code here?

> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> index 3c0933e..3ac8f0d 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -52,6 +52,10 @@ address_index = 0
>  # Misc
>  profilers = kvm_stat
>  
> +# pattern serach in guest serial console
> +serach_pattern = panic
> +post_command = "python scripts/check_serial.py"
> +post_command_noncritical = no
>  
>  # Tests
>  variants:
> @@ -1314,10 +1318,9 @@ virtio|virtio_blk|e1000|balloon_check:
>  variants:
>      - @qcow2:
>          image_format = qcow2
> -        post_command = " python scripts/check_image.py;"
> +        post_command = " python scripts/check_image.py; python scripts/check_serial.py"
                        ^
This should be +=, because post_command may have been previously
assigned some value.

>          remove_image = no
>          post_command_timeout = 600
> -        post_command_noncritical = yes
>      - vmdk:
>          only Fedora Ubuntu Windows
>          only smp2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH v2 01/10] KVM test: Introduce prompt assist
  2010-05-11  9:03 ` [PATCH v2 01/10] KVM test: Introduce prompt assist Jason Wang
@ 2010-05-12 22:00   ` Lucas Meneghel Rodrigues
  0 siblings, 0 replies; 17+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-05-12 22:00 UTC (permalink / raw)
  To: Jason Wang; +Cc: autotest, kvm

Hi Jason, just hold on cause next week I'm back and will finish work
on your patchset.

Cheers,

On Tue, May 11, 2010 at 6:03 AM, Jason Wang <jasowang@redhat.com> wrote:
> We need to send an assist string to a session in order to get the
> prompt when re-connecting to session through serial. This patch sends
> assist string before matching the prompt in remote_login().
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  client/tests/kvm/kvm_utils.py |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
> index 25f3c8c..11f2b1a 100644
> --- a/client/tests/kvm/kvm_utils.py
> +++ b/client/tests/kvm/kvm_utils.py
> @@ -451,7 +451,8 @@ def check_kvm_source_dir(source_dir):
>  # The following are functions used for SSH, SCP and Telnet communication with
>  # guests.
>
> -def remote_login(command, password, prompt, linesep="\n", timeout=10):
> +def remote_login(command, password, prompt, linesep="\n", timeout=10,
> +                 prompt_assist=None):
>     """
>     Log into a remote host (guest) using SSH or Telnet. Run the given command
>     using kvm_spawn and provide answers to the questions asked. If timeout
> @@ -468,7 +469,8 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10):
>     @param timeout: The maximal time duration (in seconds) to wait for each
>             step of the login procedure (i.e. the "Are you sure" prompt, the
>             password prompt, the shell prompt, etc)
> -
> +    @param prompt_assist: An assistant string sent before the pattern
> +            matching in order to get the prompt for some kinds of shell_client.
>     @return Return the kvm_spawn object on success and None on failure.
>     """
>     sub = kvm_subprocess.kvm_shell_session(command,
> @@ -479,6 +481,9 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10):
>
>     logging.debug("Trying to login with command '%s'" % command)
>
> +    if prompt_assist is not None:
> +        sub.sendline(prompt_assist)
> +
>     while True:
>         (match, text) = sub.read_until_last_line_matches(
>                 [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"^\s*[Ll]ogin:\s*$",
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>



-- 
Lucas

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

* Re: [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log
  2010-05-12  9:44   ` Michael Goldish
@ 2010-05-17  7:28     ` Jason Wang
  2010-05-17 21:23       ` Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Wang @ 2010-05-17  7:28 UTC (permalink / raw)
  To: Michael Goldish; +Cc: lmr, autotest, kvm

Michael Goldish wrote:
> On 05/11/2010 12:04 PM, Jason Wang wrote:
>   
>> This checker serves as the post_command to find the panic information
>> in the file which contains the content of guest serial console.
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>>  client/tests/kvm/scripts/check_serial.py |   41 ++++++++++++++++++++++++++++++
>>  client/tests/kvm/tests_base.cfg.sample   |    7 ++++-
>>  2 files changed, 46 insertions(+), 2 deletions(-)
>>  create mode 100644 client/tests/kvm/scripts/check_serial.py
>>
>> diff --git a/client/tests/kvm/scripts/check_serial.py b/client/tests/kvm/scripts/check_serial.py
>> new file mode 100644
>> index 0000000..969bbe3
>> --- /dev/null
>> +++ b/client/tests/kvm/scripts/check_serial.py
>> @@ -0,0 +1,41 @@
>> +import os, sys, glob, re
>> +
>> +
>> +class SerialCheckerError(Exception):
>> +    """
>> +    Simple wrapper for the builtin Exception class.
>> +    """
>> +    pass
>> +
>> +
>> +class SerialChecker(object):
>> +    """
>> +    Serach the panic or other keywords in the guest serial.
>> +    """
>> +    def __init__(self):
>> +        """
>> +        Gets params from environment variables and sets class attributes.
>> +        """
>> +        client_dir =  os.environ['AUTODIR']
>> +        self.pattern = os.environ['KVM_TEST_search_pattern']
>> +        self.shortname = os.environ['KVM_TEST_shortname']
>> +        self.debugdir = os.path.join(client_dir, "results/default/kvm.%s/debug" \
>>     
>
> I think the final backslash is unnecessary.
>
>   
>> +                                     % self.shortname)
>> +        self.serial_files = glob.glob(os.path.join(self.debugdir, 'serial*'))
>> +
>> +
>> +    def check(self):
>> +        """
>> +        Check whether the pattern were found in the serial files
>> +        """
>> +        fail = [ f for f in self.serial_files if
>> +                 re.findall(self.pattern, file(f).read(), re.I) ]
>> +        if fail:
>> +            print "%s is found in %s" % (self.pattern, fail)
>> +            raise SerialCheckerError("Error found during the check, Please" \
>>     
>
> Same here.
>
>   
>> +                                     " check the log")
>> +
>> +
>> +if __name__ == "__main__":
>> +    checker = SerialChecker()
>> +    checker.check()
>>     
>
> I wonder why we need a class.  Why not just put all the code here?
>
>   
Just follow the style of other pre_command, maybe Lucas like it.
>> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
>> index 3c0933e..3ac8f0d 100644
>> --- a/client/tests/kvm/tests_base.cfg.sample
>> +++ b/client/tests/kvm/tests_base.cfg.sample
>> @@ -52,6 +52,10 @@ address_index = 0
>>  # Misc
>>  profilers = kvm_stat
>>  
>> +# pattern serach in guest serial console
>> +serach_pattern = panic
>> +post_command = "python scripts/check_serial.py"
>> +post_command_noncritical = no
>>  
>>  # Tests
>>  variants:
>> @@ -1314,10 +1318,9 @@ virtio|virtio_blk|e1000|balloon_check:
>>  variants:
>>      - @qcow2:
>>          image_format = qcow2
>> -        post_command = " python scripts/check_image.py;"
>> +        post_command = " python scripts/check_image.py; python scripts/check_serial.py"
>>     
>                         ^
> This should be +=, because post_command may have been previously
> assigned some value.
>
>   
Would change it, and do you have any other comments about this patchset?
>>          remove_image = no
>>          post_command_timeout = 600
>> -        post_command_noncritical = yes
>>      - vmdk:
>>          only Fedora Ubuntu Windows
>>          only smp2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>     
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   


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

* Re: [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log
  2010-05-17  7:28     ` Jason Wang
@ 2010-05-17 21:23       ` Lucas Meneghel Rodrigues
  0 siblings, 0 replies; 17+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-05-17 21:23 UTC (permalink / raw)
  To: Jason Wang; +Cc: autotest, kvm

On Mon, 2010-05-17 at 15:28 +0800, Jason Wang wrote:
> Michael Goldish wrote:
> > On 05/11/2010 12:04 PM, Jason Wang wrote:
> >   
> >> This checker serves as the post_command to find the panic information
> >> in the file which contains the content of guest serial console.
> >>
> >> Signed-off-by: Jason Wang <jasowang@redhat.com>
> >> ---
> >>  client/tests/kvm/scripts/check_serial.py |   41 ++++++++++++++++++++++++++++++
> >>  client/tests/kvm/tests_base.cfg.sample   |    7 ++++-
> >>  2 files changed, 46 insertions(+), 2 deletions(-)
> >>  create mode 100644 client/tests/kvm/scripts/check_serial.py
> >>
> >> diff --git a/client/tests/kvm/scripts/check_serial.py b/client/tests/kvm/scripts/check_serial.py
> >> new file mode 100644
> >> index 0000000..969bbe3
> >> --- /dev/null
> >> +++ b/client/tests/kvm/scripts/check_serial.py
> >> @@ -0,0 +1,41 @@
> >> +import os, sys, glob, re
> >> +
> >> +
> >> +class SerialCheckerError(Exception):
> >> +    """
> >> +    Simple wrapper for the builtin Exception class.
> >> +    """
> >> +    pass
> >> +
> >> +
> >> +class SerialChecker(object):
> >> +    """
> >> +    Serach the panic or other keywords in the guest serial.

^ Typo here, search.

> >> +    """
> >> +    def __init__(self):
> >> +        """
> >> +        Gets params from environment variables and sets class attributes.
> >> +        """
> >> +        client_dir =  os.environ['AUTODIR']
> >> +        self.pattern = os.environ['KVM_TEST_search_pattern']
> >> +        self.shortname = os.environ['KVM_TEST_shortname']
> >> +        self.debugdir = os.path.join(client_dir, "results/default/kvm.%s/debug" \
> >>     
> >
> > I think the final backslash is unnecessary.
> >
> >   
> >> +                                     % self.shortname)
> >> +        self.serial_files = glob.glob(os.path.join(self.debugdir, 'serial*'))
> >> +
> >> +
> >> +    def check(self):
> >> +        """
> >> +        Check whether the pattern were found in the serial files
> >> +        """
> >> +        fail = [ f for f in self.serial_files if
> >> +                 re.findall(self.pattern, file(f).read(), re.I) ]
> >> +        if fail:
> >> +            print "%s is found in %s" % (self.pattern, fail)
> >> +            raise SerialCheckerError("Error found during the check, Please" \
> >>     
> >
> > Same here.
> >
> >   
> >> +                                     " check the log")
> >> +
> >> +
> >> +if __name__ == "__main__":
> >> +    checker = SerialChecker()
> >> +    checker.check()
> >>     
> >
> > I wonder why we need a class.  Why not just put all the code here?
> >
> >   
> Just follow the style of other pre_command, maybe Lucas like it.

When I made the first pre command script, I opted to use a class to
represent the unattended install setup, and other pre commands followed
this style. Since the code is small, I see no problem in putting it
under __main__ altogether. So Jason, you can remove the code from the
class and put it under __main__, please.

> >> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> >> index 3c0933e..3ac8f0d 100644
> >> --- a/client/tests/kvm/tests_base.cfg.sample
> >> +++ b/client/tests/kvm/tests_base.cfg.sample
> >> @@ -52,6 +52,10 @@ address_index = 0
> >>  # Misc
> >>  profilers = kvm_stat
> >>  
> >> +# pattern serach in guest serial console
> >> +serach_pattern = panic

^ typo, should be search_pattern

> >> +post_command = "python scripts/check_serial.py"
> >> +post_command_noncritical = no
> >>  
> >>  # Tests
> >>  variants:
> >> @@ -1314,10 +1318,9 @@ virtio|virtio_blk|e1000|balloon_check:
> >>  variants:
> >>      - @qcow2:
> >>          image_format = qcow2
> >> -        post_command = " python scripts/check_image.py;"
> >> +        post_command = " python scripts/check_image.py; python scripts/check_serial.py"
> >>     
> >                         ^
> > This should be +=, because post_command may have been previously
> > assigned some value.
> >
> >   
> Would change it, and do you have any other comments about this patchset?

Other than the issues pointed out, looks good.

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

* Re: [PATCH v2 00/10] Redirct and make use of the guest serial console
  2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
                   ` (9 preceding siblings ...)
  2010-05-11  9:04 ` [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log Jason Wang
@ 2010-05-25 14:50 ` Lucas Meneghel Rodrigues
  2010-05-28  8:19   ` Jason Wang
  10 siblings, 1 reply; 17+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-05-25 14:50 UTC (permalink / raw)
  To: Jason Wang; +Cc: autotest, kvm, Michael Goldish

On Tue, 2010-05-11 at 17:03 +0800, Jason Wang wrote:
> The guest console is useful for failure troubleshooting especially for
> the one who has calltrace. And as we plan to push the network related
> test in the next few weeks, we found the serial session in more
> reliable during the network testing. So this patchset logs the guest
> serial throught the redirectied serial of guest and also enable the
> ability to log into guest through serial console. I only open the
> serial console for linux, I would do some investigation on windows
> guests. 
> 
> Change from v1:
> 
> - Coding style improvement according to the suggestions from Michael Goldish
> - Improve the username sending handling in remote_login()
> - Change the matching re of login to [Ll]ogin:\s*$
> - Check whether vm have already dead in dumpping thread
> - Return none rather than raise exception when met unknown shell_client
> - Keep tty0 for all linux guests
> - Enable the serial console in unattended installation
> - Add a helper to check whether the panic information was occured 
> - Keep the porcess() at its original location in preprocess()

Jason, after a long conversation I've had with Michael during the
previous week, we reached some common points:

1 - We believe it is possible to be able to both log in *and* log serial
console output. That will require changes to kvm_subprocess and might
take a little bit more time.
2 - We know you guys are depending on this patchset to be accepted in
order to proceed with the network related cases. However, we ask for a
little more patience, and we'd like to get your opinions on the patches
that we are going to roll out. This way we can get to a better solution
for all of us.

So, please bear with us and I'll try to see with Michael and Dor if we
can prioritize this work to not block work items for you guys.

Cheers,

Lucas


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

* Re: [PATCH v2 00/10] Redirct and make use of the guest serial console
  2010-05-25 14:50 ` [PATCH v2 00/10] Redirct and make use of the guest serial console Lucas Meneghel Rodrigues
@ 2010-05-28  8:19   ` Jason Wang
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Wang @ 2010-05-28  8:19 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm

Lucas Meneghel Rodrigues wrote:
> On Tue, 2010-05-11 at 17:03 +0800, Jason Wang wrote:
>   
>> The guest console is useful for failure troubleshooting especially for
>> the one who has calltrace. And as we plan to push the network related
>> test in the next few weeks, we found the serial session in more
>> reliable during the network testing. So this patchset logs the guest
>> serial throught the redirectied serial of guest and also enable the
>> ability to log into guest through serial console. I only open the
>> serial console for linux, I would do some investigation on windows
>> guests. 
>>
>> Change from v1:
>>
>> - Coding style improvement according to the suggestions from Michael Goldish
>> - Improve the username sending handling in remote_login()
>> - Change the matching re of login to [Ll]ogin:\s*$
>> - Check whether vm have already dead in dumpping thread
>> - Return none rather than raise exception when met unknown shell_client
>> - Keep tty0 for all linux guests
>> - Enable the serial console in unattended installation
>> - Add a helper to check whether the panic information was occured 
>> - Keep the porcess() at its original location in preprocess()
>>     
>
> Jason, after a long conversation I've had with Michael during the
> previous week, we reached some common points:
>
> 1 - We believe it is possible to be able to both log in *and* log serial
> console output. That will require changes to kvm_subprocess and might
> take a little bit more time.
>   
Yes, I've tried a ugly implementation of a server in serial_dump_thread
( finally dropped from my patch ), so I agree that it would be much more
elegant if I can get the support from kvm_subprocess.
> 2 - We know you guys are depending on this patchset to be accepted in
> order to proceed with the network related cases. However, we ask for a
> little more patience, and we'd like to get your opinions on the patches
> that we are going to roll out. This way we can get to a better solution
> for all of us.
>
> So, please bear with us and I'll try to see with Michael and Dor if we
> can prioritize this work to not block work items for you guys.
>
> Cheers,
>
> Lucas
>
>   
Ok, no problem.

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

end of thread, other threads:[~2010-05-28  8:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-11  9:03 [PATCH v2 00/10] Redirct and make use of the guest serial console Jason Wang
2010-05-11  9:03 ` [PATCH v2 01/10] KVM test: Introduce prompt assist Jason Wang
2010-05-12 22:00   ` Lucas Meneghel Rodrigues
2010-05-11  9:03 ` [PATCH v2 02/10] KVM test: Send the username in remote_login() Jason Wang
2010-05-11  9:03 ` [PATCH v2 03/10] KVM test: Make the login re suitable for serial console Jason Wang
2010-05-11  9:03 ` [PATCH v2 04/10] KVM test: Redirect the serial to the unix domain socket Jason Wang
2010-05-11  9:03 ` [PATCH v2 05/10] KVM test: Log the content from guest serial console Jason Wang
2010-05-11  9:03 ` [PATCH v2 06/10] KVM test: Return none when met unknown type in kvm_vm.remote_login() Jason Wang
2010-05-11  9:04 ` [PATCH v2 07/10] KVM test: Introduce local_login() Jason Wang
2010-05-11  9:04 ` [PATCH v2 08/10] KVM test: Enable the serial console for all linux guests Jason Wang
2010-05-11  9:04 ` [PATCH v2 09/10] KVM test: Enable the serial console during unattended installation Jason Wang
2010-05-11  9:04 ` [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log Jason Wang
2010-05-12  9:44   ` Michael Goldish
2010-05-17  7:28     ` Jason Wang
2010-05-17 21:23       ` Lucas Meneghel Rodrigues
2010-05-25 14:50 ` [PATCH v2 00/10] Redirct and make use of the guest serial console Lucas Meneghel Rodrigues
2010-05-28  8:19   ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.