[libvirt] [PATCH v2 0/5] storage: modularize storage backend drivers

Version 2 contains one more patch that adds disables the 'zfs' and 'vstorage' backends in the spec file. The rest is the same, but I've reposted it due to it's nature. Peter Krempa (5): spec: Don't check for storage driver backends in configure script storage: Turn storage backends into dynamic modules tests: drivermodule: Make sure that all compiled storage backends can be loaded spec: Modularize the storage driver news: Mention storage driver split docs/news.xml | 10 +++ libvirt.spec.in | 188 ++++++++++++++++++++++++++++++++++++------ src/Makefile.am | 85 ++++++++++++++++++- src/storage/storage_backend.c | 70 ++++++++++++---- src/storage/storage_backend.h | 2 +- src/storage/storage_driver.c | 19 ++++- src/storage/storage_driver.h | 1 + tests/Makefile.am | 4 +- tests/virdrivermoduletest.c | 2 +- tests/virstoragetest.c | 2 +- 10 files changed, 337 insertions(+), 46 deletions(-) -- 2.11.1

Explicitly enable --with-storage-scsi and disable --without-storage-zfs and --without-storage-vstorage so that the configure script doesn't check for them. Note that --with-storage-dir is enabled by default. --- Notes: v2: - new in series libvirt.spec.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index ec199e9c8..f4ea89d77 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1182,11 +1182,14 @@ rm -f po/stamp-po --with-storage-fs \ --with-storage-lvm \ --with-storage-iscsi \ + --with-storage-scsi \ --with-storage-disk \ --with-storage-mpath \ %{?arg_storage_rbd} \ %{?arg_storage_sheepdog} \ %{?arg_storage_gluster} \ + --without-storage-zfs \ + --without-storage-vstorage \ %{?arg_numactl} \ %{?arg_numad} \ --with-capng \ -- 2.11.1

If driver modules are enabled turn storage driver backends into dynamically loadable objects. This will allow greater modularity for binary distributions, where heavyweight dependencies as rbd and gluster can be avoided by selecting only a subset of drivers if the rest is not necessary. The storage modules are installed into 'LIBDIR/libvirt/storage-backend/' and users can't override the location by using 'LIBVIRT_STORAGE_BACKEND_DIR' environment variable. rpm based distros will at this point install all the backends when libvirt-daemon-driver-storage package is installed. --- libvirt.spec.in | 17 +++++++++ src/Makefile.am | 85 ++++++++++++++++++++++++++++++++++++++++++- src/storage/storage_backend.c | 60 +++++++++++++++++++++++------- tests/Makefile.am | 4 +- 4 files changed, 151 insertions(+), 15 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index f4ea89d77..a9af97f10 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1239,6 +1239,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-driver/*.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 %if %{with_wireshark} %if 0%{fedora} >= 24 rm -f $RPM_BUILD_ROOT%{_libdir}/wireshark/plugins/libvirt.la @@ -1694,6 +1696,21 @@ exit 0 %files daemon-driver-storage %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-backend/libvirt_storage_backend_disk.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_logical.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_scsi.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_iscsi.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_mpath.so +%if %{with_storage_gluster} +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_gluster.so +%endif +%if %{with_storage_rbd} +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_rbd.so +%endif +%if %{with_storage_sheepdog} +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_sheepdog.so +%endif %if %{with_qemu} %files daemon-driver-qemu diff --git a/src/Makefile.am b/src/Makefile.am index 7099f1b88..a85cd0df8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -972,9 +972,12 @@ SECRET_DRIVER_SOURCES = \ secret/secret_driver.h secret/secret_driver.c # Storage backend specific impls +STORAGE_DRIVER_BACKEND_SOURCES = \ + storage/storage_backend.h storage/storage_backend.c + STORAGE_DRIVER_SOURCES = \ storage/storage_driver.h storage/storage_driver.c \ - storage/storage_backend.h storage/storage_backend.c \ + $(STORAGE_DRIVER_BACKEND_SOURCES) \ storage/storage_util.h storage/storage_util.c STORAGE_DRIVER_FS_SOURCES = \ @@ -1661,6 +1664,12 @@ if WITH_BLKID libvirt_driver_storage_impl_la_CFLAGS += $(BLKID_CFLAGS) libvirt_driver_storage_impl_la_LIBADD += $(BLKID_LIBS) endif WITH_BLKID + +if WITH_DRIVER_MODULES +storagebackenddir = $(libdir)/libvirt/storage-backend +storagebackend_LTLIBRARIES = +endif WITH_DRIVER_MODULES + if WITH_STORAGE noinst_LTLIBRARIES += libvirt_driver_storage_impl.la libvirt_driver_storage_la_SOURCES = @@ -1682,8 +1691,14 @@ libvirt_storage_backend_fs_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_fs.la +libvirt_storage_backend_fs_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_fs.la libvirt_driver_storage_impl_la_LIBADD += libvirt_storage_backend_fs.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE if WITH_STORAGE_LVM @@ -1693,9 +1708,15 @@ libvirt_storage_backend_logical_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_logical.la +libvirt_storage_backend_logical_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_logical.la libvirt_driver_storage_impl_la_LIBADD += \ libvirt_storage_backend_logical.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_LVM if WITH_STORAGE_ISCSI @@ -1706,9 +1727,15 @@ libvirt_storage_backend_iscsi_la_CFLAGS = \ -I$(srcdir)/secret \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_iscsi.la +libvirt_storage_backend_iscsi_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_iscsi.la libvirt_driver_storage_impl_la_LIBADD += \ libvirt_storage_backend_iscsi.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_ISCSI if WITH_STORAGE_SCSI @@ -1717,8 +1744,14 @@ libvirt_storage_backend_scsi_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_scsi.la +libvirt_storage_backend_scsi_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_scsi.la libvirt_driver_storage_impl_la_LIBADD += libvirt_storage_backend_scsi.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_SCSI if WITH_STORAGE_MPATH @@ -1730,9 +1763,15 @@ libvirt_storage_backend_mpath_la_CFLAGS = \ $(DEVMAPPER_CFLAGS) \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_mpath.la +libvirt_storage_backend_mpath_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_mpath.la libvirt_driver_storage_impl_la_LIBADD += \ libvirt_storage_backend_mpath.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_MPATH if WITH_STORAGE_DISK @@ -1741,8 +1780,14 @@ libvirt_storage_backend_disk_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_disk.la +libvirt_storage_backend_disk_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_disk.la libvirt_driver_storage_impl_la_LIBADD += libvirt_storage_backend_disk.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_DISK if WITH_STORAGE_RBD @@ -1753,8 +1798,14 @@ libvirt_storage_backend_rbd_la_CFLAGS = \ -I$(srcdir)/secret \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_rbd.la +libvirt_storage_backend_rbd_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_rbd.la libvirt_driver_storage_impl_la_LIBADD += libvirt_storage_backend_rbd.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_RBD if WITH_STORAGE_SHEEPDOG @@ -1764,9 +1815,23 @@ libvirt_storage_backend_sheepdog_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +libvirt_storage_backend_sheepdog_priv_la_SOURCES = \ + $(STORAGE_DRIVER_SHEEPDOG_SOURCES) \ + $(STORAGE_DRIVER_BACKEND_SOURCES) +libvirt_storage_backend_sheepdog_priv_la_CFLAGS = \ + -I$(srcdir)/conf \ + $(AM_CFLAGS) +noinst_LTLIBRARIES += libvirt_storage_backend_sheepdog_priv.la + +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_sheepdog.la +libvirt_storage_backend_sheepdog_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_sheepdog.la libvirt_driver_storage_impl_la_LIBADD += \ libvirt_storage_backend_sheepdog.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_SHEEPDOG if WITH_STORAGE_GLUSTER @@ -1778,9 +1843,15 @@ libvirt_storage_backend_gluster_la_CFLAGS = \ $(GLUSTERFS_CFLAGS) \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_gluster.la +libvirt_storage_backend_gluster_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_gluster.la libvirt_driver_storage_impl_la_LIBADD += \ libvirt_storage_backend_gluster.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_GLUSTER if WITH_STORAGE_ZFS @@ -1789,8 +1860,14 @@ libvirt_storage_backend_zfs_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_zfs.la +libvirt_storage_backend_zfs_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_zfs.la libvirt_driver_storage_impl_la_LIBADD += libvirt_storage_backend_zfs.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_ZFS if WITH_STORAGE_VSTORAGE @@ -1800,9 +1877,15 @@ libvirt_storage_backend_vstorage_la_CFLAGS = \ -I$(srcdir)/conf \ $(AM_CFLAGS) +if WITH_DRIVER_MODULES +storagebackend_LTLIBRARIES += libvirt_storage_backend_vstorage.la +libvirt_storage_backend_vstorage_la_LDFLAGS = \ + -module -avoid-version $(AM_LDFLAGS) +else ! WITH_DRIVER_MODULES noinst_LTLIBRARIES += libvirt_storage_backend_vstorage.la libvirt_driver_storage_impl_la_LIBADD += \ libvirt_storage_backend_vstorage.la +endif ! WITH_DRIVER_MODULES endif WITH_STORAGE_VSTORAGE if WITH_NODE_DEVICES diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index d8099be36..32f45e841 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -33,6 +33,8 @@ #include "virstoragefile.h" #include "storage_backend.h" #include "virlog.h" +#include "virfile.h" +#include "configmake.h" #if WITH_STORAGE_LVM # include "storage_backend_logical.h" @@ -79,45 +81,77 @@ static size_t virStorageBackendsCount; static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKENDS_MAX]; static size_t virStorageFileBackendsCount; -#define VIR_STORAGE_BACKEND_REGISTER(name) \ - if (name() < 0) \ +#if WITH_DRIVER_MODULES + +# define STORAGE_BACKEND_MODULE_DIR LIBDIR "/libvirt/storage-backend" + +static int +virStorageDriverLoadBackendModule(const char *name, + const char *regfunc) +{ + char *modfile = NULL; + int ret; + + if (!(modfile = virFileFindResourceFull(name, + "libvirt_storage_backend_", + ".so", + abs_topbuilddir "/src/.libs", + STORAGE_BACKEND_MODULE_DIR, + "LIBVIRT_STORAGE_BACKEND_DIR"))) + return 1; + + ret = virDriverLoadModuleFull(modfile, regfunc, NULL); + + VIR_FREE(modfile); + + return ret; +} + + +# define VIR_STORAGE_BACKEND_REGISTER(func, module) \ + if (virStorageDriverLoadBackendModule(module, #func) < 0) \ + return -1 +#else +# define VIR_STORAGE_BACKEND_REGISTER(func, module) \ + if (func() < 0) \ return -1 +#endif int virStorageBackendDriversRegister(void) { #if WITH_STORAGE_DIR || WITH_STORAGE_FS - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister, "fs"); #endif #if WITH_STORAGE_LVM - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendLogicalRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendLogicalRegister, "logical"); #endif #if WITH_STORAGE_ISCSI - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendISCSIRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendISCSIRegister, "iscsi"); #endif #if WITH_STORAGE_SCSI - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSCSIRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSCSIRegister, "scsi"); #endif #if WITH_STORAGE_MPATH - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendMpathRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendMpathRegister, "mpath"); #endif #if WITH_STORAGE_DISK - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendDiskRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendDiskRegister, "disk"); #endif #if WITH_STORAGE_RBD - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRBDRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRBDRegister, "rbd"); #endif #if WITH_STORAGE_SHEEPDOG - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSheepdogRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendSheepdogRegister, "sheepdog"); #endif #if WITH_STORAGE_GLUSTER - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendGlusterRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendGlusterRegister, "gluster"); #endif #if WITH_STORAGE_ZFS - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendZFSRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendZFSRegister, "zfs"); #endif #if WITH_STORAGE_VSTORAGE - VIR_STORAGE_BACKEND_REGISTER(virStorageBackendVstorageRegister); + VIR_STORAGE_BACKEND_REGISTER(virStorageBackendVstorageRegister, "vstorage"); #endif return 0; diff --git a/tests/Makefile.am b/tests/Makefile.am index 32a7282d4..35e82abf5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -805,7 +805,9 @@ storagebackendsheepdogtest_SOURCES = \ storagebackendsheepdogtest.c \ testutils.c testutils.h storagebackendsheepdogtest_LDADD = \ - ../src/libvirt_driver_storage_impl.la $(LDADDS) + ../src/libvirt_driver_storage_impl.la \ + ../src/libvirt_storage_backend_sheepdog_priv.la \ + $(LDADDS) else ! WITH_STORAGE_SHEEPDOG EXTRA_DIST += storagebackendsheepdogtest.c endif ! WITH_STORAGE_SHEEPDOG -- 2.11.1

On Tue, Feb 21, 2017 at 12:55:08 +0100, Peter Krempa wrote:
If driver modules are enabled turn storage driver backends into dynamically loadable objects. This will allow greater modularity for binary distributions, where heavyweight dependencies as rbd and gluster can be avoided by selecting only a subset of drivers if the rest is not necessary.
The storage modules are installed into 'LIBDIR/libvirt/storage-backend/' and users can't override the location by using
s/can't/can/ as pointed out by John in previous version. (already in my tree now).

Add a new storage driver registration function that will force the backend code to fail if any of the storage backend modules can't be loaded. This will make sure that they work and are present. --- src/storage/storage_backend.c | 16 ++++++++++++---- src/storage/storage_backend.h | 2 +- src/storage/storage_driver.c | 19 +++++++++++++++++-- src/storage/storage_driver.h | 1 + tests/virdrivermoduletest.c | 2 +- tests/virstoragetest.c | 2 +- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 32f45e841..ce278b99c 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -87,7 +87,8 @@ static size_t virStorageFileBackendsCount; static int virStorageDriverLoadBackendModule(const char *name, - const char *regfunc) + const char *regfunc, + bool forceload) { char *modfile = NULL; int ret; @@ -100,7 +101,14 @@ virStorageDriverLoadBackendModule(const char *name, "LIBVIRT_STORAGE_BACKEND_DIR"))) return 1; - ret = virDriverLoadModuleFull(modfile, regfunc, NULL); + if ((ret = virDriverLoadModuleFull(modfile, regfunc, NULL)) != 0) { + if (forceload) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to load storage backend module '%s'"), + name); + ret = -1; + } + } VIR_FREE(modfile); @@ -109,7 +117,7 @@ virStorageDriverLoadBackendModule(const char *name, # define VIR_STORAGE_BACKEND_REGISTER(func, module) \ - if (virStorageDriverLoadBackendModule(module, #func) < 0) \ + if (virStorageDriverLoadBackendModule(module, #func, allbackends) < 0) \ return -1 #else # define VIR_STORAGE_BACKEND_REGISTER(func, module) \ @@ -118,7 +126,7 @@ virStorageDriverLoadBackendModule(const char *name, #endif int -virStorageBackendDriversRegister(void) +virStorageBackendDriversRegister(bool allbackends ATTRIBUTE_UNUSED) { #if WITH_STORAGE_DIR || WITH_STORAGE_FS VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister, "fs"); diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index ca6c19c45..f433071f4 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -198,7 +198,7 @@ struct _virStorageFileBackend { virStorageFileBackendChown storageFileChown; }; -int virStorageBackendDriversRegister(void); +int virStorageBackendDriversRegister(bool allmodules); int virStorageBackendRegister(virStorageBackendPtr backend); int virStorageBackendFileRegister(virStorageFileBackendPtr backend); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7fafbcf75..0bc047f23 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2838,9 +2838,10 @@ static virStateDriver stateDriver = { .stateReload = storageStateReload, }; -int storageRegister(void) +static int +storageRegisterFull(bool allbackends) { - if (virStorageBackendDriversRegister() < 0) + if (virStorageBackendDriversRegister(allbackends) < 0) return -1; if (virSetSharedStorageDriver(&storageDriver) < 0) return -1; @@ -2850,6 +2851,20 @@ int storageRegister(void) } +int +storageRegister(void) +{ + return storageRegisterFull(false); +} + + +int +storageRegisterAll(void) +{ + return storageRegisterFull(true); +} + + /* ----------- file handlers cooperating with storage driver --------------- */ static bool virStorageFileIsInitialized(const virStorageSource *src) diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h index 682c9ff82..f0aca3671 100644 --- a/src/storage/storage_driver.h +++ b/src/storage/storage_driver.h @@ -70,5 +70,6 @@ char *virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int storageRegister(void); +int storageRegisterAll(void); #endif /* __VIR_STORAGE_DRIVER_H__ */ diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index e440350c2..13d51a8e9 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -71,7 +71,7 @@ mymain(void) TEST("interface"); #endif #ifdef WITH_STORAGE - TEST("storage"); + TEST_FULL("storage", "storageRegisterAll"); #endif #ifdef WITH_NODE_DEVICES TEST("nodedev"); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index d715fd762..36567753b 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -732,7 +732,7 @@ mymain(void) virStorageSourcePtr chain2; /* short for chain->backingStore */ virStorageSourcePtr chain3; /* short for chain2->backingStore */ - if (virStorageBackendDriversRegister() < 0) + if (virStorageBackendDriversRegister(false) < 0) return -1; /* Prep some files with qemu-img; if that is not found on PATH, or -- 2.11.1

Create a new set of sub-packages containing the new storage driver modules so that certain heavy-weight backends (gluster, rbd) can be installed separately only if required. To keep backward compatibility the 'libvirt-driver-storage' package will be turned into a virtual package pulling in all the new storage backend sub-packages. The storage driver module will be moved into libvirt-driver-storage-core including the filesystem backend which is mandatory. This then allows to make libvirt-daemon-driver-qemu depend only on the core of the storage driver. All other meta-packages still depend on the full storage driver and thus pull in all the backends. --- libvirt.spec.in | 168 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 143 insertions(+), 25 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index a9af97f10..7f3d18f72 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -585,35 +585,13 @@ Requires: libvirt-daemon = %{version}-%{release} The secret driver plugin for the libvirtd daemon, providing an implementation of the secret key APIs. - -%package daemon-driver-storage -Summary: Storage driver plugin for the libvirtd daemon +%package daemon-driver-storage-core +Summary: Storage driver plugin including base backends for the libvirtd daemon Group: Development/Libraries Requires: libvirt-daemon = %{version}-%{release} Requires: nfs-utils # For mkfs Requires: util-linux -# For glusterfs -%if 0%{?fedora} -Requires: glusterfs-client >= 2.0.1 -%endif -# gluster cli tool for pool discovery -%if (0%{?fedora} || 0%{?with_storage_gluster}) -Requires: /usr/sbin/gluster -%endif -# For LVM drivers -Requires: lvm2 -# For ISCSI driver -Requires: iscsi-initiator-utils -# For disk driver -Requires: parted -Requires: device-mapper -# For multipath support -Requires: device-mapper -%if %{with_storage_sheepdog} -# For Sheepdog support -Requires: sheepdog -%endif %if %{with_qemu} # From QEMU RPMs Requires: /usr/bin/qemu-img @@ -624,6 +602,128 @@ Requires: /usr/sbin/qcow-create %endif %endif +%description daemon-driver-storage-core +The storage driver plugin for the libvirtd daemon, providing +an implementation of the storage APIs using files, local disks, LVM, SCSI, +iSCSI, and multipath storage. + +%package daemon-driver-storage-logical +Summary: Storage driver plugin for lvm volumes +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: lvm2 + +%description daemon-driver-storage-logical +The storage driver backend adding implementation of the storage APIs for block +volumes using lvm. + + +%package daemon-driver-storage-disk +Summary: Storage driver plugin for disk +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: parted +Requires: device-mapper + +%description daemon-driver-storage-disk +The storage driver backend adding implementation of the storage APIs for block +volumes using the host disks. + + +%package daemon-driver-storage-scsi +Summary: Storage driver plugin for local scsi devices +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} + +%description daemon-driver-storage-scsi +The storage driver backend adding implementation of the storage APIs for scsi +host devices. + + +%package daemon-driver-storage-iscsi +Summary: Storage driver plugin for iscsi +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: iscsi-initiator-utils + +%description daemon-driver-storage-iscsi +The storage driver backend adding implementation of the storage APIs for iscsi +volumes using the host iscsi stack. + + +%package daemon-driver-storage-mpath +Summary: Storage driver plugin for multipath volumes +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: device-mapper + +%description daemon-driver-storage-mpath +The storage driver backend adding implementation of the storage APIs for +multipath storage using device mapper. + + +%if %{with_storage_gluster} +%package daemon-driver-storage-gluster +Summary: Storage driver plugin for gluster +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} + %if 0%{?fedora} +Requires: glusterfs-client >= 2.0.1 + %endif + %if (0%{?fedora} || 0%{?with_storage_gluster}) +Requires: /usr/sbin/gluster + %endif + +%description daemon-driver-storage-gluster +The storage driver backend adding implementation of the storage APIs for gluster +volumes using libgfapi. +%endif + + +%if %{with_storage_rbd} +%package daemon-driver-storage-rbd +Summary: Storage driver plugin for rbd +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} + +%description daemon-driver-storage-rbd +The storage driver backend adding implementation of the storage APIs for rbd +volumes using the ceph protocol. +%endif + + +%if %{with_storage_sheepdog} +%package daemon-driver-storage-sheepdog +Summary: Storage driver plugin for sheepdog +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: sheepdog + +%description daemon-driver-storage-sheepdog +The storage driver backend adding implementation of the storage APIs for +sheepdog volumes using. +%endif + + +%package daemon-driver-storage +Summary: Storage driver plugin including all backends for the libvirtd daemon +Group: Development/Libraries +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-disk = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-logical = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-scsi = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-iscsi = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-mpath = %{version}-%{release} +%if %{with_storage_gluster} +Requires: libvirt-daemon-driver-storage-gluster = %{version}-%{release} +%endif +%if %{with_storage_rbd} +Requires: libvirt-daemon-driver-storage-rbd = %{version}-%{release} +%endif +%if %{with_storage_sheepdog} +Requires: libvirt-daemon-driver-storage-sheepdog = %{version}-%{release} +%endif + %description daemon-driver-storage The storage driver plugin for the libvirtd daemon, providing an implementation of the storage APIs using LVM, iSCSI, @@ -637,7 +737,7 @@ Group: Development/Libraries Requires: libvirt-daemon = %{version}-%{release} # There really is a hard cross-driver dependency here Requires: libvirt-daemon-driver-network = %{version}-%{release} -Requires: libvirt-daemon-driver-storage = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} Requires: /usr/bin/qemu-img # For image compression Requires: gzip @@ -1694,21 +1794,39 @@ exit 0 %{_libdir}/%{name}/connection-driver/libvirt_driver_secret.so %files daemon-driver-storage + +%files daemon-driver-storage-core %attr(0755, root, root) %{_libexecdir}/libvirt_parthelper %{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so + +%files daemon-driver-storage-disk %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so + +%files daemon-driver-storage-logical %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_logical.so + +%files daemon-driver-storage-scsi %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_scsi.so + +%files daemon-driver-storage-iscsi %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_iscsi.so + +%files daemon-driver-storage-mpath %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_mpath.so + %if %{with_storage_gluster} +%files daemon-driver-storage-gluster %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_gluster.so %endif + %if %{with_storage_rbd} +%files daemon-driver-storage-rbd %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_rbd.so %endif + %if %{with_storage_sheepdog} +%files daemon-driver-storage-sheepdog %{_libdir}/%{name}/storage-backend/libvirt_storage_backend_sheepdog.so %endif -- 2.11.1

--- docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 8d53e0797..6cd469ec5 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -110,6 +110,16 @@ to/from xl.cfg. </description> </change> + <change> + <summary> + storage: modularize the storage driver + </summary> + <description> + Split up the storage driver backends into loadable modules so that + binary distributions don't have to compromise on shipping the storage + driver with all backends which may pull in too many dependencies. + </description> + </change> </section> <section title="Bug fixes"> <change> -- 2.11.1

On Tue, Feb 21, 2017 at 12:55:06PM +0100, Peter Krempa wrote:
Version 2 contains one more patch that adds disables the 'zfs' and 'vstorage' backends in the spec file. The rest is the same, but I've reposted it due to it's nature.
Peter Krempa (5): spec: Don't check for storage driver backends in configure script storage: Turn storage backends into dynamic modules tests: drivermodule: Make sure that all compiled storage backends can be loaded spec: Modularize the storage driver news: Mention storage driver split
docs/news.xml | 10 +++ libvirt.spec.in | 188 ++++++++++++++++++++++++++++++++++++------ src/Makefile.am | 85 ++++++++++++++++++- src/storage/storage_backend.c | 70 ++++++++++++---- src/storage/storage_backend.h | 2 +- src/storage/storage_driver.c | 19 ++++- src/storage/storage_driver.h | 1 + tests/Makefile.am | 4 +- tests/virdrivermoduletest.c | 2 +- tests/virstoragetest.c | 2 +- 10 files changed, 337 insertions(+), 46 deletions(-)
ACK series Jan
participants (2)
-
Ján Tomko
-
Peter Krempa