From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, stefanha@redhat.com,
mjt@tls.msk.ru, alex@alex.org.uk, 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 15:12:54 +0100 [thread overview]
Message-ID: <52F63B66.9090205@redhat.com> (raw)
In-Reply-To: <20140208044003.lMguK8Jj4y2xRi1u%famz@redhat.com>
Il 08/02/2014 05:40, Fam Zheng ha scritto:
> 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>
Really? :)
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> block.c | 8 ++++----
> bsd-user/main.c | 2 +-
> include/block/block.h | 4 ++--
> include/qemu/module.h | 2 +-
> linux-user/main.c | 2 +-
> qemu-img.c | 2 +-
> qemu-io.c | 2 +-
> qemu-nbd.c | 2 +-
> qga/main.c | 2 +-
> tests/check-qom-interface.c | 2 +-
> tests/test-qdev-global-props.c | 2 +-
> tests/test-qmp-commands.c | 2 +-
> util/module.c | 11 ++++++-----
> vl.c | 6 +++---
> 14 files changed, 25 insertions(+), 24 deletions(-)
>
> diff --git a/block.c b/block.c
> index cb21a5f..f819f6e 100644
> --- a/block.c
> +++ b/block.c
> @@ -4586,15 +4586,15 @@ BlockDriverAIOCB *bdrv_aio_discard(BlockDriverState *bs,
> return &acb->common;
> }
>
> -void bdrv_init(void)
> +void bdrv_init(const char *argv0)
> {
> - module_call_init(MODULE_INIT_BLOCK);
> + module_call_init(MODULE_INIT_BLOCK, argv0);
> }
>
> -void bdrv_init_with_whitelist(void)
> +void bdrv_init_with_whitelist(const char *argv0)
> {
> use_bdrv_whitelist = 1;
> - bdrv_init();
> + bdrv_init(argv0);
> }
>
> void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
> 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/include/block/block.h b/include/block/block.h
> index 963a61f..7305232 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -166,8 +166,8 @@ void bdrv_info_stats(Monitor *mon, QObject **ret_data);
> void bdrv_io_limits_enable(BlockDriverState *bs);
> void bdrv_io_limits_disable(BlockDriverState *bs);
>
> -void bdrv_init(void);
> -void bdrv_init_with_whitelist(void);
> +void bdrv_init(const char *argv0);
> +void bdrv_init_with_whitelist(const char *argv0);
> BlockDriver *bdrv_find_protocol(const char *filename,
> bool allow_protocol_prefix);
> BlockDriver *bdrv_find_format(const char *format_name);
> diff --git a/include/qemu/module.h b/include/qemu/module.h
> index 0fcac4f..110fc51 100644
> --- a/include/qemu/module.h
> +++ b/include/qemu/module.h
> @@ -67,6 +67,6 @@ typedef enum {
> void register_module_init(void (*fn)(void), module_init_type type);
> void register_dso_module_init(void (*fn)(void), module_init_type type);
>
> -void module_call_init(module_init_type type);
> +void module_call_init(module_init_type type, const char *argv0);
>
> #endif
> 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();
> diff --git a/qemu-img.c b/qemu-img.c
> index c989850..9a169e3 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -2721,7 +2721,7 @@ int main(int argc, char **argv)
> error_set_progname(argv[0]);
>
> qemu_init_main_loop();
> - bdrv_init();
> + bdrv_init(argv[0]);
> if (argc < 2)
> help();
> cmdname = argv[1];
> diff --git a/qemu-io.c b/qemu-io.c
> index 7f459d8..736329d 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -440,7 +440,7 @@ int main(int argc, char **argv)
> }
>
> qemu_init_main_loop();
> - bdrv_init();
> + bdrv_init(argv[0]);
>
> /* initialize commands */
> qemuio_add_command(&quit_cmd);
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 136e8c9..edebfec 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -583,7 +583,7 @@ int main(int argc, char **argv)
> }
>
> qemu_init_main_loop();
> - bdrv_init();
> + bdrv_init(argv[0]);
> atexit(bdrv_close_all);
>
> if (fmt) {
> diff --git a/qga/main.c b/qga/main.c
> index c58b26a..b448f5a 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -949,7 +949,7 @@ int main(int argc, char **argv)
> GList *blacklist = NULL;
> GAState *s;
>
> - module_call_init(MODULE_INIT_QAPI);
> + module_call_init(MODULE_INIT_QAPI, argv[0]);
>
> init_dfl_pathnames();
> pid_filepath = dfl_pathnames.pidfile;
> diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
> index f06380e..2e1480b 100644
> --- a/tests/check-qom-interface.c
> +++ b/tests/check-qom-interface.c
> @@ -92,7 +92,7 @@ int main(int argc, char **argv)
> {
> g_test_init(&argc, &argv, NULL);
>
> - module_call_init(MODULE_INIT_QOM);
> + module_call_init(MODULE_INIT_QOM, argv0);
> type_register_static(&test_if_info);
> type_register_static(&direct_impl_info);
> type_register_static(&intermediate_impl_info);
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index e4ad173..242f1a8 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -166,7 +166,7 @@ int main(int argc, char **argv)
> {
> g_test_init(&argc, &argv, NULL);
>
> - module_call_init(MODULE_INIT_QOM);
> + module_call_init(MODULE_INIT_QOM, argv0);
> type_register_static(&static_prop_type);
> type_register_static(&dynamic_prop_type);
>
> diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
> index 5a3e82a..f46c2aa 100644
> --- a/tests/test-qmp-commands.c
> +++ b/tests/test-qmp-commands.c
> @@ -175,7 +175,7 @@ int main(int argc, char **argv)
> g_test_add_func("/0.15/dealloc_types", test_dealloc_types);
> g_test_add_func("/0.15/dealloc_partial", test_dealloc_partial);
>
> - module_call_init(MODULE_INIT_QAPI);
> + module_call_init(MODULE_INIT_QAPI, argv0);
> g_test_run();
>
> return 0;
> 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 ? : "");
> diff --git a/vl.c b/vl.c
> index 383be1b..a07904c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2891,7 +2891,7 @@ int main(int argc, char **argv, char **envp)
> #endif
> }
>
> - module_call_init(MODULE_INIT_QOM);
> + module_call_init(MODULE_INIT_QOM, argv[0]);
>
> qemu_add_opts(&qemu_drive_opts);
> qemu_add_drive_opts(&qemu_legacy_drive_opts);
> @@ -2927,7 +2927,7 @@ int main(int argc, char **argv, char **envp)
> QLIST_INIT (&vm_change_state_head);
> os_setup_early_signal_handling();
>
> - module_call_init(MODULE_INIT_MACHINE);
> + module_call_init(MODULE_INIT_MACHINE, argv[0]);
> machine = find_default_machine();
> cpu_model = NULL;
> ram_size = 0;
> @@ -2943,7 +2943,7 @@ int main(int argc, char **argv, char **envp)
> nb_numa_nodes = 0;
> nb_nics = 0;
>
> - bdrv_init_with_whitelist();
> + bdrv_init_with_whitelist(argv[0]);
>
> autostart = 1;
>
>
next prev parent reply other threads:[~2014-02-08 14:13 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 [this message]
2014-02-08 15:16 ` Fam Zheng
2014-02-08 17:16 ` Andreas Färber
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=52F63B66.9090205@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex@alex.org.uk \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=mrezanin@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--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).