[Libguestfs] [PATCH v2 0/3] library: improve handling of external tools
Richard W.M. Jones
rjones at redhat.com
Fri Feb 3 15:22:45 UTC 2017
On Thu, Feb 02, 2017 at 02:33:17PM +0100, Pino Toscano wrote:
> Hi,
>
> the libguestfs library uses a number of external tools; for some of
> them, we search for them at build time, enabling some feature only if
> found, and later on assuming at runtime they are installed. However,
> the situation is more complex than that:
> - hardcoding the full path means that there is an incoherency in the
> way some of the tools are used, as some other tools (e.g. qemu-img)
> are just run as assumed to be in $PATH; also hardcoding means
> libguestfs cannot use different versions of those tools
There is reasoning here, see m4/guestfs_programs.m4:
# Check for external programs required to either build or run
# libguestfs.
#
# AC_CHECK_PROG(S) or AC_PATH_PROG(S)?
#
# Use AC_CHECK_PROG(S) for programs which are only used during build.
#
# Use AC_PATH_PROG(S) for program names which are compiled into the
# binary and used at run time. The reason is so that we know which
# programs the binary actually uses.
As it says in the message, the main reason I like to hard code the
full path is because I want to know that the user is running the same
program that we tested against, ie. they didn't install some
half-baked binary in /usr/local/bin.
I think it's a mistake if we call qemu-img without the full path BTW ...
> - some of the tools are actually optional, and their runtime lack can
> be handled gracefully instead of throwing a "failed to execute" error
Now, I do think this is a problem. But why don't we just test if the
(full pathnamed) program exists using a simple stat or access?
Rich.
> The chosen approach is to build a process-wide cache in the libguestfs
> library of paths of tools searched, even in case they are not available:
> this way it is easier to just skip something at runtime if a program is
> not there. The patch series applies it for the libdb tools, and for
> the tools used to extract icons from guests.
>
> Thanks,
>
> Pino Toscano (3):
> lib: add internal cache for external application
> lib: improve libdb tools handling at runtime (RHBZ#1409024)
> inspect: make netpbm and icoutils really optional runtime tools
>
> lib/Makefile.am | 1 +
> lib/external-apps.c | 190 +++++++++++++++++++++++++++++++++++++++++++++
> lib/guestfs-internal.h | 3 +
> lib/inspect-apps.c | 14 +++-
> lib/inspect-icon.c | 54 +++++++------
> m4/guestfs-find-db-tool.m4 | 2 +-
> m4/guestfs_progs.m4 | 24 ------
> 7 files changed, 237 insertions(+), 51 deletions(-)
> create mode 100644 lib/external-apps.c
>
> --
> 2.9.3
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
More information about the Libguestfs
mailing list