<div dir="auto"><div>Reviewed-by: Aline Manera <<a href="mailto:alinemanera@gmail.com">alinemanera@gmail.com</a>></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, "Fu.Lin" <<a href="mailto:lfu@suse.com">lfu@suse.com</a>> 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='root', transport='ssh'):<br>
<br>
FNULL = open(os.devnull, 'w')<br>
dest_uri = 'qemu+%s://%s@%s/system' % (transport, user,
remote_host)<br>
cmd = ['virsh', '-c', dest_uri, 'list']<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("killed")<br>
os.killpg(os.getpgid(proc.pid)<wbr>, signal.SIGTERM)<br>
<br>
if __name__ == '__main__':<br>
_check_remote_libvirt_conn('<wbr>localhost')</tt></p>
</blockquote>
<p><tt>`proc` is timeout every time although the connection is
normal tested by `virsh -c <uri>` 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='root',
transport='ssh'):</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt>+ FNULL = open(os.devnull, 'w')</tt><tt><br>
</tt><tt> dest_uri = 'qemu+%s://%s@%s/system' %
(transport, user, remote_host)</tt><tt><br>
</tt><tt> cmd = ['virsh', '-c', dest_uri, 'list']</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>