From: "Andreas Färber" <afaerber@suse.de>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, stefanha@redhat.com,
Riku Voipio <riku.voipio@iki.fi>,
mjt@tls.msk.ru, Alexander Graf <agraf@suse.de>,
alex@alex.org.uk, pbonzini@redhat.com, mrezanin@redhat.com,
vilanova@ac.upc.edu, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v19 11/11] module: Pass argv[0] along the module load path
Date: Sat, 08 Feb 2014 18:16:28 +0100 [thread overview]
Message-ID: <52F6666C.6060205@suse.de> (raw)
In-Reply-To: <20140208044003.lMguK8Jj4y2xRi1u%famz@redhat.com>
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.
>
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
[...]
> 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 <= 1)
> usage();
>
> - module_call_init(MODULE_INIT_QOM);
> + module_call_init(MODULE_INIT_QOM, argv[0]);
>
> if ((envlist = envlist_create()) == 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;
>
> - module_call_init(MODULE_INIT_QOM);
> + module_call_init(MODULE_INIT_QOM, argv0);
>
> 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 <aliguori@us.ibm.com>
> + * Fam Zheng <famz@redhat.com>
> *
> * This work is licensed under the terms of the GNU GPL, version 2. See
> * the COPYING file in the top-level directory.
> @@ -89,14 +90,14 @@ void register_dso_module_init(void (*fn)(void), module_init_type type)
> QTAILQ_INSERT_TAIL(&dso_init_list, e, node);
> }
>
> -static void module_load(module_init_type type);
> +static void module_load(module_init_type type, const char *argv);
>
> -void module_call_init(module_init_type type)
> +void module_call_init(module_init_type type, const char *argv)
> {
> ModuleTypeList *l;
> ModuleEntry *e;
>
> - module_load(type);
> + module_load(type, argv);
> l = find_type(type);
>
> QTAILQ_FOREACH(e, l, node) {
> @@ -161,7 +162,7 @@ out:
> }
> #endif
>
> -void module_load(module_init_type type)
> +void module_load(module_init_type type, const char *argv)
> {
> #ifdef CONFIG_MODULES
> char *fname = NULL;
> @@ -188,7 +189,7 @@ void module_load(module_init_type type)
> return;
> }
>
> - exec_dir = qemu_exec_dir(NULL);
> + exec_dir = qemu_exec_dir(argv);
> 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 ? : "");
[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
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2014-02-08 17:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-08 4:40 [Qemu-devel] [PATCH v19 11/11] module: Pass argv[0] along the module load path Fam Zheng
2014-02-08 14:12 ` Paolo Bonzini
2014-02-08 15:16 ` Fam Zheng
2014-02-08 17:16 ` Andreas Färber [this message]
2014-02-08 17:24 ` Alexander Graf
2014-02-08 17:46 ` Peter Maydell
2014-02-08 23:36 ` Paolo Bonzini
2014-02-09 0:18 ` Peter Maydell
2014-02-09 6:46 ` Paolo Bonzini
2014-02-09 9:16 ` Fam Zheng
2014-02-09 11:48 ` Peter Maydell
2014-02-09 12:13 ` Fam Zheng
2014-02-09 9:26 ` Fam Zheng
2014-02-09 10:00 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52F6666C.6060205@suse.de \
--to=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=alex@alex.org.uk \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=mrezanin@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
--cc=stefanha@redhat.com \
--cc=vilanova@ac.upc.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).