diff mbox

[3/3] client.virt.kvm_monitor: Throw less cryptic exceptions

Message ID 1313025227-10524-3-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Aug. 11, 2011, 1:13 a.m. 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 <lmr@redhat.com>
---
 client/virt/kvm_monitor.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff mbox

Patch

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):