[PATCH 04/14] driver: don't keep a pointer to the loaded library handle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/driver.c                  | 23 +++++++----------------
 src/driver.h                  |  5 ++---
 src/storage/storage_backend.c |  2 +-
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/driver.c b/src/driver.c
index 7d4c78eaaa..4d314b3870 100644
--- a/src/driver.c
+++ b/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;
-
+    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);
 
diff --git a/src/driver.h b/src/driver.h
index b071a3a782..e28c63ecc2 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -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);
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 053f4ecf26..aac2f53b01 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -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'"),
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux