mirror of https://gitee.com/openkylin/libvirt.git
Override default driver dir when running from GIT
* daemon/libvirtd.c: Set custom driver module dir if the current binary name is 'lt-libvirtd' (indicating execution directly from GIT checkout) * src/driver.c, src/driver.h, src/libvirt_driver_modules.syms: Add virDriverModuleInitialize to allow driver module location to be changed Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
a4e45a06c0
commit
b47637261c
|
@ -958,6 +958,12 @@ int main(int argc, char **argv) {
|
|||
/* initialize early logging */
|
||||
virLogSetFromEnv();
|
||||
|
||||
#ifdef WITH_DRIVER_MODULES
|
||||
if (strstr(argv[0], "lt-libvirtd") &&
|
||||
(access("./.git", R_OK) >= 0 || access("../.git", R_OK) >= 0))
|
||||
virDriverModuleInitialize("./src/.libs");
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
int optidx = 0;
|
||||
int c;
|
||||
|
|
18
src/driver.c
18
src/driver.c
|
@ -38,16 +38,30 @@
|
|||
|
||||
# include <dlfcn.h>
|
||||
|
||||
static const char *moddir = NULL;
|
||||
|
||||
void
|
||||
virDriverModuleInitialize(const char *defmoddir)
|
||||
{
|
||||
const char *custommoddir = getenv("LIBVIRT_DRIVER_DIR");
|
||||
if (custommoddir)
|
||||
moddir = custommoddir;
|
||||
else if (defmoddir)
|
||||
moddir = defmoddir;
|
||||
else
|
||||
moddir = DEFAULT_DRIVER_DIR;
|
||||
VIR_DEBUG("Module dir %s", moddir);
|
||||
}
|
||||
|
||||
void *
|
||||
virDriverLoadModule(const char *name)
|
||||
{
|
||||
const char *moddir = getenv("LIBVIRT_DRIVER_DIR");
|
||||
char *modfile = NULL, *regfunc = NULL;
|
||||
void *handle = NULL;
|
||||
int (*regsym)(void);
|
||||
|
||||
if (moddir == NULL)
|
||||
moddir = DEFAULT_DRIVER_DIR;
|
||||
virDriverModuleInitialize(NULL);
|
||||
|
||||
VIR_DEBUG("Module load %s", name);
|
||||
|
||||
|
|
|
@ -1621,6 +1621,7 @@ int virRegisterNWFilterDriver(virNWFilterDriverPtr);
|
|||
# ifdef WITH_LIBVIRTD
|
||||
int virRegisterStateDriver(virStateDriverPtr);
|
||||
# endif
|
||||
void virDriverModuleInitialize(const char *defmoddir);
|
||||
void *virDriverLoadModule(const char *name);
|
||||
|
||||
#endif /* __VIR_DRIVER_H__ */
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
|
||||
# driver.h
|
||||
virDriverLoadModule;
|
||||
virDriverModuleInitialize;
|
||||
|
|
Loading…
Reference in New Issue