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>") */ --- daemon/libvirtd.c | 1 + src/libvirt_private.syms | 2 ++ src/util/virutil.c | 25 +++++++++++++++++++++++++ src/util/virutil.h | 3 +++ 4 files changed, 31 insertions(+), 0 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 4179147..dc3da2a 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1165,6 +1165,7 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } *tmp = '\0'; + virSetUninstalledDir(argv[0]); char *driverdir; if (virAsprintfQuiet(&driverdir, "%s/../../src/.libs", argv[0]) < 0 || virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5904036..a112e6e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1989,6 +1989,7 @@ virGetGroupList; virGetGroupName; virGetHostname; virGetSelfLastChanged; +virGetUninstalledDir; virGetUnprivSGIOSysfsPath; virGetUserCacheDirectory; virGetUserConfigDirectory; @@ -2017,6 +2018,7 @@ virSetInherit; virSetNonBlock; virSetUIDGID; virSetUIDGIDWithCaps; +virSetUninstalledDir; virStrIsPrint; virUpdateSelfLastChanged; virValidateWWN; diff --git a/src/util/virutil.c b/src/util/virutil.c index 733cdff..46f6c75 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -2204,3 +2204,28 @@ void virUpdateSelfLastChanged(const char *path) selfLastChanged = sb.st_ctime; } } + +static char *uninstalledDir = NULL; +/** + * virSetUninstalledDir: + * @path: location from which libvirtd is running without + * installation + * + * Set a pointer to the path which can be accessed by all + * other APIs using virGetUninstalledDir(). + */ +void virSetUninstalledDir(char *path) +{ + uninstalledDir = path; +} + +/** + * virGetUninstalledDir: + * + * If libvirtd is running without installation, return the + * path from which it was invoked, otherwise, return NULL + */ +char *virGetUninstalledDir(void) +{ + return uninstalledDir; +} diff --git a/src/util/virutil.h b/src/util/virutil.h index 1f2efd5..3e6ba47 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -202,4 +202,7 @@ bool virIsSUID(void); time_t virGetSelfLastChanged(void); void virUpdateSelfLastChanged(const char *path); +void virSetUninstalledDir(char *path); +char *virGetUninstalledDir(void); + #endif /* __VIR_UTIL_H__ */ -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list