launch: Close file descriptors after fork (RHBZ#1123007).

This refactors existing code to close file descriptors in the recovery
process, and also adds code to close file descriptors between the
fork() and exec() of QEMU or User-Mode Linux.

The reason is to avoid leaking main process file descriptors where the
main process (or other libraries in the main process) are not setting
O_CLOEXEC at all or not setting it atomically.  Python is a particular
culprit.

See also this OpenStack Nova bug report:
https://bugs.launchpad.net/nova/+bug/1313477

Thanks: Qin Zhao for identifying and characterizing the problem in Nova.

This is version 2 of this commit.  This commit is identical to the
reverted commit 115fcc34325f965ac3723683e4462fc667dcd254 except that
we don't close stderr.

(cherry picked from commit e1c508c29f929134bfcb0f83b402a02e8ff94caa)
RHEL 6: Emphasize libguestfs-winsupport package (RHBZ#627468).

This RHEL 6.1-only patch changes the error messages when the
inspection code cannot find an operating system inside the guest
image.  For a Windows guest this may happen because the user has not
installed the separate 'libguestfs-winsupport' package.  Therefore we
emphasize that the user may need to install this package.

Notes:

(1) In RHEL 6.1 there are two pieces of inspection code, the old Perl
code (deprecated upstream) and the new C core inspection API.
Therefore this patch has to touch two places with essentially the same
change.

(2) This patch doesn't try to be clever and detect if it was a Windows
guest.  This should reduce the chance of failure.

Output from (Perl) virt-inspector now looks like this:

 $ virt-inspector disk.img
 No operating system could be detected inside this disk image.

 This may be because the file is not a disk image, or is not a virtual machine
 image, or because the OS type is not understood by virt-inspector.

 If you feel this is an error, please file a bug report including as much
 information about the disk image as possible.

 RHEL 6 notice
 -------------
 libguestfs will return this error for Microsoft Windows guests if the
 separate 'libguestfs-winsupport' package is not installed. If the
 guest is running Microsoft Windows, please try again after installing
 'libguestfs-winsupport'.

Output from guestfish (ie. C core inspection API) now looks like this:

 $ guestfish -i disk.img
 guestfish: no operating system was found on this disk

 RHEL 6 notice
 -------------
 libguestfs will return this error for Microsoft Windows guests if the
 separate 'libguestfs-winsupport' package is not installed. If the
 guest is running Microsoft Windows, please try again after installing
 'libguestfs-winsupport'.
RHEL 6: Require external hex editor set with $HEXEDITOR.

RHEL 6 doesn't have the hexedit program or any suitable replacement.
Require that the user sets $HEXEDITOR to make this command work.
(cherry picked from commit 1ee31426e13446bc5fcce242eb496a01d8a78d8c)
RHEL 6: Directly include String::ShellQuote.

Directly include a snippet from String::ShellQuote so that we
don't need to depend on this external library, which is not
included in RHEL 6.1.

This affects virt-make-fs.
RHEL 6: Modify blkid test so it is successful on RHEL 6-era blkid.
RHEL 6: Remove libguestfs live (RHBZ#798980).

This isn't supported in RHEL 6.
RHEL 6: Exclude iptables from the appliance (RHBZ#858648).
RHEL 6: In mount-local docs, change refs to libguestfs 1.18 -> RHEL 6.4.

We backported the libguestfs 1.18 / mount-local functionality
into the libguestfs 1.16 codebase for RHEL 6.4.
RHEL 6: Ignore /etc/release if /etc/redhat-release exists (RHBZ#872454).

If the user has created /etc/release on a RHEL machine, don't
mis-detect the OS as NetBSD.
RHEL 6: Modify ruby Rakefile.in to work with older Ruby.
RHEL 6: Remove check for qemu >= 1.
RHEL 6: Revert "Use pkg-config for Python"

Python in RHEL 6 does not contain the required pkg-config files.

This reverts commit e5f0dfb6e3425e8dbaa405847ae98a8dcc421da7.
RHEL 6: tests/regressions/rhbz895904.sh: Use `` instead of $().

Apparently bash in RHEL 6 cannot handle this unusual
multi-line use of $(...), but `` works fine.
RHEL 6: Add back some state test commands to guestfish (RHBZ#971664).

In RHEL 6, re-add the following commands to ensure there is no
regression between RHEL 6.4 and RHEL 6.5:

  get-state            get the current state
  is-busy              is busy processing a command
  is-launching         is launching subprocess
  is-ready             is ready to accept commands

(As a side-effect this also adds 'wait-ready' which is a no-op).

These commands have been removed upstream and will be removed
permanently in RHEL 7.  The reason is that these commands do not do
anything useful.
RHEL 6: Pipe 'yes' into ntfsresize (RHBZ#971326).

This works around a problem in ntfsresize on RHEL 6.  See:
https://bugzilla.redhat.com/show_bug.cgi?id=971326#c4
RHEL 6: Remove 9p APIs from RHEL (RHBZ#997884).

(cherry picked from commit 5f7b0f81793f38191634f4460b1c18b97990db44)
RHEL 6: disable fstrim API (RHBZ#982979).

The combination of qemu, kernel & virtio-scsi in RHEL 6 is too old to
make fstrim work properly.
Thus, make the 'fstrim' feature always unavailable, and hide the
'fstrim' command from the documentation.