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%{wireshark_plugindir}/libvirt.la
%endif
%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
%files daemon-driver-storage-disk
%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so
%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
%if %{with_storage_rbd}
STORAGE_DRIVER_FS_SOURCES = \
storage/storage_backend_fs.h \
storage/storage_backend_fs.c \
+ $(NULL)
+
+STORAGE_FILE_FS_SOURCES = \
storage/storage_file_fs.h \
storage/storage_file_fs.c \
$(NULL)
STORAGE_DRIVER_GLUSTER_SOURCES = \
storage/storage_backend_gluster.h \
storage/storage_backend_gluster.c \
+ $(NULL)
+
+STORAGE_FILE_GLUSTER_SOURCES = \
storage/storage_file_gluster.h \
storage/storage_file_gluster.c \
$(NULL)
EXTRA_DIST += \
$(STORAGE_DRIVER_SOURCES) \
$(STORAGE_DRIVER_FS_SOURCES) \
+ $(STORAGE_FILE_FS_SOURCES) \
$(STORAGE_DRIVER_LVM_SOURCES) \
$(STORAGE_DRIVER_ISCSI_SOURCES) \
$(STORAGE_DRIVER_SCSI_SOURCES) \
$(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) \
storagebackenddir = $(libdir)/libvirt/storage-backend
storagebackend_LTLIBRARIES =
+storagefiledir = $(libdir)/libvirt/storage-file
+storagefile_LTLIBRARIES =
+
# Needed to keep automake quiet about conditionals
libvirt_driver_storage_impl_la_SOURCES =
libvirt_driver_storage_impl_la_CFLAGS = \
libvirt.la \
../gnulib/lib/libgnu.la \
$(NULL)
+
+libvirt_storage_file_fs_la_SOURCES = $(STORAGE_FILE_FS_SOURCES)
+libvirt_storage_file_fs_la_CFLAGS = \
+ -I$(srcdir)/conf \
+ $(AM_CFLAGS) \
+ $(NULL)
+
+storagefile_LTLIBRARIES += libvirt_storage_file_fs.la
+libvirt_storage_file_fs_la_LDFLAGS = $(AM_LDFLAGS_MOD)
+libvirt_storage_file_fs_la_LIBADD = \
+ libvirt.la \
+ ../gnulib/lib/libgnu.la \
+ $(NULL)
endif WITH_STORAGE
if WITH_STORAGE_LVM
storagebackend_LTLIBRARIES += libvirt_storage_backend_gluster.la
libvirt_storage_backend_gluster_la_LDFLAGS = $(AM_LDFLAGS_MOD)
+
+
+libvirt_storage_file_gluster_la_SOURCES = $(STORAGE_FILE_GLUSTER_SOURCES)
+libvirt_storage_file_gluster_la_LIBADD = \
+ libvirt.la \
+ $(GLUSTERFS_LIBS) \
+ ../gnulib/lib/libgnu.la \
+ $(NULL)
+libvirt_storage_file_gluster_la_CFLAGS = \
+ -I$(srcdir)/conf \
+ $(GLUSTERFS_CFLAGS) \
+ $(AM_CFLAGS) \
+ $(NULL)
+
+storagefile_LTLIBRARIES += libvirt_storage_file_gluster.la
+libvirt_storage_file_gluster_la_LDFLAGS = $(AM_LDFLAGS_MOD)
endif WITH_STORAGE_GLUSTER
if WITH_STORAGE_ZFS
#include "virerror.h"
#include "storage_backend_fs.h"
-#include "storage_file_fs.h"
#include "storage_util.h"
#include "storage_conf.h"
#include "vircommand.h"
return -1;
#endif /* WITH_STORAGE_FS */
- if (virStorageFileFsRegister() < 0)
- return -1;
-
return 0;
}
#include <glusterfs/api/glfs.h>
#include "storage_backend_gluster.h"
-#include "storage_file_gluster.h"
#include "storage_conf.h"
#include "viralloc.h"
#include "virerror.h"
if (virStorageBackendRegister(&virStorageBackendGluster) < 0)
return -1;
- if (virStorageFileGlusterRegister() < 0)
- return -1;
-
return 0;
}
actualType = virStorageSourceGetActualType(src);
- *backend = virStorageFileBackendForTypeInternal(actualType, src->protocol, false);
+ if (virStorageFileBackendForType(actualType, src->protocol, false, backend) < 0)
+ return -1;
+
return 0;
}
else
src->drv->gid = gid;
- if (!(src->drv->backend = virStorageFileBackendForType(actualType,
- src->protocol)))
+ if (virStorageFileBackendForType(actualType,
+ src->protocol,
+ true,
+ &src->drv->backend) < 0)
goto error;
if (src->drv->backend->backendInit &&
#include "internal.h"
#include "virstoragefilebackend.h"
#include "virlog.h"
+#include "virmodule.h"
#include "virfile.h"
#include "configmake.h"
static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKENDS_MAX];
static size_t virStorageFileBackendsCount;
+#define STORAGE_FILE_MODULE_DIR LIBDIR "/libvirt/storage-file"
+
+static int
+virStorageFileLoadBackendModule(const char *name,
+ const char *regfunc,
+ bool forceload)
+{
+ char *modfile = NULL;
+ int ret;
+
+ if (!(modfile = virFileFindResourceFull(name,
+ "libvirt_storage_file_",
+ ".so",
+ abs_topbuilddir "/src/.libs",
+ STORAGE_FILE_MODULE_DIR,
+ "LIBVIRT_STORAGE_FILE_DIR")))
+ return -1;
+
+ ret = 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", "virStorageFileGlusterRegister", false) < 0)
+ return -1;
+#endif /* WITH_STORAGE_GLUSTER */
+ return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(virStorageFileBackend)
int
virStorageFileBackendRegister(virStorageFileBackendPtr backend)
return 0;
}
-virStorageFileBackendPtr
-virStorageFileBackendForTypeInternal(int type,
- int protocol,
- bool report)
+int
+virStorageFileBackendForType(int type,
+ int protocol,
+ bool required,
+ virStorageFileBackendPtr *backend)
{
size_t i;
+ *backend = NULL;
+
+ if (virStorageFileBackendInitialize() < 0)
+ return -1;
+
for (i = 0; i < virStorageFileBackendsCount; i++) {
if (virStorageFileBackends[i]->type == type) {
if (type == VIR_STORAGE_TYPE_NETWORK &&
virStorageFileBackends[i]->protocol != protocol)
continue;
- return virStorageFileBackends[i];
+ *backend = virStorageFileBackends[i];
+ return 0;
}
}
- if (!report)
- return NULL;
+ if (!required)
+ return 0;
if (type == VIR_STORAGE_TYPE_NETWORK) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virStorageTypeToString(type));
}
- return NULL;
-}
-
-
-virStorageFileBackendPtr
-virStorageFileBackendForType(int type,
- int protocol)
-{
- return virStorageFileBackendForTypeInternal(type, protocol, true);
+ return -1;
}
uid_t uid,
gid_t gid);
-virStorageFileBackendPtr virStorageFileBackendForType(int type, int protocol);
-virStorageFileBackendPtr virStorageFileBackendForTypeInternal(int type,
- int protocol,
- bool report);
-
+int virStorageFileBackendForType(int type,
+ int protocol,
+ bool required,
+ virStorageFileBackendPtr *backend);
struct _virStorageFileBackend {
int type;