Use virFileFindResource to locate virtlockd daemon

Make the lock plugin use virFileFindResource to find the
virtlockd daemon path, so that it executes the in-builddir
daemon if run from source tree.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2014-04-25 11:55:32 +01:00
parent 57e5c3c2ae
commit e18a80a3a0
2 changed files with 8 additions and 19 deletions

2
run.in
View File

@ -55,7 +55,7 @@ export LD_LIBRARY_PATH
export LIBVIRT_DRIVER_DIR="$b/src/.libs" export LIBVIRT_DRIVER_DIR="$b/src/.libs"
export LIBVIRT_LOCK_MANAGER_PLUGIN_DIR="$b/src/.libs" export LIBVIRT_LOCK_MANAGER_PLUGIN_DIR="$b/src/.libs"
export VIRTLOCKD_PATH="$b/src/virtlockd" export VIRTLOCKD_PATH="$b/src"
export LIBVIRTD_PATH="$b/daemon" export LIBVIRTD_PATH="$b/daemon"
# This is a cheap way to find some use-after-free and uninitialized # This is a cheap way to find some use-after-free and uninitialized

View File

@ -81,22 +81,6 @@ struct _virLockManagerLockDaemonDriver {
static virLockManagerLockDaemonDriverPtr driver = NULL; static virLockManagerLockDaemonDriverPtr driver = NULL;
#define VIRTLOCKD_PATH SBINDIR "/virtlockd"
static const char *
virLockManagerLockDaemonFindDaemon(void)
{
const char *customDaemon = virGetEnvBlockSUID("VIRTLOCKD_PATH");
if (customDaemon)
return customDaemon;
if (virFileIsExecutable(VIRTLOCKD_PATH))
return VIRTLOCKD_PATH;
return NULL;
}
static int virLockManagerLockDaemonLoadConfig(const char *configFile) static int virLockManagerLockDaemonLoadConfig(const char *configFile)
{ {
virConfPtr conf; virConfPtr conf;
@ -266,8 +250,13 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
if (!(lockdpath = virLockManagerLockDaemonPath(privileged))) if (!(lockdpath = virLockManagerLockDaemonPath(privileged)))
goto error; goto error;
if (!privileged) if (!privileged &&
daemonPath = virLockManagerLockDaemonFindDaemon(); !(daemonPath = virFileFindResourceFull("virtlockd",
NULL, NULL,
"src",
SBINDIR,
"VIRTLOCKD_PATH")))
goto error;
if (!(client = virNetClientNewUNIX(lockdpath, if (!(client = virNetClientNewUNIX(lockdpath,
daemonPath != NULL, daemonPath != NULL,