From nobody Tue Nov 4 15:25:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530593859743298.950415806362; Mon, 2 Jul 2018 21:57:39 -0700 (PDT) Received: from localhost ([::1]:37800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faDNZ-0001oP-D4 for importer@patchew.org; Tue, 03 Jul 2018 00:57:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa5N1-0005W2-Gi for qemu-devel@nongnu.org; Mon, 02 Jul 2018 16:24:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa5Mx-0000tN-Dv for qemu-devel@nongnu.org; Mon, 02 Jul 2018 16:24:23 -0400 Received: from mail-io0-x243.google.com ([2607:f8b0:4001:c06::243]:40449) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa5Mx-0000rf-8f for qemu-devel@nongnu.org; Mon, 02 Jul 2018 16:24:19 -0400 Received: by mail-io0-x243.google.com with SMTP id t135-v6so15844938iof.7 for ; Mon, 02 Jul 2018 13:24:19 -0700 (PDT) Received: from computer (CPE1cabc0918a93-CM1cabc0918a90.cpe.net.cable.rogers.com. [99.229.26.117]) by smtp.gmail.com with ESMTPSA id b125-v6sm3558827itc.37.2018.07.02.13.24.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 13:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=i/nnznIZtYhmYjh0eXsIXi+VDCu8KXAnIdp3UynGYiM=; b=dUGF1psaMOQvMZUqZ3fMXMl70LXBeY91aDbp50cV6d6TxLSp3z6fD2SHMPV7OPAB5/ 5yoU24V3o5sTxWRlihfJY5KKoxfNOUncMYbMPdbJ0zRloWt524lZyYSbdXtMEvS98wZ1 ss0XDzkKvg8p37/+B3LhJvFJYtpfvODtw2tWMRvhwdXA98tTiPQE6FzkP8mM4skw56/b pymAUOZ3eneRNzzTxjzvLJ4eyB1gwqnKdQPzZv2kaj2w7nZ1/tLNXO/M7eFZ++WxpO1C gVaLUgyKSo+dcDfTeuJp3FyIqqu98eanK/hFVy18tVB/Iz+CX3QhaDjwZNLO0zP1goR9 1b/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=i/nnznIZtYhmYjh0eXsIXi+VDCu8KXAnIdp3UynGYiM=; b=VmYP0rUVwmCtMJk4MqtwDvnCT3reso5KeVeP6Z+ihNpbwGq0Asd9TKKajvotbzLeQq 04oYJnMyuehzrDMxVV6C1kq5lMYSTrPOpQNKGY0epTCx0Fmg6cqG4WDprxpDJ30AdW47 hWL1jdm9RkSfzVXPaM7sXWQwkgL/NeCMPrvairac4TEXXf1rwK0cN+LPT3I5kIItJSgo FJFQCnn31z50z4d4Y5XE96pjoPrbEg3DqwbkHAF372EfsCT2cJWNIMWqO4kXonAs2j6w EkxnJiqIBp87KAIxCzs6WHGkVOz83in59f5oZ8pJcsHdTkeGezHLn/oxSgpp/a1Asv8a K5Gg== X-Gm-Message-State: APt69E1OS2UajhIld9EJiLzg9riXONFS01r4AjgCFRtQGDN/HwD+eSE2 fggF7JZhmAtS0Hlc7rzIsPkC+Gc= X-Google-Smtp-Source: AAOMgpf7OY2KGoJcBrg3U82+xpgZu2pCna/H08eYdVpMV8q++FixxqQ0hrqe+C11aB9Zqo9QZfkdrw== X-Received: by 2002:a6b:d30e:: with SMTP id s14-v6mr21269307iob.213.1530563058288; Mon, 02 Jul 2018 13:24:18 -0700 (PDT) Date: Mon, 2 Jul 2018 16:24:15 -0400 From: ryang To: qemu-devel@nongnu.org Message-ID: <20180702202415.GA12440@computer> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::243 X-Mailman-Approved-At: Tue, 03 Jul 2018 00:56:33 -0400 Subject: [Qemu-devel] [PATCH] module: Use QEMU_MODULE_PATH as a search path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Fam Zheng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_PATH=3D~/.local/var/pmbootstrap/chroot_native/usr/lib/qemu/ [1] https://postmarketos.org/ Signed-off-by: ryang --- Apologies if this is not sent to the correct maintainers. I couldn't find anyone listed for this specific file in MAINTAINERS or by using get_maintainer.pl. I'm sending this to the orignal author and maintainers involved with the patch that added module loading. util/module.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/util/module.c b/util/module.c index c909737..f9088a5 100644 --- a/util/module.c +++ b/util/module.c @@ -162,9 +162,10 @@ void module_load_one(const char *prefix, const char *l= ib_name) #ifdef CONFIG_MODULES char *fname =3D NULL; char *exec_dir; - char *dirs[3]; + char *search_path; + char *dirs[4]; char *module_name; - int i =3D 0; + int i =3D 0, n_dirs; int ret; static GHashTable *loaded_modules; =20 @@ -186,14 +187,18 @@ void module_load_one(const char *prefix, const char *= lib_name) g_hash_table_insert(loaded_modules, module_name, module_name); =20 exec_dir =3D qemu_get_exec_dir(); - dirs[i++] =3D g_strdup_printf("%s", CONFIG_QEMU_MODDIR); - dirs[i++] =3D g_strdup_printf("%s/..", exec_dir ? : ""); - dirs[i++] =3D g_strdup_printf("%s", exec_dir ? : ""); - assert(i =3D=3D ARRAY_SIZE(dirs)); + search_path =3D getenv("QEMU_MODULE_PATH"); + if (search_path !=3D NULL) + dirs[n_dirs++] =3D g_strdup_printf("%s", search_path); + dirs[n_dirs++] =3D g_strdup_printf("%s", CONFIG_QEMU_MODDIR); + dirs[n_dirs++] =3D g_strdup_printf("%s/..", exec_dir ? : ""); + dirs[n_dirs++] =3D g_strdup_printf("%s", exec_dir ? : ""); + assert(n_dirs <=3D ARRAY_SIZE(dirs)); + g_free(exec_dir); exec_dir =3D NULL; =20 - for (i =3D 0; i < ARRAY_SIZE(dirs); i++) { + for (i =3D 0; i < n_dirs; i++) { fname =3D g_strdup_printf("%s/%s%s", dirs[i], module_name, HOST_DSOSUF); ret =3D module_load_file(fname); @@ -205,7 +210,7 @@ void module_load_one(const char *prefix, const char *li= b_name) } } =20 - for (i =3D 0; i < ARRAY_SIZE(dirs); i++) { + for (i =3D 0; i < n_dirs; i++) { g_free(dirs[i]); } =20 --=20 2.7.4