public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 1/2] KVM test: Create a verify_kernel_crash() VM method v3
Date: Fri, 18 Mar 2011 17:58:27 -0300	[thread overview]
Message-ID: <1300481908-4931-1-git-send-email-lmr@redhat.com> (raw)

A method to verify guest kernel panics can be very
useful for a number of tests. Adapted from a function
present on virtio_console test, create VM.verify_kernel_crash()
and use it on unattended_install.

Changes from v1:
 * According to mgoldish's comments, instead of using
read_nonblocking() and read_until_last_line_matches(),
use simply get_output(), and only throw an exception
at the time we have a full trace.

Changes from v3:
 * Reimplementing the method on a less moronic fashion.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 43ae79c..8114670 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -105,6 +105,15 @@ class VMDeadError(VMError):
                 (self.status, self.output))
 
 
+class VMDeadKernelCrashError(VMError):
+    def __init__(self, kernel_crash):
+        VMError.__init__(self, kernel_crash)
+        self.kernel_crash = kernel_crash
+
+    def __str__(self):
+        return ("VM is dead due to a kernel crash:\n%s" % self.kernel_crash)
+
+
 class VMAddressError(VMError):
     pass
 
@@ -1158,6 +1167,20 @@ class VM:
         return not self.process or not self.process.is_alive()
 
 
+    def verify_kernel_crash(self):
+        """
+        Find kernel crash message on the VM serial console.
+
+        @raise: VMDeadKernelCrashError, in case a kernel crash message was
+                found.
+        """
+        data = self.serial_console.get_output()
+        match = re.search(r"BUG:.*---\[ end trace .* \]---", data,
+                          re.DOTALL|re.MULTILINE)
+        if match is not None:
+            raise VMDeadKernelCrashError(match.group(0))
+
+
     def get_params(self):
         """
         Return the VM's params dict. Most modified params take effect only
-- 
1.7.4

             reply	other threads:[~2011-03-18 20:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 20:58 Lucas Meneghel Rodrigues [this message]
2011-03-18 20:58 ` [PATCH 2/2] KVM test: Use verify_kernel_crash() on unattended install Lucas Meneghel Rodrigues

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=1300481908-4931-1-git-send-email-lmr@redhat.com \
    --to=lmr@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /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