From nobody Mon Dec 15 23:04:53 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 1524671873417414.0962925286658; Wed, 25 Apr 2018 08:57:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA2BD30BC123; Wed, 25 Apr 2018 15:57:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25179611AA; Wed, 25 Apr 2018 15:57:51 +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 F18534CAA5; Wed, 25 Apr 2018 15:57:49 +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 w3PFqnJd026783 for ; Wed, 25 Apr 2018 11:52:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF8D2202323A; Wed, 25 Apr 2018 15:52:49 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C9492023239; Wed, 25 Apr 2018 15:52:49 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 25 Apr 2018 16:52:43 +0100 Message-Id: <20180425155243.23406-7-berrange@redhat.com> In-Reply-To: <20180425155243.23406-1-berrange@redhat.com> References: <20180425155243.23406-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 Cc: Peter Krempa Subject: [libvirt] [PATCH 6/6] storage: create separate loadable modules for storage file drivers 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 25 Apr 2018 15:57:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The storage file drivers are currently loaded as a side effect of loading the storage driver. This is a bogus dependancy because the storage file code has no interaction with the storage drivers, and even ultimately be running in a completely separate daemon. Signed-off-by: Daniel P. Berrang=C3=A9 --- libvirt.spec.in | 4 ++ src/storage/Makefile.inc.am | 40 +++++++++++++++++++ src/storage/storage_backend_fs.c | 4 -- src/storage/storage_backend_gluster.c | 4 -- src/util/virstoragefile.c | 10 +++-- src/util/virstoragefilebackend.c | 72 +++++++++++++++++++++++++++----= ---- src/util/virstoragefilebackend.h | 9 ++--- 7 files changed, 111 insertions(+), 32 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 5090dfa2aa..e8705bbb48 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1384,6 +1384,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-dr= iver/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-driver/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-backend/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-backend/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-file/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-file/*.a %if %{with_wireshark} rm -f $RPM_BUILD_ROOT%{_libdir}/wireshark/plugins/libvirt.la %endif @@ -1886,6 +1888,7 @@ exit 0 %attr(0755, root, root) %{_libexecdir}/libvirt_parthelper %{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so +%{_libdir}/%{name}/storage-file/libvirt_storage_file_fs.so =20 %files daemon-driver-storage-disk %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so @@ -1905,6 +1908,7 @@ exit 0 %if %{with_storage_gluster} %files daemon-driver-storage-gluster %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_gluster.so +%{_libdir}/%{name}/storage-file/libvirt_storage_file_gluster.so %endif =20 %if %{with_storage_rbd} diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am index af2c97ab93..ea98c0ee52 100644 --- a/src/storage/Makefile.inc.am +++ b/src/storage/Makefile.inc.am @@ -14,6 +14,9 @@ STORAGE_DRIVER_SOURCES =3D \ STORAGE_DRIVER_FS_SOURCES =3D \ storage/storage_backend_fs.h \ storage/storage_backend_fs.c \ + $(NULL) + +STORAGE_FILE_FS_SOURCES =3D \ storage/storage_file_fs.h \ storage/storage_file_fs.c \ $(NULL) @@ -57,6 +60,9 @@ STORAGE_DRIVER_SHEEPDOG_SOURCES =3D \ STORAGE_DRIVER_GLUSTER_SOURCES =3D \ storage/storage_backend_gluster.h \ storage/storage_backend_gluster.c \ + $(NULL) + +STORAGE_FILE_GLUSTER_SOURCES =3D \ storage/storage_file_gluster.h \ storage/storage_file_gluster.c \ $(NULL) @@ -80,6 +86,7 @@ STATEFUL_DRIVER_SOURCE_FILES +=3D $(STORAGE_DRIVER_SOURCE= S) EXTRA_DIST +=3D \ $(STORAGE_DRIVER_SOURCES) \ $(STORAGE_DRIVER_FS_SOURCES) \ + $(STORAGE_FILE_FS_SOURCES) \ $(STORAGE_DRIVER_LVM_SOURCES) \ $(STORAGE_DRIVER_ISCSI_SOURCES) \ $(STORAGE_DRIVER_SCSI_SOURCES) \ @@ -88,6 +95,7 @@ EXTRA_DIST +=3D \ $(STORAGE_DRIVER_RBD_SOURCES) \ $(STORAGE_DRIVER_SHEEPDOG_SOURCES) \ $(STORAGE_DRIVER_GLUSTER_SOURCES) \ + $(STORAGE_FILE_GLUSTER_SOURCES) \ $(STORAGE_DRIVER_ZFS_SOURCES) \ $(STORAGE_DRIVER_VSTORAGE_SOURCES) \ $(STORAGE_HELPER_DISK_SOURCES) \ @@ -96,6 +104,9 @@ EXTRA_DIST +=3D \ storagebackenddir =3D $(libdir)/libvirt/storage-backend storagebackend_LTLIBRARIES =3D =20 +storagefiledir =3D $(libdir)/libvirt/storage-file +storagefile_LTLIBRARIES =3D + # Needed to keep automake quiet about conditionals libvirt_driver_storage_impl_la_SOURCES =3D libvirt_driver_storage_impl_la_CFLAGS =3D \ @@ -136,6 +147,19 @@ libvirt_storage_backend_fs_la_LIBADD =3D \ libvirt.la \ ../gnulib/lib/libgnu.la \ $(NULL) + +libvirt_storage_file_fs_la_SOURCES =3D $(STORAGE_FILE_FS_SOURCES) +libvirt_storage_file_fs_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) \ + $(NULL) + +storagefile_LTLIBRARIES +=3D libvirt_storage_file_fs.la +libvirt_storage_file_fs_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_storage_file_fs_la_LIBADD =3D \ + libvirt.la \ + ../gnulib/lib/libgnu.la \ + $(NULL) endif WITH_STORAGE =20 if WITH_STORAGE_LVM @@ -270,6 +294,22 @@ libvirt_storage_backend_gluster_la_CFLAGS =3D \ =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_gluster.la libvirt_storage_backend_gluster_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) + + +libvirt_storage_file_gluster_la_SOURCES =3D $(STORAGE_FILE_GLUSTER_SOURCES) +libvirt_storage_file_gluster_la_LIBADD =3D \ + libvirt.la \ + $(GLUSTERFS_LIBS) \ + ../gnulib/lib/libgnu.la \ + $(NULL) +libvirt_storage_file_gluster_la_CFLAGS =3D \ + -I$(srcdir)/conf \ + $(GLUSTERFS_CFLAGS) \ + $(AM_CFLAGS) \ + $(NULL) + +storagefile_LTLIBRARIES +=3D libvirt_storage_file_gluster.la +libvirt_storage_file_gluster_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) endif WITH_STORAGE_GLUSTER =20 if WITH_STORAGE_ZFS diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index bface86b43..37fea8c941 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -32,7 +32,6 @@ =20 #include "virerror.h" #include "storage_backend_fs.h" -#include "storage_file_fs.h" #include "storage_util.h" #include "storage_conf.h" #include "vircommand.h" @@ -713,8 +712,5 @@ virStorageBackendFsRegister(void) return -1; #endif /* WITH_STORAGE_FS */ =20 - if (virStorageFileFsRegister() < 0) - return -1; - return 0; } diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index aca772676c..5d4b920a60 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -24,7 +24,6 @@ #include =20 #include "storage_backend_gluster.h" -#include "storage_file_gluster.h" #include "storage_conf.h" #include "viralloc.h" #include "virerror.h" @@ -567,8 +566,5 @@ virStorageBackendGlusterRegister(void) if (virStorageBackendRegister(&virStorageBackendGluster) < 0) return -1; =20 - if (virStorageFileGlusterRegister() < 0) - return -1; - return 0; } diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index da13d51d32..73937b527a 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4117,7 +4117,9 @@ virStorageFileGetBackendForSupportCheck(const virStor= ageSource *src, =20 actualType =3D virStorageSourceGetActualType(src); =20 - *backend =3D virStorageFileBackendForTypeInternal(actualType, src->pro= tocol, false); + if (virStorageFileBackendForType(actualType, src->protocol, false, bac= kend) < 0) + return -1; + return 0; } =20 @@ -4234,8 +4236,10 @@ virStorageFileInitAs(virStorageSourcePtr src, else src->drv->gid =3D gid; =20 - if (!(src->drv->backend =3D virStorageFileBackendForType(actualType, - src->protocol))) + if (virStorageFileBackendForType(actualType, + src->protocol, + true, + &src->drv->backend) < 0) goto error; =20 if (src->drv->backend->backendInit && diff --git a/src/util/virstoragefilebackend.c b/src/util/virstoragefileback= end.c index df86ee39c2..ac087dabac 100644 --- a/src/util/virstoragefilebackend.c +++ b/src/util/virstoragefilebackend.c @@ -32,6 +32,7 @@ #include "internal.h" #include "virstoragefilebackend.h" #include "virlog.h" +#include "virmodule.h" #include "virfile.h" #include "configmake.h" =20 @@ -44,6 +45,46 @@ VIR_LOG_INIT("storage.storage_source_backend"); static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKEND= S_MAX]; static size_t virStorageFileBackendsCount; =20 +#define STORAGE_FILE_MODULE_DIR LIBDIR "/libvirt/storage-file" + +static int +virStorageFileLoadBackendModule(const char *name, + const char *regfunc, + bool forceload) +{ + char *modfile =3D NULL; + int ret; + + if (!(modfile =3D virFileFindResourceFull(name, + "libvirt_storage_file_", + ".so", + abs_topbuilddir "/src/.libs", + STORAGE_FILE_MODULE_DIR, + "LIBVIRT_STORAGE_FILE_DIR"))) + return -1; + + ret =3D virModuleLoad(modfile, regfunc, forceload); + + VIR_FREE(modfile); + + return ret; +} + + +static int virStorageFileBackendOnceInit(void) +{ +#if WITH_STORAGE_DIR || WITH_STORAGE_FS + if (virStorageFileLoadBackendModule("fs", "virStorageFileFsRegister", = false) < 0) + return -1; +#endif /* WITH_STORAGE_DIR || WITH_STORAGE_FS */ +#if WITH_STORAGE_GLUSTER + if (virStorageFileLoadBackendModule("gluster", "virStorageFileGlusterR= egister", false) < 0) + return -1; +#endif /* WITH_STORAGE_GLUSTER */ + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virStorageFileBackend) =20 int virStorageFileBackendRegister(virStorageFileBackendPtr backend) @@ -65,25 +106,32 @@ virStorageFileBackendRegister(virStorageFileBackendPtr= backend) return 0; } =20 -virStorageFileBackendPtr -virStorageFileBackendForTypeInternal(int type, - int protocol, - bool report) +int +virStorageFileBackendForType(int type, + int protocol, + bool required, + virStorageFileBackendPtr *backend) { size_t i; =20 + *backend =3D NULL; + + if (virStorageFileBackendInitialize() < 0) + return -1; + for (i =3D 0; i < virStorageFileBackendsCount; i++) { if (virStorageFileBackends[i]->type =3D=3D type) { if (type =3D=3D VIR_STORAGE_TYPE_NETWORK && virStorageFileBackends[i]->protocol !=3D protocol) continue; =20 - return virStorageFileBackends[i]; + *backend =3D virStorageFileBackends[i]; + return 0; } } =20 - if (!report) - return NULL; + if (!required) + return 0; =20 if (type =3D=3D VIR_STORAGE_TYPE_NETWORK) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -96,13 +144,5 @@ virStorageFileBackendForTypeInternal(int type, virStorageTypeToString(type)); } =20 - return NULL; -} - - -virStorageFileBackendPtr -virStorageFileBackendForType(int type, - int protocol) -{ - return virStorageFileBackendForTypeInternal(type, protocol, true); + return -1; } diff --git a/src/util/virstoragefilebackend.h b/src/util/virstoragefileback= end.h index 6cd51750ee..6686864367 100644 --- a/src/util/virstoragefilebackend.h +++ b/src/util/virstoragefilebackend.h @@ -71,11 +71,10 @@ typedef int uid_t uid, gid_t gid); =20 -virStorageFileBackendPtr virStorageFileBackendForType(int type, int protoc= ol); -virStorageFileBackendPtr virStorageFileBackendForTypeInternal(int type, - int protocol, - bool report); - +int virStorageFileBackendForType(int type, + int protocol, + bool required, + virStorageFileBackendPtr *backend); =20 struct _virStorageFileBackend { int type; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list