]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
driver: don't keep a pointer to the loaded library handle
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 19 Apr 2018 14:20:44 +0000 (15:20 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 24 Apr 2018 16:00:47 +0000 (17:00 +0100)
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>
src/driver.c
src/driver.h
src/storage/storage_backend.c

index 7d4c78eaaaf8f46a03bb3685b84bfe38d4290e06..4d314b38703c9bf21ea3c81ac58f26526b426565 100644 (file)
@@ -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;
-
+    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);
 
index b071a3a782567e0f3bf9e94b9f4a16791cc683dc..e28c63ecc28b055ad4c60a1441ed5ed78a30276d 100644 (file)
@@ -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);
index 053f4ecf26ebb8d137b9f9a8a4b3fe96e93a9dff..aac2f53b0125b4c05f2531e69f996cca8b134f8f 100644 (file)
@@ -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'"),