*/
int
virDriverLoadModuleFull(const char *path,
- const char *regfunc)
+ const char *regfunc,
+ bool required)
{
void *rethandle = NULL;
int (*regsym)(void);
int ret = -1;
if (!virFileExists(path)) {
- VIR_INFO("Module '%s' does not exists", path);
- return 1;
+ if (required) {
+ virReportSystemError(errno,
+ _("Failed to find module '%s'"), path);
+ return -1;
+ } else {
+ VIR_INFO("Module '%s' does not exist", path);
+ return 1;
+ }
}
if (!(rethandle = virDriverLoadModuleFile(path)))
#else /* ! HAVE_DLFCN_H */
int
virDriverLoadModuleFull(const char *path ATTRIBUTE_UNUSED,
- const char *regfunc ATTRIBUTE_UNUSED)
+ const char *regfunc ATTRIBUTE_UNUSED,
+ bool required)
{
VIR_DEBUG("dlopen not available on this platform");
- /* Since we have no dlopen(), but definition we have no
- * loadable modules on disk, so we can resaonably
- * return '1' instead of an error.
- */
- return 1;
+ if (required) {
+ virReportSystemError(ENOSYS,
+ _("Failed to find module '%s': %s"), path);
+ return -1;
+ } else {
+ /* Since we have no dlopen(), but definition we have no
+ * loadable modules on disk, so we can resaonably
+ * return '1' instead of an error.
+ */
+ return 1;
+ }
}
#endif /* ! HAVE_DLFCN_H */
int
virDriverLoadModule(const char *name,
- const char *regfunc)
+ const char *regfunc,
+ bool required)
{
char *modfile = NULL;
int ret;
"LIBVIRT_DRIVER_DIR")))
return -1;
- ret = virDriverLoadModuleFull(modfile, regfunc);
+ ret = virDriverLoadModuleFull(modfile, regfunc, required);
VIR_FREE(modfile);
int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
int virDriverLoadModule(const char *name,
- const char *regfunc);
+ const char *regfunc,
+ bool required);
int virDriverLoadModuleFull(const char *path,
- const char *regfunc);
+ const char *regfunc,
+ bool required);
virConnectPtr virGetConnectInterface(void);
virConnectPtr virGetConnectNetwork(void);
"LIBVIRT_STORAGE_BACKEND_DIR")))
return -1;
- if ((ret = virDriverLoadModuleFull(modfile, regfunc)) != 0) {
- if (forceload) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to load storage backend module '%s'"),
- name);
- ret = -1;
- }
- }
+ ret = virDriverLoadModuleFull(modfile, regfunc, forceload);
VIR_FREE(modfile);