diff options
| author | Kevin Wolf <kwolf@redhat.com> | 2016-10-07 14:17:11 +0200 |
|---|---|---|
| committer | Kevin Wolf <kwolf@redhat.com> | 2016-10-07 14:17:11 +0200 |
| commit | 9c7f3fcae714925153c4c5ada086ca4fcf6bbbd8 (patch) | |
| tree | efe15b0952ffe7eeec72c103479ca77d6a422837 /util/module.c | |
| parent | 2d76e724cf9e3f9fec6070a8af79c7ee4c2e763e (diff) | |
| parent | 27685a8dd08c051fa6d641fe46106fc0dfa51073 (diff) | |
| download | focaccia-qemu-9c7f3fcae714925153c4c5ada086ca4fcf6bbbd8.tar.gz focaccia-qemu-9c7f3fcae714925153c4c5ada086ca4fcf6bbbd8.zip | |
Merge remote-tracking branch 'mreitz/tags/pull-block-2016-10-07' into queue-block
Block patches for the block queue. # gpg: Signature made Fri Oct 7 14:14:45 2016 CEST # gpg: using RSA key 0xF407DB0061D5CF40 # gpg: Good signature from "Max Reitz <mreitz@redhat.com>" # Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40 * mreitz/tags/pull-block-2016-10-07: dmg: Move libbz2 code to dmg-bz2.so module: Don't load the same module if requested multiple times scripts: Allow block module to not define BlockDriver Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'util/module.c')
| -rw-r--r-- | util/module.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/util/module.c b/util/module.c index a5f7fbd941..c90973721f 100644 --- a/util/module.c +++ b/util/module.c @@ -163,14 +163,28 @@ void module_load_one(const char *prefix, const char *lib_name) char *fname = NULL; char *exec_dir; char *dirs[3]; + char *module_name; int i = 0; int ret; + static GHashTable *loaded_modules; if (!g_module_supported()) { fprintf(stderr, "Module is not supported by system.\n"); return; } + if (!loaded_modules) { + loaded_modules = g_hash_table_new(g_str_hash, g_str_equal); + } + + module_name = g_strdup_printf("%s%s", prefix, lib_name); + + if (g_hash_table_lookup(loaded_modules, module_name)) { + g_free(module_name); + return; + } + g_hash_table_insert(loaded_modules, module_name, module_name); + exec_dir = qemu_get_exec_dir(); dirs[i++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR); dirs[i++] = g_strdup_printf("%s/..", exec_dir ? : ""); @@ -180,8 +194,8 @@ void module_load_one(const char *prefix, const char *lib_name) exec_dir = NULL; for (i = 0; i < ARRAY_SIZE(dirs); i++) { - fname = g_strdup_printf("%s/%s%s%s", - dirs[i], prefix, lib_name, HOST_DSOSUF); + fname = g_strdup_printf("%s/%s%s", + dirs[i], module_name, HOST_DSOSUF); ret = module_load_file(fname); g_free(fname); fname = NULL; |