[libvirt] [PATCH] More advanced auto-detection of driver module directory

Eric Blake eblake at redhat.com
Mon Jul 23 15:46:39 UTC 2012


On 07/23/2012 09:22 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> When running directly from GIT, libvirtd attempts to locate
> the directory containing loadable modules. This currently
> only works if executing libvirtd with a CWD inside the libvirt
> source tree. Switch to locate based on the path to the current
> binary instead
> ---
>  daemon/libvirtd.c |   24 +++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> index b5c0102..a7bb9dd 100644
> --- a/daemon/libvirtd.c
> +++ b/daemon/libvirtd.c
> @@ -972,9 +972,27 @@ int main(int argc, char **argv) {
>      virLogSetFromEnv();
>  
>  #ifdef WITH_DRIVER_MODULES
> -    if (strstr(argv[0], "lt-libvirtd") &&
> -        (access("./.git", R_OK) >= 0 || access("../.git", R_OK) >= 0))
> -        virDriverModuleInitialize("./src/.libs");
> +    if (strstr(argv[0], "lt-libvirtd")) {
> +        char *tmp = strrchr(argv[0], '/');
> +        if (!tmp) {
> +            fprintf(stderr, _("%s: cannot identify driver directory\n"), argv[0]);
> +            exit(EXIT_FAILURE);
> +        }
> +        *tmp = '\0';

Modifying argv in-place - fun stuff.  I'm not sure if it is technically
kosher by C99 rules, but it works and I'm not going to be a stickler.

ACK - this addresses one of my findings from when you first introduced
this test.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120723/e8e9bd71/attachment-0001.sig>


More information about the libvir-list mailing list