module: Use QEMU_MODULE_DIR as a search path
commit900610e631c0371070aad4d9482fd42915166948
authorryang <decatf@gmail.com>
Wed, 4 Jul 2018 18:10:10 +0000 (4 14:10 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Aug 2018 16:46:25 +0000 (23 18:46 +0200)
tree151bdd2763c575d4d2757a2fbe52e2a0d0050242
parent7294e600eb814fd2ca17738969413d3a5b7d1c02
module: Use QEMU_MODULE_DIR as a search path

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 <decatf@gmail.com>
Message-Id: <20180704181010.GA918@computer>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/module.c