Bug 801788

Summary: libguestfs holds open file descriptors when handle is launched
Product: Red Hat Enterprise Linux 6 Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: imcleod, leiwang, moli, qguan, qwan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.16.10-1.el6 Doc Type: Bug Fix
Doc Text:
No Documentation needed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 07:01:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2012-03-09 14:01:32 UTC
Description of problem:

I discovered a problem when a program is using libguestfs
and pipes.  The recovery process holds file descriptors open
(it doesn't exec, so is not affected by FD_CLOEXEC).  For
pipes this is very bad because you cannot close the write
side of the pipe, since the recovery process holds it open.

First version of proposed patch is here, but danpb pointed
out that it's also a good idea to remove signal handlers as
well, so I'm going to do a second version.

https://www.redhat.com/archives/libguestfs/2012-March/msg00044.html

Version-Release number of selected component (if applicable):

1.17.13

How reproducible:

100%

Steps to Reproduce:

I need to write a simple reproducer, but the problem was exposed
initially when I wrote this program:

https://www.redhat.com/archives/libguestfs/2012-March/msg00045.html

Comment 4 Qixiang Wan 2012-03-23 09:56:06 UTC
Hi Rich,

I tried to reproduce this with the program "copy_over" you mentioned in the bug description, but I got same error for the old package and the latest one. Is it
different error from this defect or the defect hasn't been fixed?

Old package:
# rpm -q libguestfs
libguestfs-1.16.8-1.el6.x86_64
# ./copy_over rhel /root/file.test rhel6 /root
libguestfs: error: file receive cancelled by daemon
libguestfs: error: /dev/fd/5: error in chunked encoding

New package:
# rpm -q libguestfs
libguestfs-1.16.10-1.el6.x86_64
# ./copy_over rhel /root/file.test rhel6 /root
libguestfs: error: file receive cancelled by daemon
libguestfs: error: /dev/fd/5: error in chunked encoding

Comment 5 Richard W.M. Jones 2012-03-23 10:03:43 UTC
(In reply to comment #4)
> Hi Rich,
> 
> I tried to reproduce this with the program "copy_over" you mentioned in the bug
> description, but I got same error for the old package and the latest one. Is it
> different error from this defect or the defect hasn't been fixed?
> 
> Old package:
> # rpm -q libguestfs
> libguestfs-1.16.8-1.el6.x86_64
> # ./copy_over rhel /root/file.test rhel6 /root
> libguestfs: error: file receive cancelled by daemon
> libguestfs: error: /dev/fd/5: error in chunked encoding
> 
> New package:
> # rpm -q libguestfs
> libguestfs-1.16.10-1.el6.x86_64
> # ./copy_over rhel /root/file.test rhel6 /root
> libguestfs: error: file receive cancelled by daemon
> libguestfs: error: /dev/fd/5: error in chunked encoding

This error is not the one you would expect from this bug.

If you have this bug, then the test will *hang*.

The error you're seeing is, oh joy, a different one.  Can
you run it again with:

  LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 ./copy_over [etc]

and then post the full debug output into a NEW bug?

Comment 6 Qixiang Wan 2012-03-23 10:19:19 UTC
(In reply to comment #5)
> This error is not the one you would expect from this bug.
> 
> If you have this bug, then the test will *hang*.
> 
> The error you're seeing is, oh joy, a different one.  Can
> you run it again with:
> 
>   LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 ./copy_over [etc]
> 
> and then post the full debug output into a NEW bug?

Thanks, checked the debug output, I find it happened because the src was a file, and it should be a directory. So it's not a bug.

And I reproduced the hang with correct command line, with the new package (libguestfs-1.16.10-1.el6), the copy can finish without issue:

# ./copy_over rhel /root/ rhel6 /tmp
copy finished, elapsed time (excluding launch) was 0.498 s

So change this to VERIFIED.

Comment 7 Richard W.M. Jones 2012-04-26 13:45:46 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed.

Comment 9 errata-xmlrpc 2012-06-20 07:01:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0774.html