Re: [PATCH] Add utility functions for storing uninstalled location

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/23/2014 02:22 AM, Nehal J Wani wrote:
> When libvirtd is run from a build directory without being installed, it
> should not depend on files from a libvirt package installed in the
> system. Currently, APIs defined in src/ don't know whether libvirtd
> is being run from the build dir or the installed dir. The following
> additions provide the functionality to do so:
> 
> src/util/virutil.c
>    *virSetUninstalledDir
>    *virGetUninstalledDir
> 
> Example usage (utility = lxc|iohelper):
>    char *path_tmp = virGetUninstalledDir();
>    if (path_tmp)
>       /* do stuff with ("%s/../../src/libvirt_<utility>", path_tmp) */
>    else
>       /* do stuff with (LIBEXECDIR "/libvirt_<utility>") */
> 

Hmm - we already have virFDStreamSetIOHelper() for overriding the
location of libvirt_iohelper, but I like your approach as something a
bit more generic.  Do we really need both mechanisms, or should your
series include a followup patch to nuke virFDStreamSetIOHelper() and
instead teach the testsuite to use your new functions (that is,
testutils.c should probably call virSetUninstalledDir).

I'm not sure if there is a better name for the concept (I'm a bit
biased, because I helped you design this on IRC) - so I'll wait for
other reviewers.

> +static char *uninstalledDir = NULL;
> +/**
> + * virSetUninstalledDir:
> + * @path: location from which libvirtd is running without
> + * installation

Grammar is awkward.  How about:

@path: directory containing an uninstalled binary, for use in locating
other uninstalled files

> + *
> + * Set a pointer to the path which can be accessed by all
> + * other APIs using virGetUninstalledDir().
> + */
> +void virSetUninstalledDir(char *path)
> +{
> +    uninstalledDir = path;

Dangerous to not strdup this argument - if the caller modifies the
argument (and libvirtd.c main() DOES modify the argument) then you are
not pointing to the same string that you thought you were.

> +}
> +
> +/**
> + * virGetUninstalledDir:
> + *
> + * If libvirtd is running without installation, return the
> + * path from which it was invoked, otherwise, return NULL

How about:

If libvirtd (or other binary) is running uninstalled from a build tree,
return the directory containing the binary.  A NULL return implies that
the binary has been installed and paths relying on <configmake.h> locations.

Series is incomplete.  It's not worth adding the new function unless you
also have followup patches that use the new function.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]