<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Reviewed and Tested-by: Chandra Shekhar Reddy Potula <a
        class="moz-txt-link-rfc2396E"
        href="mailto:chandra@linux.vnet.ibm.com">&lt;chandra@linux.vnet.ibm.com&gt;</a></p>
    <br>
    <div class="moz-cite-prefix">On 10/13/16 2:36 PM,
      <a class="moz-txt-link-abbreviated" href="mailto:archus@linux.vnet.ibm.com">archus@linux.vnet.ibm.com</a> wrote:<br>
    </div>
    <blockquote
      cite="mid:1476349615-13011-1-git-send-email-archus@linux.vnet.ibm.com"
      type="cite">
      <pre wrap="">From: Archana Singh <a class="moz-txt-link-rfc2396E" href="mailto:archus@linux.vnet.ibm.com">&lt;archus@linux.vnet.ibm.com&gt;</a>

Socket server gets closed for VM's serial console connection if its not readable instead writeable.
This is due to fact that _is_vm_listening_serial(...) only call _test_output if its readable
and not on writeable. Adding libvirt.VIR_STREAM_EVENT_WRITABLE solve the issue.
Also added libvirt.VIR_STREAM_EVENT_HANGUP event so that in case of hangup also
console gets connected.

Signed-off-by: Archana Singh <a class="moz-txt-link-rfc2396E" href="mailto:archus@linux.vnet.ibm.com">&lt;archus@linux.vnet.ibm.com&gt;</a>
---
 serialconsole.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/serialconsole.py b/serialconsole.py
index 13ef331..725f55d 100644
--- a/serialconsole.py
+++ b/serialconsole.py
@@ -101,7 +101,9 @@ class SocketServer(Process):
             while not is_listening:
                 libvirt.virEventRunDefaultImpl()

-        console.eventAddCallback(libvirt.VIR_STREAM_EVENT_READABLE,
+        console.eventAddCallback(libvirt.VIR_STREAM_EVENT_READABLE |
+                                 libvirt.VIR_STREAM_EVENT_WRITABLE |
+                                 libvirt.VIR_STREAM_EVENT_HANGUP,
                                  _test_output,
                                  None)
         libvirt_loop = threading.Thread(target=_event_loop)
@@ -111,6 +113,7 @@ class SocketServer(Process):
         libvirt_loop.join(1)

         if not libvirt_loop.is_alive():
+            wok_log.error("console libvirt stream is not listening to event")
             console.eventRemoveCallback()
             return True

</pre>
    </blockquote>
    <br>
  </body>
</html>