From patchwork Thu Aug 11 01:13:47 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: 1055532 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7B1ECPQ021846 for ; Thu, 11 Aug 2011 01:14:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755587Ab1HKBOI (ORCPT ); Wed, 10 Aug 2011 21:14:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57834 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755582Ab1HKBOE (ORCPT ); Wed, 10 Aug 2011 21:14:04 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7B1E3FJ015626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 10 Aug 2011 21:14:03 -0400 Received: from freedom.local.com (vpn-10-65.rdu.redhat.com [10.11.10.65]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7B1DwXU031219; Wed, 10 Aug 2011 21:14:02 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 3/3] client.virt.kvm_monitor: Throw less cryptic exceptions Date: Wed, 10 Aug 2011 22:13:47 -0300 Message-Id: <1313025227-10524-3-git-send-email-lmr@redhat.com> In-Reply-To: <1313025227-10524-1-git-send-email-lmr@redhat.com> References: <1313025227-10524-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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]); Thu, 11 Aug 2011 01:14:13 +0000 (UTC) Sometimes, when the kvm monitor code tries to verify if there is data available on the monitor socket, a socket.error might be thrown, leading to somewhat cryptic error messages, such as: raise error(EBADF, 'Bad file descriptor') error: [Errno 9] Bad file descriptor So, wrap the select operation on a try block and raise a more comprehensive MonitorSocketError, along with the original exception. Also, turning the error into a MonitorError makes KVM autotest to not blow when trying to get a screendump from the VM during postprocessing. Signed-off-by: Lucas Meneghel Rodrigues --- client/virt/kvm_monitor.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py index c96f062..7e6a055 100644 --- a/client/virt/kvm_monitor.py +++ b/client/virt/kvm_monitor.py @@ -120,7 +120,10 @@ class Monitor: def _data_available(self, timeout=0): timeout = max(0, timeout) - return bool(select.select([self._socket], [], [], timeout)[0]) + try: + return bool(select.select([self._socket], [], [], timeout)[0]) + except socket.error, e: + raise MonitorSocketError("Verifying data on monitor socket", e) def _recvall(self):