qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: qemu-devel@nongnu.org
Cc: Warner Losh <imp@bsdimp.com>,
	richard.henderson@linaro.org, alex.bennee@linaro.org,
	Kyle Evans <kevans@freebsd.org>
Subject: Re: [PATCH] bsd-user: add option to enable plugins
Date: Mon, 31 Mar 2025 16:50:00 -0700	[thread overview]
Message-ID: <eda8b528-78c1-4664-9d12-f3a74e190947@linaro.org> (raw)
In-Reply-To: <20250331234228.3475706-1-pierrick.bouvier@linaro.org>

On 3/31/25 16:42, Pierrick Bouvier wrote:
> Nothing prevent plugins to be enabled on this platform for user
> binaries, only the option in the driver is missing.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   bsd-user/main.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index fdb160bed0f..329bd1acc02 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -175,6 +175,9 @@ static void usage(void)
>              "-strace           log system calls\n"
>              "-trace            [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
>              "                  specify tracing options\n"
> +#ifdef CONFIG_PLUGIN
> +           "-plugin           [file=]<file>[,<argname>=<argvalue>]\n"
> +#endif
>              "\n"
>              "Environment variables:\n"
>              "QEMU_STRACE       Print system calls and arguments similar to the\n"
> @@ -225,6 +228,8 @@ static void init_task_state(TaskState *ts)
>       };
>   }
>   
> +static QemuPluginList plugins = QTAILQ_HEAD_INITIALIZER(plugins);
> +
>   void gemu_log(const char *fmt, ...)
>   {
>       va_list ap;
> @@ -307,6 +312,7 @@ int main(int argc, char **argv)
>       cpu_model = NULL;
>   
>       qemu_add_opts(&qemu_trace_opts);
> +    qemu_plugin_add_opts();
>   
>       optind = 1;
>       for (;;) {
> @@ -399,6 +405,11 @@ int main(int argc, char **argv)
>               do_strace = 1;
>           } else if (!strcmp(r, "trace")) {
>               trace_opt_parse(optarg);
> +#ifdef CONFIG_PLUGIN
> +        } else if (!strcmp(r, "plugin")) {
> +            r = argv[optind++];
> +            qemu_plugin_opt_parse(r, &plugins);
> +#endif
>           } else if (!strcmp(r, "0")) {
>               argv0 = argv[optind++];
>           } else {
> @@ -433,6 +444,7 @@ int main(int argc, char **argv)
>           exit(1);
>       }
>       trace_init_file();
> +    qemu_plugin_load_list(&plugins, &error_fatal);
>   
>       /* Zero out regs */
>       memset(regs, 0, sizeof(struct target_pt_regs));

For BSD folks,

if you're not familiar with plugins, you can try this command:
$ ./configure && ninja -C build
# plugins are built by default
$ ./build/qemu-x86_64 \
  -plugin ./build/contrib/plugins/libstoptrigger,icount=1000000 \
  -plugin ./build/tests/tcg/plugins/libinsn \
  -d plugin \
  ./build/qemu-system-x86_64 --version

Output should be something similar to:
icount reached at 0x7f2933a6a3f8, exiting
cpu 0 insns: 1000001
total insns: 1000001

It stopped after executing 1000001 instructions (libstoptrigger), and 
report how many instructions (libinsn) were executed.

Regards,
Pierrick


  reply	other threads:[~2025-03-31 23:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 23:42 [PATCH] bsd-user: add option to enable plugins Pierrick Bouvier
2025-03-31 23:50 ` Pierrick Bouvier [this message]
2025-04-01  6:15 ` Philippe Mathieu-Daudé
2025-04-01 14:33   ` Pierrick Bouvier
2025-04-01 14:44     ` Philippe Mathieu-Daudé
2025-04-01 14:59       ` Pierrick Bouvier
2025-04-01 18:50         ` Philippe Mathieu-Daudé
2025-04-28 19:36 ` Pierrick Bouvier
2025-04-28 22:57   ` Kyle Evans
2025-04-28 23:03     ` Pierrick Bouvier
2025-05-05 18:38     ` Pierrick Bouvier
2025-05-06  0:25       ` Warner Losh
2025-05-06  8:24         ` Philippe Mathieu-Daudé
2025-05-08 12:18 ` Philippe Mathieu-Daudé

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=eda8b528-78c1-4664-9d12-f3a74e190947@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=imp@bsdimp.com \
    --cc=kevans@freebsd.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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).