From nobody Wed May 14 08:07:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524158056992131.13355937588403; Thu, 19 Apr 2018 10:14:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A62FE316423F; Thu, 19 Apr 2018 17:14:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 568665D9C7; Thu, 19 Apr 2018 17:14:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F04B3180610F; Thu, 19 Apr 2018 17:14:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3JHAB9l015102 for ; Thu, 19 Apr 2018 13:10:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DAFE2024CA1; Thu, 19 Apr 2018 17:10:11 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5FC32026985; Thu, 19 Apr 2018 17:10:10 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 19 Apr 2018 18:09:52 +0100 Message-Id: <20180419171002.17117-5-berrange@redhat.com> In-Reply-To: <20180419171002.17117-1-berrange@redhat.com> References: <20180419171002.17117-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/14] driver: don't keep a pointer to the loaded library handle X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 19 Apr 2018 17:14:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A9 --- 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 re= turned - * 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 =3D NULL; int (*regsym)(void); @@ -120,11 +118,7 @@ virDriverLoadModuleFull(const char *path, goto cleanup; } =20 - if (handle) - VIR_STEAL_PTR(*handle, rethandle); - else - rethandle =3D NULL; - + rethandle =3D NULL; ret =3D 0; =20 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 =3D NULL; return -1; } #endif /* ! HAVE_DLFCN_H */ @@ -164,7 +155,7 @@ virDriverLoadModule(const char *name, "LIBVIRT_DRIVER_DIR"))) return 1; =20 - ret =3D virDriverLoadModuleFull(modfile, regfunc, NULL); + ret =3D virDriverLoadModuleFull(modfile, regfunc); =20 VIR_FREE(modfile); =20 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 drive= r) ATTRIBUTE_RETURN_CHECK =20 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); =20 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; =20 - if ((ret =3D virDriverLoadModuleFull(modfile, regfunc, NULL)) !=3D 0) { + if ((ret =3D virDriverLoadModuleFull(modfile, regfunc)) !=3D 0) { if (forceload) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to load storage backend module '%s'"), --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list