<div dir="auto"><div>Reviewed-by: Aline Manera &lt;<a href="mailto:alinemanera@gmail.com">alinemanera@gmail.com</a>&gt;</div><div dir="auto"><br></div><div dir="auto">I will test and apply it upstream tomorrow. </div><div dir="auto"><br></div><div dir="auto">Thanks, </div><div dir="auto"><br><div data-smartmail="gmail_signature" dir="auto">Aline Manera </div><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Oct 31, 2017 04:28, &quot;Fu.Lin&quot; &lt;<a href="mailto:lfu@suse.com">lfu@suse.com</a>&gt; wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p><tt>Long ago, I submitted an issue:
        <a class="m_-6347471772743292624moz-txt-link-freetext" href="https://github.com/kimchi-project/kimchi/issues/1170" target="_blank">https://github.com/kimchi-<wbr>project/kimchi/issues/1170</a> ...</tt></p>
    <p><tt>Test by following script:</tt></p>
    <blockquote>
      <p><tt>import subprocess<br>
          import os<br>
          import time<br>
          <br>
          def _check_remote_libvirt_conn(<wbr>remote_host,<br>
                  user=&#39;root&#39;, transport=&#39;ssh&#39;):<br>
          <br>
              FNULL = open(os.devnull, &#39;w&#39;)<br>
              dest_uri = &#39;qemu+%s://%s@%s/system&#39; % (transport, user,
          remote_host)<br>
              cmd = [&#39;virsh&#39;, &#39;-c&#39;, dest_uri, &#39;list&#39;]<br>
              proc = subprocess.Popen(cmd, stdout=FNULL, stderr=FNULL,<br>
                      shell=True, preexec_fn=os.setsid)<br>
              timeout = 0<br>
              while proc.poll() is None:<br>
                  time.sleep(1)<br>
                  timeout += 1<br>
                  if timeout == 5:<br>
                      print(&quot;killed&quot;)<br>
                      os.killpg(os.getpgid(proc.pid)<wbr>, signal.SIGTERM)<br>
          <br>
          if __name__ == &#39;__main__&#39;:<br>
              _check_remote_libvirt_conn(&#39;<wbr>localhost&#39;)</tt></p>
    </blockquote>
    <p><tt>`proc` is timeout every time although the connection is
        normal tested by `virsh -c &lt;uri&gt;` list <br>
      </tt></p>
    <p><tt><br>
      </tt></p>
    <p><tt>The following is the reason of changing(From Python Document
        2.7.14):<br>
      </tt></p>
    <p><tt> Do not use stdout=PIPE or stderr=PIPE with this function as
        <font color="#330099">that can deadlock</font> based on the
        child process output volume. Use Popen with the communicate()
        method when you need pipes.</tt></p>
    <p><tt> Using shell=True can be <font color="#330099">a security
          hazard</font>. See the warning under Frequently Used Arguments
        for details.<br>
      </tt></p>
    <p><tt>At the same time, if not change, it does not work.<br>
      </tt></p>
    <p><tt><br>
      </tt></p>
    <p><tt>diff --git a/model/vms.py b/model/vms.py</tt><tt><br>
      </tt><tt>index 6da4f3b..92e771f 100644</tt><tt><br>
      </tt><tt>--- a/model/vms.py</tt><tt><br>
      </tt><tt>+++ b/model/vms.py</tt><tt><br>
      </tt><tt>@@ -1885,10 +1885,11 @@ class VMModel(object):</tt><tt><br>
      </tt><tt>     def _check_remote_libvirt_conn(<wbr>self, remote_host,</tt><tt><br>
      </tt><tt>                              <wbr>      user=&#39;root&#39;,
        transport=&#39;ssh&#39;):</tt><tt><br>
      </tt><tt> </tt><tt><br>
      </tt><tt>+        FNULL = open(os.devnull, &#39;w&#39;)</tt><tt><br>
      </tt><tt>         dest_uri = &#39;qemu+%s://%s@%s/system&#39; %
        (transport, user, remote_host)</tt><tt><br>
      </tt><tt>         cmd = [&#39;virsh&#39;, &#39;-c&#39;, dest_uri, &#39;list&#39;]</tt><tt><br>
      </tt><tt>-        proc = subprocess.Popen(cmd,
        stdout=subprocess.PIPE,</tt><tt><br>
      </tt><tt>-                             <wbr>   shell=True,
        preexec_fn=os.setsid)</tt><tt><br>
      </tt><tt>+        proc = subprocess.Popen(cmd, stdout=FNULL,
        stderr=FNULL,</tt><tt><br>
      </tt><tt>+                             <wbr>   shell=False,
        preexec_fn=os.setsid)</tt><tt><br>
      </tt><tt>         timeout = 0</tt><tt><br>
      </tt><tt>         while proc.poll() is None:</tt><tt><br>
      </tt><tt>             time.sleep(1)</tt><font color="#888888"><br>
      <br>
    </font></p><font color="#888888">
    <pre class="m_-6347471772743292624moz-signature" cols="72">-- 
Regards
River (Fu.Lin)</pre>
  </font></div>

<br>______________________________<wbr>_________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/kimchi-devel</a><br>
<br></blockquote></div><br></div></div></div>