src/libvirt_private.syms
*Add symbols
daemon/libvirtd.c
*Set uninstallDir when libvirtd is running uninstalled
from a build tree
src/util/virutil.c
*Introduce virSetUninstalledDir
*Introduce virGetUninstalledDir
---
daemon/libvirtd.c | 1 +
src/libvirt_private.syms | 2 ++
src/util/virutil.c | 27 +++++++++++++++++++++++++++
src/util/virutil.h | 3 +++
4 files changed, 33 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 2357f95..3549868 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1997,6 +1997,7 @@ virGetGroupList;
virGetGroupName;
virGetHostname;
virGetSelfLastChanged;
+virGetUninstalledDir;
virGetUnprivSGIOSysfsPath;
virGetUserCacheDirectory;
virGetUserConfigDirectory;
@@ -2025,6 +2026,7 @@ virSetInherit;
virSetNonBlock;
virSetUIDGID;
virSetUIDGIDWithCaps;
+virSetUninstalledDir;
virStrIsPrint;
virUpdateSelfLastChanged;
virValidateWWN;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 733cdff..47afbc4 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2204,3 +2204,30 @@ void virUpdateSelfLastChanged(const char *path)
selfLastChanged = sb.st_ctime;
}
}
+
+static char *uninstalledDir = NULL;
+/**
+ * virSetUninstalledDir:
+ * @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)
+{
+ ignore_value(VIR_STRDUP(uninstalledDir, path));
+}
+
+/**
+ * virGetUninstalledDir:
+ *
+ * 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 are relying on <configmake.h>
+ * locations.
+ */
+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