From: 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> References: <1313025227-10524-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: autotest@test.kernel.org Return-path: In-Reply-To: <1313025227-10524-1-git-send-email-lmr@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org 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): -- 1.7.6