fish: fix dir completion on filesystems w/o dirent.d_type (RHBZ#1153844).

On filesystems whose dirent.d_type is DT_UNKNOWN or some unknown value,
manually check whether an entry is a directory, thus completing in the
proper way.

Partially cherry picked from commit a8b95a5535480c7b382fab82dcaf18eb67e5278a,
but adapted to manually resolving the path, since guestfs_is_dir uses
lstat.
fish: complete symlink properly

When an entry is a symlink, check whether it points to a directory, so
the entry for it can be completed correctly.

(cherry picked from commit 7ba102dc4cd4b7c80f7486a54bf8535dd964f436)
add_drive: Introduce 'cachemode' parameter to control drive caching.

This commit adds an optional 'cachemode' parameter to the 'add_drive'
API to control caching.  This corresponds approximately to the
'-drive ...,cache=' parameter in qemu, but the choices are much more
restrictive, just 'writeback' or 'unsafe', for reasons outlined below.

The caching modes supported by recent QEMU are:

  writeback:
   - Reports data writes completed when data is present in the host
     page cache.
     Only safe provided guest correctly issues flush operations.

  writethrough:
   - Reports data writes completed only when each write has been
     flushed to disk.  Performance is reported as not good.

  none:
   - Uses O_DIRECT (avoids all interaction with host cache), but does
     not ensure every write is flushed to disk.
     Only safe provided guest correctly issues flush operations.

  directsync:
   - Uses O_DIRECT (avoids all interaction with host cache), and
     ensures every write has been flushed to disk.

  unsafe:
   - No special handling.

Since the libguestfs appliance kernel always issues flush operations
(eg. for filesystem journalling and for sync) the following modes can
be ignored: 'directsync', 'writethrough'.

That leaves 'writeback', 'none' and 'unsafe'.  However 'none' is both
a constant source of pain (RHBZ#994517), is inefficient because it
doesn't use the host cache, and does not give us any safety guarantees
over and above 'writeback'.  Therefore we should ignore 'none'.

This leaves 'writeback' (safe) and 'unsafe' (fast, useful for scratch
disks), which is what we implement in this patch.

Note that the previous behaviour was to use 'none' if possible, else
to use 'writeback'.  The new behaviour is to use 'writeback' only
which is (in safety terms) equivalent to 'none', and also faster and
less painful (RHBZ#994517).

This patch also allows you to specify a cache mode for network drives
which also previously defaulted to 'writeback'.

There is a considerable performance benefit to using unsafe (for
scratch disks only, of course).  The C API tests only use scratch
disks (since they are just tests, the final state of the disk doesn't
matter), and this decreases total run time from 202 seconds to 163
seconds, about 25% faster.

(cherry picked from commit 749e947bb0103f19feda0f29b6cbbf3cbfa350da)
sparsify: Use cachemode "unsafe" for the overlay disk.

(cherry picked from commit f3a9c9f867bed178d1aabf9675955f633bf3069a)
rescue: Use cachemode "unsafe" for the virt-rescue --scratch option.

(cherry picked from commit 3f0748f1fc64e42517c0d4535c27b1f32da86023)
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)