[PATCH] KVM test: Create a verify_kernel_crash() VM method v2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 43ae79c..e5bbf23 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,26 @@ class VM:
         return not self.process or not self.process.is_alive()
 
 
+    def verify_kernel_crash(self, timeout=2):
+        """
+        Find kernel crash message on serial console.
+
+        @param timeout: Timeout used to verify expected output.
+
+        @raise: VMDeadKernelCrashError, in case a kernel crash message was
+                found.
+        """
+        data = self.serial_console.get_output()
+        match = re.search("BUG:", data, re.MULTILINE)
+        if match is not None:
+            # Let's raise an exception only if we get a full trace
+            # (which will probably happen on the next verification)
+            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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux