From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=BDupka?= Subject: [KVM-Autotest][PATCH 1/5] virt: Check illegal instruction code Date: Tue, 31 Jan 2012 15:40:13 +0100 Message-ID: <1328020817-8159-2-git-send-email-jzupka@redhat.com> References: <1328020817-8159-1-git-send-email-jzupka@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, lmr@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1751 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753506Ab2AaOkb (ORCPT ); Tue, 31 Jan 2012 09:40:31 -0500 In-Reply-To: <1328020817-8159-1-git-send-email-jzupka@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Add a check on the base VM class for illegal instruction code executed by the VM. That check is performed on the serial console output. Signed-off-by: Ji=C5=99=C3=AD =C5=BDupka --- client/virt/virt_vm.py | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/client/virt/virt_vm.py b/client/virt/virt_vm.py index 32593c1..d4fb47d 100644 --- a/client/virt/virt_vm.py +++ b/client/virt/virt_vm.py @@ -133,6 +133,18 @@ class VMDeadKernelCrashError(VMError): return ("VM is dead due to a kernel crash:\n%s" % self.kernel_= crash) =20 =20 +class VMInvalidInstructionCode(VMError): + def __init__(self, invalid_code): + VMError.__init__(self, invalid_code) + self.invalid_code =3D invalid_code + + def __str__(self): + error =3D "" + for invalid_code in self.invalid_code: + error +=3D "%s" % (invalid_code) + return ("Invalid instruction was executed on VM:\n%s" % error) + + class VMAddressError(VMError): pass =20 @@ -656,6 +668,21 @@ class BaseVM(object): raise VMDeadKernelCrashError(match.group(0)) =20 =20 + def verify_illegal_instructonn(self): + """ + Find illegal instruction code on VM serial console output. + + @raise: VMInvalidInstructionCode, in case a wrong instruction = code. + """ + if self.serial_console is not None: + data =3D self.serial_console.get_output() + match =3D re.findall(r".*trap invalid opcode.*\n", data, + re.MULTILINE) + + if match: + raise VMInvalidInstructionCode(match) + + def get_params(self): """ Return the VM's params dict. Most modified params take effect = only --=20 1.7.7.6