static int
virStorageDriverLoadBackendModule(const char *name,
- const char *regfunc)
+ const char *regfunc,
+ bool forceload)
{
char *modfile = NULL;
int ret;
"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);
# 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) \
#endif
int
-virStorageBackendDriversRegister(void)
+virStorageBackendDriversRegister(bool allbackends ATTRIBUTE_UNUSED)
{
#if WITH_STORAGE_DIR || WITH_STORAGE_FS
VIR_STORAGE_BACKEND_REGISTER(virStorageBackendFsRegister, "fs");
virStorageFileBackendChown storageFileChown;
};
-int virStorageBackendDriversRegister(void);
+int virStorageBackendDriversRegister(bool allmodules);
int virStorageBackendRegister(virStorageBackendPtr backend);
int virStorageBackendFileRegister(virStorageFileBackendPtr backend);
.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;
}
+int
+storageRegister(void)
+{
+ return storageRegisterFull(false);
+}
+
+
+int
+storageRegisterAll(void)
+{
+ return storageRegisterFull(true);
+}
+
+
/* ----------- file handlers cooperating with storage driver --------------- */
static bool
virStorageFileIsInitialized(const virStorageSource *src)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int storageRegister(void);
+int storageRegisterAll(void);
#endif /* __VIR_STORAGE_DRIVER_H__ */
TEST("interface");
#endif
#ifdef WITH_STORAGE
- TEST("storage");
+ TEST_FULL("storage", "storageRegisterAll");
#endif
#ifdef WITH_NODE_DEVICES
TEST("nodedev");
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