mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
driver: don't keep a pointer to the loaded library handle
Now that we've activated two hacks to prevent unloading of modules, there is no point passing back a pointer to the loaded library handle. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
71feef9226
commit
96a72f3444
21
src/driver.c
21
src/driver.c
@ -86,12 +86,11 @@ virDriverLoadModuleFunc(void *handle,
|
||||
* virDriverLoadModuleFull:
|
||||
* @path: filename of module to load
|
||||
* @regfunc: name of the function that registers the module
|
||||
* @handle: Returns handle of the loaded library if not NULL
|
||||
*
|
||||
* Loads a loadable module named @path and calls the
|
||||
* registration function @regfunc. If @handle is not NULL the handle is returned
|
||||
* in the variable. Otherwise the handle is leaked so that the module stays
|
||||
* loaded forever.
|
||||
* registration function @regfunc. The module will never
|
||||
* be unloaded because unloading is not safe in a multi-threaded
|
||||
* application.
|
||||
*
|
||||
* The module is automatically looked up in the appropriate place (git or
|
||||
* installed directory).
|
||||
@ -100,8 +99,7 @@ virDriverLoadModuleFunc(void *handle,
|
||||
*/
|
||||
int
|
||||
virDriverLoadModuleFull(const char *path,
|
||||
const char *regfunc,
|
||||
void **handle)
|
||||
const char *regfunc)
|
||||
{
|
||||
void *rethandle = NULL;
|
||||
int (*regsym)(void);
|
||||
@ -120,11 +118,7 @@ virDriverLoadModuleFull(const char *path,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (handle)
|
||||
VIR_STEAL_PTR(*handle, rethandle);
|
||||
else
|
||||
rethandle = NULL;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
@ -136,12 +130,9 @@ virDriverLoadModuleFull(const char *path,
|
||||
#else /* ! HAVE_DLFCN_H */
|
||||
int
|
||||
virDriverLoadModuleFull(const char *path ATTRIBUTE_UNUSED,
|
||||
const char *regfunc ATTRIBUTE_UNUSED,
|
||||
void **handle)
|
||||
const char *regfunc ATTRIBUTE_UNUSED)
|
||||
{
|
||||
VIR_DEBUG("dlopen not available on this platform");
|
||||
if (handle)
|
||||
*handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
#endif /* ! HAVE_DLFCN_H */
|
||||
@ -164,7 +155,7 @@ virDriverLoadModule(const char *name,
|
||||
"LIBVIRT_DRIVER_DIR")))
|
||||
return 1;
|
||||
|
||||
ret = virDriverLoadModuleFull(modfile, regfunc, NULL);
|
||||
ret = virDriverLoadModuleFull(modfile, regfunc);
|
||||
|
||||
VIR_FREE(modfile);
|
||||
|
||||
|
@ -109,9 +109,8 @@ int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN_CHECK
|
||||
|
||||
int virDriverLoadModule(const char *name,
|
||||
const char *regfunc);
|
||||
int virDriverLoadModuleFull(const char *name,
|
||||
const char *regfunc,
|
||||
void **handle);
|
||||
int virDriverLoadModuleFull(const char *path,
|
||||
const char *regfunc);
|
||||
|
||||
virConnectPtr virGetConnectInterface(void);
|
||||
virConnectPtr virGetConnectNetwork(void);
|
||||
|
@ -97,7 +97,7 @@ virStorageDriverLoadBackendModule(const char *name,
|
||||
"LIBVIRT_STORAGE_BACKEND_DIR")))
|
||||
return 1;
|
||||
|
||||
if ((ret = virDriverLoadModuleFull(modfile, regfunc, NULL)) != 0) {
|
||||
if ((ret = virDriverLoadModuleFull(modfile, regfunc)) != 0) {
|
||||
if (forceload) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to load storage backend module '%s'"),
|
||||
|
Loading…
Reference in New Issue
Block a user