mllib: Create a common utility function is_directory.

This is a wrapper around Sys.is_directory which doesn't throw
exceptions.

(cherry picked from commit 893bfe2e36f5a766e822b14fe5e7e4fc9b2b3f75)
sparsify: Add --tmp option to allow specifying temp directory or block device.

Add the virt-sparsify --tmp option.

This works in two ways.  Either you can specify a temporary directory,
in which case it's just the same as setting $TMPDIR before:

  virt-sparsify indisk outdisk --tmp /var/tmp

Or, as a new feature, you can specify a block device which is directly
used (and OVERWRITTEN):

  virt-sparsify indisk outdisk --tmp /dev/sdX

This is useful for oVirt nodes, where there is limited temporary
space, but a block device can be assigned to the node.

In both cases it is only used in copying mode.  In-place
sparsification doesn't require large amounts of temporary space.

(cherry picked from commit 870c17e99acd038daed9b4004c66d401679475ab)
sparsify: Add --tmp prebuilt:file option.

This option allows oVirt to pass a prebuilt qcow2 file to use as the
temporary overlay.  The file must be qcow2, and must have indisk as a
backing file - the code does minimal checks to ensure this is correct.

Example usage:

  qemu-img create -f qcow2 -b indisk overlay.qcow2
  virt-sparsify indisk --tmp prebuilt:overlay.qcow2 outdisk

Note this only applies in copying mode.

(cherry picked from commit 13be9eabed2202be6480662a137a5bc2d3477219)
sparsify: update documentation

- remove mention of --in-place, not present in this version
- in TMPDIR, remove the version for --tmp (it is provided in the current
  version already)
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.