+ *
+ * The supermin appliance cache directory lives in
+ * $TMPDIR/.guestfs-$UID/ and consists of four files:
+ *
+ * $TMPDIR/.guestfs-$UID/checksum - the checksum
+ * $TMPDIR/.guestfs-$UID/kernel - symlink to the kernel
+ * $TMPDIR/.guestfs-$UID/initrd - the febootstrap initrd
+ * $TMPDIR/.guestfs-$UID/root - the appliance
+ *
+ * Since multiple instances of libguestfs with the same UID may be
+ * racing to create an appliance, we need to be careful when building
+ * and using the appliance.
+ *
+ * If a cached appliance with checksum exists (step (2) above) then we
+ * make a hard link to it with our current PID, so that we have a copy
+ * even if the appliance is replaced by another process building an
+ * appliance afterwards:
+ *
+ * $TMPDIR/.guestfs-$UID/kernel.$PID
+ * $TMPDIR/.guestfs-$UID/initrd.$PID
+ * $TMPDIR/.guestfs-$UID/root.$PID
+ *
+ * A lock is taken on "checksum" while we perform the link.
+ *
+ * Linked files are deleted by a garbage collection sweep which can be
+ * initiated by any libguestfs process with the same UID when the
+ * corresponding PID no longer exists. (This is safe: the parent is
+ * always around in guestfs_launch() while qemu is starting up, and
+ * after that qemu will either have finished with the files or be
+ * holding them open, so we can unlink them).
+ *
+ * When building a new appliance (step (3)), it is built into randomly
+ * named temporary files in the $TMPDIR. Then a lock is acquired on
+ * $TMPDIR/.guestfs-$UID/checksum (this file being created if
+ * necessary), the files are renamed into their final location, and
+ * the lock is released.