From patchwork Mon Jan 3 18:27:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 448691 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 p03IRBb8024206 for ; Mon, 3 Jan 2011 18:27:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751847Ab1ACS0y (ORCPT ); Mon, 3 Jan 2011 13:26:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25626 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751760Ab1ACS0w (ORCPT ); Mon, 3 Jan 2011 13:26:52 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p03IQpoH019978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 Jan 2011 13:26:51 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p03IQpOt005586; Mon, 3 Jan 2011 13:26:51 -0500 Received: from moof.tlv.redhat.com (dhcp-1-185.tlv.redhat.com [10.35.1.185]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p03IQeWZ027298; Mon, 3 Jan 2011 13:26:50 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 07/17] KVM test: introduce VM exceptions Date: Mon, 3 Jan 2011 20:27:08 +0200 Message-Id: <1294079238-21239-7-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294079238-21239-1-git-send-email-mgoldish@redhat.com> References: <1294079238-21239-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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.3 (demeter1.kernel.org [140.211.167.41]); Mon, 03 Jan 2011 18:27:22 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index e310401..c237fbe 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -11,6 +11,152 @@ from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils +class VMError(Exception): + pass + + +class VMCreateError(VMError): + def __init__(self, cmd, status, output): + VMError.__init__(self, cmd, status, output) + self.cmd = cmd + self.status = status + self.output = output + + def __str__(self): + return ("VM creation command failed: %r (status: %s, output: %r)" % + (self.cmd, self.status, self.output)) + + +class VMHashMismatchError(VMError): + def __init__(self, actual, expected): + VMError.__init__(self, actual, expected) + self.actual_hash = actual + self.expected_hash = expected + + def __str__(self): + return ("CD image hash (%s) differs from expected one (%s)" % + (self.actual_hash, self.expected_hash)) + + +class VMImageMissingError(VMError): + def __init__(self, filename): + VMError.__init__(self, filename) + self.filename = filename + + def __str__(self): + return "CD image file not found: %r" % self.filename + + +class VMBadPATypeError(VMError): + def __init__(self, pa_type): + VMError.__init__(self, pa_type) + self.pa_type = pa_type + + def __str__(self): + return "Unsupported PCI assignable type: %r" % self.pa_type + + +class VMPAError(VMError): + def __init__(self, pa_type): + VMError.__init__(self, pa_type) + self.pa_type = pa_type + + def __str__(self): + return ("No PCI assignable devices could be assigned " + "(pci_assignable=%r)" % self.pa_type) + + +class VMPostCreateError(VMError): + def __init__(self, cmd, output): + VMError.__init__(self, cmd, output) + self.cmd = cmd + self.output = output + + +class VMHugePageError(VMPostCreateError): + def __str__(self): + return ("Cannot allocate hugepage memory (command: %r, output: %r)" % + (self.cmd, self.output)) + + +class VMKVMInitError(VMPostCreateError): + def __str__(self): + return ("Cannot initialize KVM (command: %r, output: %r)" % + (self.cmd, self.output)) + + +class VMDeadError(VMError): + pass + + +class VMAddressError(VMError): + pass + + +class VMPortNotRedirectedError(VMAddressError): + def __init__(self, port): + VMAddressError.__init__(self, port) + self.port = port + + def __str__(self): + return "Port not redirected: %s" % self.port + + +class VMAddressVerificationError(VMAddressError): + def __init__(self, mac, ip): + VMAddressError.__init__(self, mac, ip) + self.mac = mac + self.ip = ip + + def __str__(self): + return "Cannot verify MAC-IP address mapping: %s ---> %s" % (self.mac, + self.ip) + + +class VMMACAddressMissingError(VMAddressError): + def __init__(self, nic_index): + VMAddressError.__init__(self, nic_index) + self.nic_index = nic_index + + def __str__(self): + return "No MAC address defined for NIC #%s" % self.nic_index + + +class VMIPAddressMissingError(VMAddressError): + def __init__(self, mac): + VMAddressError.__init__(self, mac) + self.mac = mac + + def __str__(self): + return "Cannot find IP address for MAC address %s" % self.mac + + +class VMMigrateError(VMError): + pass + + +class VMMigrateTimeoutError(VMMigrateError): + pass + + +class VMMigrateCancelError(VMMigrateError): + pass + + +class VMMigrateFailedError(VMMigrateError): + pass + + +class VMMigrateStateMismatchError(VMMigrateError): + def __init__(self, src_hash, dst_hash): + self.src_hash = src_hash + self.dst_hash = dst_hash + + def __str__(self): + return ("Mismatch of VM state before and after migration (%s != %s)" % + (self.src_hash, self.dst_hash)) + + def get_image_filename(params, root_dir): """ Generate an image path from params and root_dir.