summaryrefslogtreecommitdiff
path: root/util/module.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2019-07-22 17:13:23 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2019-08-21 16:29:57 +0200
commit81d8ccb1bea4fb9eaaf4c8e30bd4021180a9a39f (patch)
tree4f0002c5da0e89a390594e525140ffb6c6ea4727 /util/module.c
parent90629122d2ef536290882c71ca16bac3df842ca1 (diff)
module: return success on module load
Let the caller know of load success. Note that this also changes slightly the behaviour of the function to try loading on subsequent calls if the previous ones failed. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util/module.c')
-rw-r--r--util/module.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/util/module.c b/util/module.c
index ca9885c490..e9fe3e5422 100644
--- a/util/module.c
+++ b/util/module.c
@@ -156,8 +156,10 @@ out:
}
#endif
-void module_load_one(const char *prefix, const char *lib_name)
+bool module_load_one(const char *prefix, const char *lib_name)
{
+ bool success = false;
+
#ifdef CONFIG_MODULES
char *fname = NULL;
char *exec_dir;
@@ -170,7 +172,7 @@ void module_load_one(const char *prefix, const char *lib_name)
if (!g_module_supported()) {
fprintf(stderr, "Module is not supported by system.\n");
- return;
+ return false;
}
if (!loaded_modules) {
@@ -181,7 +183,7 @@ void module_load_one(const char *prefix, const char *lib_name)
if (!g_hash_table_add(loaded_modules, module_name)) {
g_free(module_name);
- return;
+ return true;
}
exec_dir = qemu_get_exec_dir();
@@ -205,13 +207,19 @@ void module_load_one(const char *prefix, const char *lib_name)
fname = NULL;
/* Try loading until loaded a module file */
if (!ret) {
+ success = true;
break;
}
}
+ if (!success) {
+ g_hash_table_remove(loaded_modules, module_name);
+ }
+
for (i = 0; i < n_dirs; i++) {
g_free(dirs[i]);
}
#endif
+ return success;
}