[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/13] module: return success on module load
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 04/13] module: return success on module load |
Date: |
Wed, 21 Aug 2019 19:28:12 +0200 |
From: Marc-André Lureau <address@hidden>
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 <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/module.h | 2 +-
util/module.c | 14 +++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/include/qemu/module.h b/include/qemu/module.h
index db30653..65ba596 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -65,6 +65,6 @@ void register_module_init(void (*fn)(void), module_init_type
type);
void register_dso_module_init(void (*fn)(void), module_init_type type);
void module_call_init(module_init_type type);
-void module_load_one(const char *prefix, const char *lib_name);
+bool module_load_one(const char *prefix, const char *lib_name);
#endif
diff --git a/util/module.c b/util/module.c
index ca9885c..e9fe3e5 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;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/13] Misc patches for 2019-08-21, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 01/13] qemu-ga: clean up TOOLS variable, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 02/13] configure: define CONFIG_TOOLS here, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 03/13] module: use g_hash_table_add(), Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 04/13] module: return success on module load,
Paolo Bonzini <=
- [Qemu-devel] [PULL 05/13] tests: add module loading test, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 06/13] configure: remove AUTOCONF_HOST, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 07/13] minikconf: don't print CONFIG_FOO=n lines, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 08/13] memory: Refactor memory_region_clear_coalescing, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 09/13] memory: Split zones when do coalesced_io_del(), Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 10/13] memory: Remove has_coalesced_range counter, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 11/13] memory: Fix up memory_region_{add|del}_coalescing, Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 12/13] main-loop: Fix GSource leak in qio_task_thread_worker(), Paolo Bonzini, 2019/08/21
- [Qemu-devel] [PULL 13/13] char-socket: Lock tcp_chr_disconnect() and socket_reconnect_timeout(), Paolo Bonzini, 2019/08/21
- Re: [Qemu-devel] [PULL 00/13] Misc patches for 2019-08-21, Peter Maydell, 2019/08/22