From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: aaron@os.amperecomputing.com, cota@braap.org,
"Alex Bennée" <alex.bennee@linaro.org>,
robert.foley@futurewei.com, peter.puhov@futurewei.com
Subject: [PATCH v5 51/55] plugins: expand the plugin_init function to include an info block
Date: Mon, 14 Oct 2019 11:49:44 +0100 [thread overview]
Message-ID: <20191014104948.4291-52-alex.bennee@linaro.org> (raw)
In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org>
This provides a limited amount of info to plugins about the guest
system that will allow them to make some additional decisions on
setup.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
include/qemu/qemu-plugin.h | 26 ++++++++++++++++++++++++--
plugins/loader.c | 22 ++++++++++++++++++----
tests/plugin/bb.c | 5 +++--
tests/plugin/empty.c | 5 +++--
tests/plugin/hotblocks.c | 5 +++--
tests/plugin/hotpages.c | 5 +++--
tests/plugin/howvec.c | 5 +++--
tests/plugin/insn.c | 5 +++--
tests/plugin/mem.c | 5 +++--
9 files changed, 63 insertions(+), 20 deletions(-)
diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index 8b403dd615..719d7054a1 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -38,9 +38,27 @@
typedef uint64_t qemu_plugin_id_t;
+typedef struct {
+ /* string describing architecture */
+ const char *target_name;
+ /* is this a full system emulation? */
+ bool system_emulation;
+ union {
+ /*
+ * smp_vcpus may change if vCPUs can be hot-plugged, max_vcpus
+ * is the system-wide limit.
+ */
+ struct {
+ int smp_vcpus;
+ int max_vcpus;
+ } system;
+ };
+} qemu_info_t;
+
/**
* qemu_plugin_install() - Install a plugin
* @id: this plugin's opaque ID
+ * @info: a block describing some details about the guest
* @argc: number of arguments
* @argv: array of arguments (@argc elements)
*
@@ -49,10 +67,14 @@ typedef uint64_t qemu_plugin_id_t;
* Note: Calling qemu_plugin_uninstall() from this function is a bug. To raise
* an error during install, return !0.
*
+ * Note: @info is only live during the call. Copy any information we
+ * want to keep.
+ *
* Note: @argv remains valid throughout the lifetime of the loaded plugin.
*/
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv);
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv);
/*
* Prototypes for the various callback styles we will be registering
diff --git a/plugins/loader.c b/plugins/loader.c
index 5de5cff8e3..a136a71d35 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -29,6 +29,9 @@
#include "hw/core/cpu.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#ifndef CONFIG_USER_ONLY
+#include "hw/boards.h"
+#endif
#include "plugin.h"
@@ -60,7 +63,7 @@ QemuOptsList qemu_plugin_opts = {
},
};
-typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, int, char **);
+typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, const qemu_info_t *, int, char **);
extern struct qemu_plugin_state plugin;
@@ -147,7 +150,7 @@ static uint64_t xorshift64star(uint64_t x)
return x * UINT64_C(2685821657736338717);
}
-static int plugin_load(struct qemu_plugin_desc *desc)
+static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info)
{
qemu_plugin_install_func_t install;
struct qemu_plugin_ctx *ctx;
@@ -198,7 +201,7 @@ static int plugin_load(struct qemu_plugin_desc *desc)
}
QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry);
ctx->installing = true;
- rc = install(ctx->id, desc->argc, desc->argv);
+ rc = install(ctx->id, info, desc->argc, desc->argv);
ctx->installing = false;
if (rc) {
error_report("%s: qemu_plugin_install returned error code %d",
@@ -249,11 +252,22 @@ static void plugin_desc_free(struct qemu_plugin_desc *desc)
int qemu_plugin_load_list(QemuPluginList *head)
{
struct qemu_plugin_desc *desc, *next;
+ g_autofree qemu_info_t *info = g_new0(qemu_info_t, 1);
+
+ info->target_name = TARGET_NAME;
+#ifndef CONFIG_USER_ONLY
+ MachineState * ms = MACHINE(qdev_get_machine());
+ info->system_emulation = true;
+ info->system.smp_vcpus = ms->smp.cpus;
+ info->system.max_vcpus = ms->smp.max_cpus;
+#else
+ info->system_emulation = false;
+#endif
QTAILQ_FOREACH_SAFE(desc, head, entry, next) {
int err;
- err = plugin_load(desc);
+ err = plugin_load(desc, info);
if (err) {
return err;
}
diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
index 93d25de363..4a6d6ca0bc 100644
--- a/tests/plugin/bb.c
+++ b/tests/plugin/bb.c
@@ -48,8 +48,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
}
}
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv)
{
if (argc && strcmp(argv[0], "inline") == 0) {
do_inline = true;
diff --git a/tests/plugin/empty.c b/tests/plugin/empty.c
index b141ddd0df..3f60f69027 100644
--- a/tests/plugin/empty.c
+++ b/tests/plugin/empty.c
@@ -21,8 +21,9 @@
static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
{ }
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv)
{
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
return 0;
diff --git a/tests/plugin/hotblocks.c b/tests/plugin/hotblocks.c
index a150179a5c..57bea765b3 100644
--- a/tests/plugin/hotblocks.c
+++ b/tests/plugin/hotblocks.c
@@ -129,8 +129,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
}
}
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+ int argc, char **argv)
{
if (argc && strcmp(argv[0], "inline") == 0) {
do_inline = true;
diff --git a/tests/plugin/hotpages.c b/tests/plugin/hotpages.c
index 13ce8ffeb8..99bb4be07c 100644
--- a/tests/plugin/hotpages.c
+++ b/tests/plugin/hotpages.c
@@ -148,8 +148,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
}
}
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+ int argc, char **argv)
{
int i;
diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c
index b435c6b64d..3b1d177ef3 100644
--- a/tests/plugin/howvec.c
+++ b/tests/plugin/howvec.c
@@ -264,8 +264,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
}
}
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv)
{
int i;
diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c
index 3000ab4b73..9cfa7d0e53 100644
--- a/tests/plugin/insn.c
+++ b/tests/plugin/insn.c
@@ -45,8 +45,9 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
dprintf(stdout_fd, "insns: %" PRIu64 "\n", insn_count);
}
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv)
{
if (argc && !strcmp(argv[0], "inline")) {
do_inline = true;
diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c
index e5490f4a99..fdf4347c5e 100644
--- a/tests/plugin/mem.c
+++ b/tests/plugin/mem.c
@@ -64,8 +64,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
}
}
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv)
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv)
{
if (argc) {
if (argc >= 3) {
--
2.20.1
next prev parent reply other threads:[~2019-10-14 11:45 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 10:48 [PATCH for 4.2 v5 00/55] Support for TCG plugins Alex Bennée
2019-10-14 10:48 ` [PATCH v5 01/55] trace: expand mem_info:size_shift to 4 bits Alex Bennée
2019-10-14 14:35 ` Richard Henderson
2019-10-14 10:48 ` [PATCH v5 02/55] trace: add mmu_index to mem_info Alex Bennée
2019-10-14 14:53 ` Richard Henderson
2019-10-15 11:15 ` Alex Bennée
2019-10-14 10:48 ` [PATCH v5 03/55] cpu: introduce cpu_in_exclusive_context() Alex Bennée
2019-10-14 10:48 ` [PATCH v5 04/55] translate-all: use cpu_in_exclusive_work_context() in tb_flush Alex Bennée
2019-10-14 10:48 ` [PATCH v5 05/55] docs/devel: add plugins.rst design document Alex Bennée
2019-10-14 10:48 ` [PATCH v5 06/55] configure: add --enable-plugins (MOVE TO END) Alex Bennée
2019-10-14 10:49 ` [PATCH v5 07/55] plugin: add user-facing API Alex Bennée
2019-10-14 10:49 ` [PATCH v5 08/55] plugin: add core code Alex Bennée
2019-10-14 10:49 ` [PATCH v5 09/55] plugin: add implementation of the api Alex Bennée
2019-10-14 10:49 ` [PATCH v5 10/55] queue: add QTAILQ_REMOVE_SEVERAL Alex Bennée
2019-10-14 10:49 ` [PATCH v5 11/55] cputlb: document get_page_addr_code Alex Bennée
2019-10-14 10:49 ` [PATCH v5 12/55] cputlb: introduce get_page_addr_code_hostp Alex Bennée
2019-10-14 10:49 ` [PATCH v5 13/55] tcg: add tcg_gen_st_ptr Alex Bennée
2019-10-14 10:49 ` [PATCH v5 14/55] plugin-gen: add module for TCG-related code Alex Bennée
2019-10-14 15:23 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 15/55] atomic_template: add inline trace/plugin helpers Alex Bennée
2019-10-14 10:49 ` [PATCH v5 16/55] tcg: let plugins instrument virtual memory accesses Alex Bennée
2019-10-14 10:49 ` [PATCH v5 17/55] plugins: implement helpers for resolving hwaddr Alex Bennée
2019-10-14 15:45 ` Richard Henderson
2019-10-14 15:54 ` Peter Maydell
2019-10-14 16:34 ` Alex Bennée
2019-10-14 16:56 ` Peter Maydell
2019-10-14 10:49 ` [PATCH v5 18/55] translate-all: notify plugin code of tb_flush Alex Bennée
2019-10-14 10:49 ` [PATCH v5 19/55] *-user: notify plugin of exit Alex Bennée
2019-10-14 10:49 ` [PATCH v5 20/55] *-user: plugin syscalls Alex Bennée
2019-10-14 10:49 ` [PATCH v5 21/55] cpu: hook plugin vcpu events Alex Bennée
2019-10-14 10:49 ` [PATCH v5 22/55] plugin-gen: add plugin_insn_append Alex Bennée
2019-10-14 10:49 ` [PATCH v5 23/55] translator: add translator_ld{ub,sw,uw,l,q} Alex Bennée
2019-10-14 16:08 ` Richard Henderson
2019-10-14 17:31 ` Peter Maydell
2019-10-15 18:55 ` Alex Bennée
2019-10-15 21:34 ` Alex Bennée
2019-10-15 19:03 ` Alex Bennée
2019-10-14 10:49 ` [PATCH v5 24/55] target/arm: fetch code with translator_ld Alex Bennée
2019-10-14 10:49 ` [PATCH v5 25/55] target/ppc: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 26/55] target/sh4: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 27/55] target/i386: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 28/55] target/hppa: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 29/55] target/m68k: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 30/55] target/alpha: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 31/55] target/riscv: " Alex Bennée
2019-10-14 17:59 ` Alistair Francis
2019-10-18 18:32 ` Palmer Dabbelt
2019-10-14 10:49 ` [PATCH v5 32/55] target/sparc: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 33/55] target/xtensa: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 34/55] target/openrisc: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 35/55] translator: inject instrumentation from plugins Alex Bennée
2019-10-14 10:49 ` [PATCH v5 36/55] plugin: add API symbols to qemu-plugins.symbols Alex Bennée
2019-10-14 16:13 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 37/55] vl: support -plugin option Alex Bennée
2019-10-14 10:49 ` [PATCH v5 38/55] linux-user: " Alex Bennée
2019-10-14 10:49 ` [PATCH v5 39/55] tests/plugin: add sample plugins Alex Bennée
2019-10-14 16:14 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 40/55] tests/tcg/Makefile.target: fix path to config-host.mak Alex Bennée
2019-10-14 16:15 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 41/55] tests/tcg: set QEMU_OPTS for all cris runs Alex Bennée
2019-10-14 16:16 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 42/55] tests/tcg: move "virtual" tests to EXTRA_TESTS Alex Bennée
2019-10-14 16:16 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 43/55] tests/tcg: drop test-i386-fprem from TESTS when not SLOW Alex Bennée
2019-10-14 16:44 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 44/55] tests/tcg: enable plugin testing Alex Bennée
2019-10-14 16:46 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 45/55] tests/plugin: add a hotblocks plugin Alex Bennée
2019-10-14 16:49 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 46/55] plugin: add qemu_plugin_insn_disas helper Alex Bennée
2019-10-14 10:49 ` [PATCH v5 47/55] tests/plugin: add instruction execution breakdown Alex Bennée
2019-10-14 16:50 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 48/55] tests/plugin: add hotpages plugin to breakdown memory access patterns Alex Bennée
2019-10-14 16:51 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 49/55] accel/stubs: reduce headers from tcg-stub Alex Bennée
2019-10-14 10:49 ` [PATCH v5 50/55] include/exec: wrap cpu_ldst.h in CONFIG_TCG Alex Bennée
2019-10-14 10:49 ` Alex Bennée [this message]
2019-10-14 16:54 ` [PATCH v5 51/55] plugins: expand the plugin_init function to include an info block Richard Henderson
2019-10-14 10:49 ` [PATCH v5 52/55] plugins: make howvec plugin more generic Alex Bennée
2019-10-14 16:59 ` Richard Henderson
2019-10-14 17:14 ` Alex Bennée
2019-10-14 17:39 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 53/55] plugins: add sparc64 instruction classification table Alex Bennée
2019-10-14 17:01 ` Richard Henderson
2019-10-15 19:09 ` Alex Bennée
2019-10-15 19:37 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 54/55] plugins: add qemu_plugin_outs and use it Alex Bennée
2019-10-14 17:03 ` Richard Henderson
2019-10-14 10:49 ` [PATCH v5 55/55] .travis.yml: add --enable-plugins tests Alex Bennée
2019-10-14 17:04 ` Richard Henderson
2019-10-15 4:36 ` [PATCH for 4.2 v5 00/55] Support for TCG plugins no-reply
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=20191014104948.4291-52-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aaron@os.amperecomputing.com \
--cc=cota@braap.org \
--cc=peter.puhov@futurewei.com \
--cc=qemu-devel@nongnu.org \
--cc=robert.foley@futurewei.com \
/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).