From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCBWE-0003ze-T3 for qemu-devel@nongnu.org; Sat, 08 Feb 2014 12:16:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCBW7-0007xw-GD for qemu-devel@nongnu.org; Sat, 08 Feb 2014 12:16:42 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45759 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCBW7-0007xZ-6t for qemu-devel@nongnu.org; Sat, 08 Feb 2014 12:16:35 -0500 Message-ID: <52F6666C.6060205@suse.de> Date: Sat, 08 Feb 2014 18:16:28 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <20140208044003.lMguK8Jj4y2xRi1u%famz@redhat.com> In-Reply-To: <20140208044003.lMguK8Jj4y2xRi1u%famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v19 11/11] module: Pass argv[0] along the module load path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, stefanha@redhat.com, Riku Voipio , mjt@tls.msk.ru, Alexander Graf , alex@alex.org.uk, pbonzini@redhat.com, mrezanin@redhat.com, vilanova@ac.upc.edu, rth@twiddle.net Am 08.02.2014 05:40, schrieb Fam Zheng: > This adds parameter "argv0" in calling path from main() to > module_call_init(). So that module loader knows the location of > executable. >=20 > Suggested-by: Paolo Bonzini > Signed-off-by: Fam Zheng [...] > diff --git a/bsd-user/main.c b/bsd-user/main.c > index f9246aa..2802d0c 100644 > --- a/bsd-user/main.c > +++ b/bsd-user/main.c > @@ -749,7 +749,7 @@ int main(int argc, char **argv) > if (argc <=3D 1) > usage(); > =20 > - module_call_init(MODULE_INIT_QOM); > + module_call_init(MODULE_INIT_QOM, argv[0]); > =20 > if ((envlist =3D envlist_create()) =3D=3D NULL) { > (void) fprintf(stderr, "Unable to allocate envlist\n"); [...] > diff --git a/linux-user/main.c b/linux-user/main.c > index cabc9e1..b01c0a9 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -3805,7 +3805,7 @@ int main(int argc, char **argv, char **envp) > int ret; > int execfd; > =20 > - module_call_init(MODULE_INIT_QOM); > + module_call_init(MODULE_INIT_QOM, argv0); > =20 > qemu_init_auxval(envp); > qemu_cache_utils_init(); Are you sure these two are going to do the expected thing? At least with Alex' binfmt wrapper, argv[0] will be the path of the emulated binary (e.g., /bin/ls) rather than QEMU's IIUC. CC'ing Alex and Riku. My hope would be that it doesn't matter for *-user in that core QOM classes being initialized here remain in the main executable, but there's no code comment or statement in the commit message indicating this corner case has actually been thought of in this otherwise trivial refactoring. [...] > diff --git a/util/module.c b/util/module.c > index c36b60a..e5bc30e 100644 > --- a/util/module.c > +++ b/util/module.c > @@ -5,6 +5,7 @@ > * > * Authors: > * Anthony Liguori > + * Fam Zheng > * > * This work is licensed under the terms of the GNU GPL, version 2. S= ee > * the COPYING file in the top-level directory. > @@ -89,14 +90,14 @@ void register_dso_module_init(void (*fn)(void), mod= ule_init_type type) > QTAILQ_INSERT_TAIL(&dso_init_list, e, node); > } > =20 > -static void module_load(module_init_type type); > +static void module_load(module_init_type type, const char *argv); > =20 > -void module_call_init(module_init_type type) > +void module_call_init(module_init_type type, const char *argv) > { > ModuleTypeList *l; > ModuleEntry *e; > =20 > - module_load(type); > + module_load(type, argv); > l =3D find_type(type); > =20 > QTAILQ_FOREACH(e, l, node) { > @@ -161,7 +162,7 @@ out: > } > #endif > =20 > -void module_load(module_init_type type) > +void module_load(module_init_type type, const char *argv) > { > #ifdef CONFIG_MODULES > char *fname =3D NULL; > @@ -188,7 +189,7 @@ void module_load(module_init_type type) > return; > } > =20 > - exec_dir =3D qemu_exec_dir(NULL); > + exec_dir =3D qemu_exec_dir(argv); > 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 ? : ""); [snip] Suggest to consistently name them argv0 (like in the header) since passing argv without [] to functions looks kind of odd. I assume the v stands for vector, which a single argument isn't really (ignoring the character vector). Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg