From patchwork Mon Oct 18 13:13:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 261841 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 o9IDDq0x020134 for ; Mon, 18 Oct 2010 13:13:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755041Ab0JRNNt (ORCPT ); Mon, 18 Oct 2010 09:13:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1026 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754992Ab0JRNNr (ORCPT ); Mon, 18 Oct 2010 09:13:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9IDDlrl030281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Oct 2010 09:13:47 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9IDDkjD021919; Mon, 18 Oct 2010 09:13:46 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o9IDDebt007914; Mon, 18 Oct 2010 09:13:45 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: kvm_monitor.py: add __str__() method to QMPCmdError exception Date: Mon, 18 Oct 2010 15:13:40 +0200 Message-Id: <1287407620-30026-4-git-send-email-mgoldish@redhat.com> In-Reply-To: <1287407620-30026-3-git-send-email-mgoldish@redhat.com> References: <1287407620-30026-1-git-send-email-mgoldish@redhat.com> <1287407620-30026-2-git-send-email-mgoldish@redhat.com> <1287407620-30026-3-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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, 18 Oct 2010 13:13:53 +0000 (UTC) diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py index b887060..40be77d 100644 --- a/client/tests/kvm/kvm_monitor.py +++ b/client/tests/kvm/kvm_monitor.py @@ -38,7 +38,9 @@ class MonitorNotSupportedError(MonitorError): class QMPCmdError(MonitorError): - pass + def __str__(self): + return ("QMP command '%s' failed (arguments: %r, error message: %r)" % + tuple(self.args)) class Monitor: @@ -501,8 +503,8 @@ class QMPMonitor(Monitor): @raise MonitorSendError: Raised if the command cannot be sent @raise MonitorProtocolError: Raised if no response is received @raise QMPCmdError: Raised if the response is an error message - (the exception's args are (msg, data) where msg is a string and - data is the error data) + (the exception's args are (cmd, args, data) where data is the + error data) """ if not self._acquire_lock(20): raise MonitorLockError("Could not acquire exclusive lock to send " @@ -524,7 +526,7 @@ class QMPMonitor(Monitor): if "return" in r: return r["return"] if "error" in r: - raise QMPCmdError("QMP command '%s' failed" % cmd, r["error"]) + raise QMPCmdError(cmd, args, r["error"]) finally: self._lock.release()