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
%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
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 = \
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 =
-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
-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
-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
-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
$(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
-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
-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
-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
$(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
-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
-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
#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"
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;