mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 21:45:21 +00:00
daemon: Autodetect lock driver directory
When running libvirtd from a build directory, libvirtd would load lock drivers from system directory unless explicitly overridden by setting LIBVIRT_LOCK_MANAGER_PLUGIN_DIR environment variable. Since we already autodetect driver directory if libvirt is build with driver modules, we can use the same trick to automagically set lock driver directory.
This commit is contained in:
parent
1a4379cb21
commit
15f5e16f4e
@ -55,6 +55,7 @@
|
|||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
#include "viraudit.h"
|
#include "viraudit.h"
|
||||||
|
#include "locking/lock_manager.h"
|
||||||
|
|
||||||
#ifdef WITH_DRIVER_MODULES
|
#ifdef WITH_DRIVER_MODULES
|
||||||
# include "driver.h"
|
# include "driver.h"
|
||||||
@ -971,7 +972,6 @@ int main(int argc, char **argv) {
|
|||||||
/* initialize early logging */
|
/* initialize early logging */
|
||||||
virLogSetFromEnv();
|
virLogSetFromEnv();
|
||||||
|
|
||||||
#ifdef WITH_DRIVER_MODULES
|
|
||||||
if (strstr(argv[0], "lt-libvirtd") ||
|
if (strstr(argv[0], "lt-libvirtd") ||
|
||||||
strstr(argv[0], "/daemon/.libs/libvirtd")) {
|
strstr(argv[0], "/daemon/.libs/libvirtd")) {
|
||||||
char *tmp = strrchr(argv[0], '/');
|
char *tmp = strrchr(argv[0], '/');
|
||||||
@ -990,11 +990,13 @@ int main(int argc, char **argv) {
|
|||||||
argv[0], driverdir);
|
argv[0], driverdir);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
virLockManagerSetPluginDir(driverdir);
|
||||||
|
#ifdef WITH_DRIVER_MODULES
|
||||||
virDriverModuleInitialize(driverdir);
|
virDriverModuleInitialize(driverdir);
|
||||||
|
#endif
|
||||||
*tmp = '/';
|
*tmp = '/';
|
||||||
/* Must not free 'driverdir' - it is still used */
|
/* Must not free 'driverdir' - it is still used */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int optidx = 0;
|
int optidx = 0;
|
||||||
|
@ -757,6 +757,7 @@ virLockManagerPluginUnref;
|
|||||||
virLockManagerPluginUsesState;
|
virLockManagerPluginUsesState;
|
||||||
virLockManagerPluginGetName;
|
virLockManagerPluginGetName;
|
||||||
virLockManagerRelease;
|
virLockManagerRelease;
|
||||||
|
virLockManagerSetPluginDir;
|
||||||
|
|
||||||
|
|
||||||
# logging.h
|
# logging.h
|
||||||
|
@ -64,6 +64,16 @@ struct _virLockManagerPlugin {
|
|||||||
|
|
||||||
#define DEFAULT_LOCK_MANAGER_PLUGIN_DIR LIBDIR "/libvirt/lock-driver"
|
#define DEFAULT_LOCK_MANAGER_PLUGIN_DIR LIBDIR "/libvirt/lock-driver"
|
||||||
|
|
||||||
|
static const char *virLockManagerPluginDir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR;
|
||||||
|
|
||||||
|
void
|
||||||
|
virLockManagerSetPluginDir(const char *dir)
|
||||||
|
{
|
||||||
|
if (dir)
|
||||||
|
virLockManagerPluginDir = dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void virLockManagerLogParams(size_t nparams,
|
static void virLockManagerLogParams(size_t nparams,
|
||||||
virLockManagerParamPtr params)
|
virLockManagerParamPtr params)
|
||||||
{
|
{
|
||||||
@ -128,7 +138,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||||||
driver = &virLockDriverNop;
|
driver = &virLockDriverNop;
|
||||||
} else {
|
} else {
|
||||||
if (moddir == NULL)
|
if (moddir == NULL)
|
||||||
moddir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR;
|
moddir = virLockManagerPluginDir;
|
||||||
|
|
||||||
VIR_DEBUG("Module load %s from %s", name, moddir);
|
VIR_DEBUG("Module load %s from %s", name, moddir);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
typedef struct _virLockManagerPlugin virLockManagerPlugin;
|
typedef struct _virLockManagerPlugin virLockManagerPlugin;
|
||||||
typedef virLockManagerPlugin *virLockManagerPluginPtr;
|
typedef virLockManagerPlugin *virLockManagerPluginPtr;
|
||||||
|
|
||||||
|
void virLockManagerSetPluginDir(const char *dir);
|
||||||
virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
||||||
const char *configFile,
|
const char *configFile,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user