From patchwork Tue Mar 15 17:13:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 636621 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2FHDwDJ015557 for ; Tue, 15 Mar 2011 17:13:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932378Ab1CORNz (ORCPT ); Tue, 15 Mar 2011 13:13:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28130 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932357Ab1CORNz (ORCPT ); Tue, 15 Mar 2011 13:13:55 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2FHDrZN007977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Mar 2011 13:13:53 -0400 Received: from freedom.redhat.com (vpn-8-102.rdu.redhat.com [10.11.8.102]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2FHDoHF032377; Tue, 15 Mar 2011 13:13:51 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, mgoldish@redhat.com, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Create a verify_kernel_crash() VM method v2 Date: Tue, 15 Mar 2011 14:13:48 -0300 Message-Id: <1300209228-28322-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 15 Mar 2011 17:13:58 +0000 (UTC) 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