monitor socket will be initiated at the beginning of '*Monitor.__init__', if exception occur in this function, socket will not be closed correctly. In this case, 'Monitor.__del__' function should be executed explicitly.
Signed-off-by: Qingtang Zhou <[email protected]> --- client/virt/kvm_monitor.py | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py index aff716a..7e97a3e 100644 --- a/client/virt/kvm_monitor.py +++ b/client/virt/kvm_monitor.py @@ -171,6 +171,7 @@ class HumanMonitor(Monitor): # Find the initial (qemu) prompt s, o = self._read_up_to_qemu_prompt(20) if not s: + Monitor.__del__(self) raise MonitorProtocolError("Could not find (qemu) prompt " "after connecting to monitor. " "Output so far: %r" % o) @@ -179,6 +180,7 @@ class HumanMonitor(Monitor): self._help_str = self.cmd("help", debug=False) except MonitorError, e: + Monitor.__del__(self) if suppress_exceptions: logging.warn(e) else: @@ -427,6 +429,7 @@ class QMPMonitor(Monitor): try: json except NameError: + Monitor.__del__(self) raise MonitorNotSupportedError("QMP requires the json module " "(Python 2.6 and up)") @@ -441,12 +444,14 @@ class QMPMonitor(Monitor): break time.sleep(0.1) else: + Monitor.__del__(self) raise MonitorProtocolError("No QMP greeting message received") # Issue qmp_capabilities self.cmd("qmp_capabilities") except MonitorError, e: + Monitor.__del__(self) if suppress_exceptions: logging.warn(e) else: -- 1.7.4.1 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
