<div dir="ltr">yep, we don't wait for the process inside cpopen code - we expect the caller to take care of it. if you use execCmd with sync=False (as in virt-v2v) - you have to take care for killing the process and wait for its pid after its done - you can see that with the fix we raise exception and this exception is caught in _import func and call _abort which calls kill and sign the pid to zombiereaper which waits for it to die.<div>If you use execCmd with sync=True (the default) you can see that we wait until process exists and return.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 30, 2016 at 5:30 PM, Nir Soffer <span dir="ltr"><<a href="mailto:nsoffer@redhat.com" target="_blank">nsoffer@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Mar 30, 2016 at 3:32 PM, Shahar Havivi <<a href="mailto:shaharh@redhat.com">shaharh@redhat.com</a>> wrote:<br>
> On 30.03.16 14:28, Nir Soffer wrote:<br>
>> On Wed, Mar 30, 2016 at 1:36 PM, Michal Skrivanek<br>
>> <<a href="mailto:michal.skrivanek@redhat.com">michal.skrivanek@redhat.com</a>> wrote:<br>
>> ><br>
>> >> On 30 Mar 2016, at 11:49, Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>> wrote:<br>
>> >><br>
>> >> On Wed, Mar 30, 2016 at 12:19:35PM +0300, Shahar Havivi wrote:<br>
>> >>> Hi,<br>
>> >>><br>
>> >>> We encounter a problem in VDSM project that virt-v2v become zombie task while<br>
>> >>> importing vm from vmware.<br>
>> >>> When virt-v2v is in 'copy disk' mode and we someone deletes the vm at vmware<br>
>> >>> the process hang in read() method,<br>
>> >>> I am pretty sure that its not virt-v2v problem because when I run it from the<br>
>> >>> shell virt-v2v exit with an error, still maybe someone have an idea....<br>
>> >>><br>
>> >>> I wrote a small python script that encounter the problem:<br>
>> >>><br>
>> >>> ----------------------------------------------------------------------------<br>
>> >>> from cpopen import CPopen<br>
>> >>><br>
>> >>> env = {'LIBGUESTFS_BACKEND': 'direct'}<br>
>> >>> cmd = ['/usr/bin/virt-v2v', '-ic',<br>
>> >>> 'vpx://....', '-o',<br>
>> >>> 'local', '-os', '/tmp', '-of', 'raw', '-oa', 'sparse',<br>
>> >>> '--password-file', '/tmp/passwd', '--machine-readable', 'bbb']<br>
>> >>> p = CPopen(cmd, env=env)<br>
>> >>> while p.returncode is None:<br>
>><br>
>> p.returncode just return the instance variable, there is no wait() involved.<br>
>><br>
>> The right way:<br>
>><br>
>> while p.poll() is None:<br>
> the problem is proc.stdout.read(1) didn't raise and error when the stream<br>
> closed but return ''.<br>
> its a CPopen behaviour and works differently in subprocess.<br>
<br>
</div></div>No, it works the same in both, this was just a bug in our code.<br>
Fixed in <a href="https://gerrit.ovirt.org/55477" rel="noreferrer" target="_blank">https://gerrit.ovirt.org/55477</a><br>
<div class="HOEnZb"><div class="h5"><br>
><br>
>> ...<br>
>><br>
>> p.returncode calling wait is non-standard feature in vdsm AsyncProc<br>
>> wrapper. This is<br>
>> the object used by v2v vdsm module, so there accessing p.returncode does call<br>
>> p.poll().<br>
>><br>
>> These non-standard apis will be removed from vdsm, please do not use them.<br>
>><br>
>> >>> c = p.stdout.read(1)<br>
>> >>> print c<br>
>> >>> ----------------------------------------------------------------------------<br>
>> >><br>
>> >> An actual zombie task? That would indicate that the parent process<br>
>> >> (your Python program) wasn't doing a wait system call.<br>
>> >><br>
>> >> I downloaded the cpopen-1.4 program, and it doesn't appear to call any<br>
>> >> of the wait*(2) system calls anywhere, so that could be the problem.<br>
>> ><br>
>> > I suppose the cpopen parameters are not alright…I’m sure vdsm developers can help with that.<br>
>> ><br>
>> >><br>
>> >> Rich.<br>
>> >><br>
>> >> --<br>
>> >> Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
>> >> Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
>> >> virt-p2v converts physical machines to virtual machines. Boot with a<br>
>> >> live CD or over the network (PXE) and turn machines into KVM guests.<br>
>> >> <a href="http://libguestfs.org/virt-v2v" rel="noreferrer" target="_blank">http://libguestfs.org/virt-v2v</a><br>
>> ><br>
>> > _______________________________________________<br>
>> > Devel mailing list<br>
>> > <a href="mailto:Devel@ovirt.org">Devel@ovirt.org</a><br>
>> > <a href="http://lists.ovirt.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman/listinfo/devel</a><br>
_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@ovirt.org">Devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman/listinfo/devel</a></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span style="font-size:12.8px"><b>Yaniv Bronhaim.</b></span><br></div></div></div></div></div>
</div>