We have two functions to set that we want to override directory where to
look for libvirt files, one checks the binary name and the other one
checks env variable.
This patch removes the binary name check to simplify code by using only
the env variable.
This change will be required for Meson introduction where the binary
name doesn't have any prefix by default.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/libvirt.c | 2 +-
src/libvirt_private.syms | 3 +--
src/locking/lock_daemon.c | 2 +-
src/logging/log_daemon.c | 2 +-
src/qemu/qemu_shim.c | 2 +-
src/remote/remote_daemon.c | 2 +-
src/security/virt-aa-helper.c | 2 +-
src/util/virfile.c | 25 +------------------------
src/util/virfile.h | 4 +---
tests/Makefile.am | 1 +
tests/qemucapsprobe.c | 2 +-
tests/testutils.c | 2 +-
tools/virsh.c | 2 +-
tools/virt-admin.c | 2 +-
14 files changed, 14 insertions(+), 39 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index b2d0ba3d232..e3d68dc81d5 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -221,7 +221,7 @@ virGlobalInit(void)
if (virErrorInitialize() < 0)
goto error;
- virFileActivateDirOverrideForLib();
+ virFileActivateDirOverride();
if (getuid() != geteuid() ||
getgid() != getegid()) {
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ae0e253ab9f..f2808945c21 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2041,8 +2041,7 @@ virDirOpenQuiet;
virDirRead;
virFileAbsPath;
virFileAccessibleAs;
-virFileActivateDirOverrideForLib;
-virFileActivateDirOverrideForProg;
+virFileActivateDirOverride;
virFileBindMountDevice;
virFileBuildPath;
virFileCanonicalizePath;
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index b0cd89375be..7dc1fcb28f2 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -954,7 +954,7 @@ int main(int argc, char **argv) {
}
}
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (!(config = virLockDaemonConfigNew(privileged))) {
VIR_ERROR(_("Can't create initial configuration"));
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 028f771f149..8e92543a3a1 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -733,7 +733,7 @@ int main(int argc, char **argv) {
}
}
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (!(config = virLogDaemonConfigNew(privileged))) {
VIR_ERROR(_("Can't create initial configuration"));
diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c
index 7e87b8fb962..1e4e2b22ee4 100644
--- a/src/qemu/qemu_shim.c
+++ b/src/qemu/qemu_shim.c
@@ -167,7 +167,7 @@ int main(int argc, char **argv)
}
}
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (verbose)
g_printerr("%s: %lld: preparing event loop thread\n",
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 1aa9bfc0d2f..901af6e934e 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -808,7 +808,7 @@ int main(int argc, char **argv) {
virUpdateSelfLastChanged(argv[0]);
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
while (1) {
int optidx = 0;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 08eb162b8cd..82d27efa7b3 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1459,7 +1459,7 @@ main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
/* Initialize the log system */
virLogSetFromEnv();
diff --git a/src/util/virfile.c b/src/util/virfile.c
index c034df5931e..9e8dee4cb0f 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1777,29 +1777,6 @@ virFileFindResource(const char *filename,
}
-/**
- * virFileActivateDirOverrideForProg:
- * @argv0: argv[0] of the calling program
- *
- * Look at @argv0 and try to detect if running from
- * a build directory, by looking for a 'lt-' prefix
- * on the binary name, or '/.libs/' in the path
- */
-void
-virFileActivateDirOverrideForProg(const char *argv0)
-{
- char *file = strrchr(argv0, '/');
- if (!file || file[1] == '\0')
- return;
- file++;
- if (STRPREFIX(file, "lt-") ||
- strstr(argv0, "/.libs/")) {
- useDirOverride = true;
- VIR_DEBUG("Activating build dir override for %s", argv0);
- }
-}
-
-
/**
* virFileActivateDirOverrideForLib:
*
@@ -1807,7 +1784,7 @@ virFileActivateDirOverrideForProg(const char *argv0)
* the build/src tree instead of install tree.
*/
void
-virFileActivateDirOverrideForLib(void)
+virFileActivateDirOverride(void)
{
if (getenv("LIBVIRT_DIR_OVERRIDE") != NULL)
useDirOverride = true;
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 7a92364a5c9..fc0f6360506 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -190,9 +190,7 @@ char *virFileFindResourceFull(const char *filename,
const char *installdir,
const char *envname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
-void virFileActivateDirOverrideForProg(const char *argv0)
- ATTRIBUTE_NONNULL(1);
-void virFileActivateDirOverrideForLib(void);
+void virFileActivateDirOverride(void);
off_t virFileLength(const char *path, int fd) ATTRIBUTE_NONNULL(1);
bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c87b12d28c3..f237c134213 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -484,6 +484,7 @@ TESTS_ENVIRONMENT = \
abs_builddir="$(abs_builddir)" \
abs_srcdir="$(abs_srcdir)" \
LIBVIRT_AUTOSTART=0 \
+ LIBVIRT_DIR_OVERRIDE=1 \
LC_ALL=C \
VIR_TEST_EXPENSIVE=$(VIR_TEST_EXPENSIVE) \
$(VG)
diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
index 26ea9ff5ed1..f18b7792b02 100644
--- a/tests/qemucapsprobe.c
+++ b/tests/qemucapsprobe.c
@@ -55,7 +55,7 @@ main(int argc, char **argv)
VIR_TEST_PRELOAD(mock);
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (argc != 2) {
fprintf(stderr, "%s QEMU_binary\n", argv[0]);
diff --git a/tests/testutils.c b/tests/testutils.c
index 7f1776b2449..191917b01f0 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -794,7 +794,7 @@ int virTestMain(int argc,
g_setenv("VIR_TEST_MOCK_PROGNAME", progname, TRUE);
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (virTestSetEnvPath() < 0)
return EXIT_AM_HARDFAIL;
diff --git a/tools/virsh.c b/tools/virsh.c
index 197a90636d3..4f5e6ed65ef 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -887,7 +887,7 @@ main(int argc, char **argv)
return EXIT_FAILURE;
}
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (!vshInit(ctl, cmdGroups, NULL))
exit(EXIT_FAILURE);
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index fef0332a0d3..fdb0a130523 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -1573,7 +1573,7 @@ main(int argc, char **argv)
return EXIT_FAILURE;
}
- virFileActivateDirOverrideForProg(argv[0]);
+ virFileActivateDirOverride();
if (!vshInit(ctl, cmdGroups, NULL))
exit(EXIT_FAILURE);
--
2.26.2