I am not being able to apply it due the following error:

[alinefm@alinefm-TP440 kimchi]$ git am -3 /home/alinefm/mail-patches/\[Kimchi-devel\]\ \[PATCH\]\ \[Kimchi\ 1_1\]\ Fix\ issue\ #1170\:\ ERROR\:KCHVM0090E\:\ Unable\ to\ create\ a\ password-less\ libvirt\ connection\ to\ the\ remote\ libvirt\ daemon.eml
Applying: Fix issue #1170: ERROR:KCHVM0090E: Unable to create a password-less libvirt connection to the remote libvirt daemon
error: corrupt patch at line 11
error: could not build fake ancestor
Patch failed at 0001 Fix issue #1170: ERROR:KCHVM0090E: Unable to create a password-less libvirt connection to the remote libvirt daemon
The copy of the patch that failed is found in: /home/alinefm/wok/.git/modules/src/wok/plugins/kimchi/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
[alinefm@alinefm-TP440 kimchi]$ vi /home/alinefm/mail-patches/\[Kimchi-devel\]\ \[PATCH\]\ \[Kimchi\ 1_1\]\ Fix\ issue\ #1170\:\ ERROR\:KCHVM0090E\:\ Unable\ to\ create\ a\ password-less\ libvirt\ connection\ to\ the\ remote\ libvirt\ daemon.eml
[alinefm@alinefm-TP440 kimchi]$ git am --abort


Seems the patch gets corrupted in some way.

Also, looking again to the patch, maybe it is simpler to just remove the sdtout parameter from Popen.

On 10/31/2017 04:06 AM, Fu.Lin wrote:

Long ago, I submitted an issue: https://github.com/kimchi-project/kimchi/issues/1170 ...

Test by following script:

import subprocess
import os
import time

def _check_remote_libvirt_conn(remote_host,
        user='root', transport='ssh'):

    FNULL = open(os.devnull, 'w')
    dest_uri = 'qemu+%s://%s@%s/system' % (transport, user, remote_host)
    cmd = ['virsh', '-c', dest_uri, 'list']
    proc = subprocess.Popen(cmd, stdout=FNULL, stderr=FNULL,
            shell=True, preexec_fn=os.setsid)
    timeout = 0
    while proc.poll() is None:
        time.sleep(1)
        timeout += 1
        if timeout == 5:
            print("killed")
            os.killpg(os.getpgid(proc.pid), signal.SIGTERM)

if __name__ == '__main__':
    _check_remote_libvirt_conn('localhost')

`proc` is timeout every time although the connection is normal tested by `virsh -c <uri>` list


The following is the reason of changing(From Python Document 2.7.14):

 Do not use stdout=PIPE or stderr=PIPE with this function as that can deadlock based on the child process output volume. Use Popen with the communicate() method when you need pipes.

 Using shell=True can be a security hazard. See the warning under Frequently Used Arguments for details.

At the same time, if not change, it does not work.


diff --git a/model/vms.py b/model/vms.py
index 6da4f3b..92e771f 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -1885,10 +1885,11 @@ class VMModel(object):
     def _check_remote_libvirt_conn(self, remote_host,
                                    user='root', transport='ssh'):
 
+        FNULL = open(os.devnull, 'w')
         dest_uri = 'qemu+%s://%s@%s/system' % (transport, user, remote_host)
         cmd = ['virsh', '-c', dest_uri, 'list']
-        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                                shell=True, preexec_fn=os.setsid)
+        proc = subprocess.Popen(cmd, stdout=FNULL, stderr=FNULL,
+                                shell=False, preexec_fn=os.setsid)
         timeout = 0
         while proc.poll() is None:
             time.sleep(1)

-- 
Regards
River (Fu.Lin)


_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel