[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 49/74] module: Use QEMU_MODULE_DIR as a search path
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 49/74] module: Use QEMU_MODULE_DIR as a search path |
Date: |
Tue, 21 Aug 2018 19:02:21 +0200 |
From: ryang <address@hidden>
The current paths for modules are CONFIG_QEMU_MODDIR and paths relative
to the executable. Qemu and its modules can be installed and executed in
paths that are different from these search paths. This change allows
a search path to be specified by environment variable.
An example usage for this is postmarketOS[1]. This is a build environment
for Alpine Linux. It sets up Alpine Linux in a chroot environment.
Alpine's Qemu packages are installed in the chroot. The Alpine Linux Qemu
package is used to test compiled Alpine Linux system images. This way there
isn't a reliance on the which ever version of Qemu the host system / distro
provides.
postmarketOS executes Qemu on host system outside of the chroot
The Qemu module search path needs to point to the location of the
chroot relative to the host system.
e.g.
The root of the Alpine Linux chroot is:
~/.local/var/pmbootstrap/chroot_native/
Alpine's Qemu is installed at
~/.local/var/pmbootstrap/chroot_native/usr/bin/
The Qemu module search path needs to be:
QEMU_MODULE_DIR=~/.local/var/pmbootstrap/chroot_native/usr/lib/qemu/
[1] https://postmarketos.org/
Signed-off-by: ryang <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/module.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/util/module.c b/util/module.c
index c909737..1259dd3 100644
--- a/util/module.c
+++ b/util/module.c
@@ -162,9 +162,10 @@ void module_load_one(const char *prefix, const char
*lib_name)
#ifdef CONFIG_MODULES
char *fname = NULL;
char *exec_dir;
- char *dirs[3];
+ const char *search_dir;
+ char *dirs[4];
char *module_name;
- int i = 0;
+ int i = 0, n_dirs = 0;
int ret;
static GHashTable *loaded_modules;
@@ -186,14 +187,19 @@ void module_load_one(const char *prefix, const char
*lib_name)
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 ? : "");
- dirs[i++] = g_strdup_printf("%s", exec_dir ? : "");
- assert(i == ARRAY_SIZE(dirs));
+ search_dir = getenv("QEMU_MODULE_DIR");
+ if (search_dir != NULL) {
+ dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
+ }
+ dirs[n_dirs++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR);
+ dirs[n_dirs++] = g_strdup_printf("%s/..", exec_dir ? : "");
+ dirs[n_dirs++] = g_strdup_printf("%s", exec_dir ? : "");
+ assert(n_dirs <= ARRAY_SIZE(dirs));
+
g_free(exec_dir);
exec_dir = NULL;
- for (i = 0; i < ARRAY_SIZE(dirs); i++) {
+ for (i = 0; i < n_dirs; i++) {
fname = g_strdup_printf("%s/%s%s",
dirs[i], module_name, HOST_DSOSUF);
ret = module_load_file(fname);
@@ -205,7 +211,7 @@ void module_load_one(const char *prefix, const char
*lib_name)
}
}
- for (i = 0; i < ARRAY_SIZE(dirs); i++) {
+ for (i = 0; i < n_dirs; i++) {
g_free(dirs[i]);
}
--
1.8.3.1
- [Qemu-devel] [PULL 21/74] qsp: support call site coalescing, (continued)
- [Qemu-devel] [PULL 21/74] qsp: support call site coalescing, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 32/74] kvm: add call to qemu_add_opts() for -overcommit option, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 25/74] hmp-commands: add sync-profile, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 47/74] hw/intc/apic: Switch away from old_mmio, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 28/74] update-linux-headers.sh: add qemu_fw_cfg.h, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 34/74] target-i386: Fix lcall/ljmp to call gate in IA-32e mode, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 37/74] rcu_queue: remove barrier from QLIST_EMPTY_RCU, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 17/74] seqlock: constify seqlock_read_begin, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 43/74] tests: add test-list-simpleq, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 44/74] tests: add test-rcu-tailq, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 49/74] module: Use QEMU_MODULE_DIR as a search path,
Paolo Bonzini <=
- [Qemu-devel] [PULL 51/74] seqlock: add QemuLockable support, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 41/74] test-rcu-list: access counters with atomics, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 39/74] rcu_queue: add RCU QTAILQ, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 46/74] qom: convert the CPU list to RCU, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 23/74] tests/atomic_add-bench: add -p to enable sync profiler, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 52/74] cpus: protect TimerState writes with a spinlock, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 38/74] rcu_queue: add RCU QSIMPLEQ, Paolo Bonzini, 2018/08/21
- [Qemu-devel] [PULL 45/74] spapr: do not use CPU_FOREACH_REVERSE, Paolo Bonzini, 2018/08/21