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
23
src/driver.c
23
src/driver.c
@ -86,12 +86,11 @@ virDriverLoadModuleFunc(void *handle,
|
|||||||
* virDriverLoadModuleFull:
|
* virDriverLoadModuleFull:
|
||||||
* @path: filename of module to load
|
* @path: filename of module to load
|
||||||
* @regfunc: name of the function that registers the module
|
* @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
|
* Loads a loadable module named @path and calls the
|
||||||
* registration function @regfunc. If @handle is not NULL the handle is returned
|
* registration function @regfunc. The module will never
|
||||||
* in the variable. Otherwise the handle is leaked so that the module stays
|
* be unloaded because unloading is not safe in a multi-threaded
|
||||||
* loaded forever.
|
* application.
|
||||||
*
|
*
|
||||||
* The module is automatically looked up in the appropriate place (git or
|
* The module is automatically looked up in the appropriate place (git or
|
||||||
* installed directory).
|
* installed directory).
|
||||||
@ -100,8 +99,7 @@ virDriverLoadModuleFunc(void *handle,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virDriverLoadModuleFull(const char *path,
|
virDriverLoadModuleFull(const char *path,
|
||||||
const char *regfunc,
|
const char *regfunc)
|
||||||
void **handle)
|
|
||||||
{
|
{
|
||||||
void *rethandle = NULL;
|
void *rethandle = NULL;
|
||||||
int (*regsym)(void);
|
int (*regsym)(void);
|
||||||
@ -120,11 +118,7 @@ virDriverLoadModuleFull(const char *path,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle)
|
rethandle = NULL;
|
||||||
VIR_STEAL_PTR(*handle, rethandle);
|
|
||||||
else
|
|
||||||
rethandle = NULL;
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -136,12 +130,9 @@ virDriverLoadModuleFull(const char *path,
|
|||||||
#else /* ! HAVE_DLFCN_H */
|
#else /* ! HAVE_DLFCN_H */
|
||||||
int
|
int
|
||||||
virDriverLoadModuleFull(const char *path ATTRIBUTE_UNUSED,
|
virDriverLoadModuleFull(const char *path ATTRIBUTE_UNUSED,
|
||||||
const char *regfunc ATTRIBUTE_UNUSED,
|
const char *regfunc ATTRIBUTE_UNUSED)
|
||||||
void **handle)
|
|
||||||
{
|
{
|
||||||
VIR_DEBUG("dlopen not available on this platform");
|
VIR_DEBUG("dlopen not available on this platform");
|
||||||
if (handle)
|
|
||||||
*handle = NULL;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif /* ! HAVE_DLFCN_H */
|
#endif /* ! HAVE_DLFCN_H */
|
||||||
@ -164,7 +155,7 @@ virDriverLoadModule(const char *name,
|
|||||||
"LIBVIRT_DRIVER_DIR")))
|
"LIBVIRT_DRIVER_DIR")))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
ret = virDriverLoadModuleFull(modfile, regfunc, NULL);
|
ret = virDriverLoadModuleFull(modfile, regfunc);
|
||||||
|
|
||||||
VIR_FREE(modfile);
|
VIR_FREE(modfile);
|
||||||
|
|
||||||
|
@ -109,9 +109,8 @@ int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN_CHECK
|
|||||||
|
|
||||||
int virDriverLoadModule(const char *name,
|
int virDriverLoadModule(const char *name,
|
||||||
const char *regfunc);
|
const char *regfunc);
|
||||||
int virDriverLoadModuleFull(const char *name,
|
int virDriverLoadModuleFull(const char *path,
|
||||||
const char *regfunc,
|
const char *regfunc);
|
||||||
void **handle);
|
|
||||||
|
|
||||||
virConnectPtr virGetConnectInterface(void);
|
virConnectPtr virGetConnectInterface(void);
|
||||||
virConnectPtr virGetConnectNetwork(void);
|
virConnectPtr virGetConnectNetwork(void);
|
||||||
|
@ -97,7 +97,7 @@ virStorageDriverLoadBackendModule(const char *name,
|
|||||||
"LIBVIRT_STORAGE_BACKEND_DIR")))
|
"LIBVIRT_STORAGE_BACKEND_DIR")))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((ret = virDriverLoadModuleFull(modfile, regfunc, NULL)) != 0) {
|
if ((ret = virDriverLoadModuleFull(modfile, regfunc)) != 0) {
|
||||||
if (forceload) {
|
if (forceload) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to load storage backend module '%s'"),
|
_("failed to load storage backend module '%s'"),
|
||||||
|
Loading…
Reference in New Issue
Block a user