mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
plugins: add userdata to qemu_plugin_vcpu_for_each
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-12-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
This commit is contained in:
@@ -957,6 +957,7 @@ const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn);
|
||||
* qemu_plugin_vcpu_for_each() - iterate over the existing vCPU
|
||||
* @id: plugin ID
|
||||
* @cb: callback function
|
||||
* @userdata: user data for callback
|
||||
*
|
||||
* The @cb function is called once for each existing vCPU.
|
||||
*
|
||||
@@ -964,7 +965,8 @@ const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn);
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id,
|
||||
qemu_plugin_vcpu_simple_cb_t cb);
|
||||
qemu_plugin_vcpu_udata_cb_t cb,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_register_flush_cb() - register code cache flush callback
|
||||
|
||||
@@ -297,18 +297,20 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu)
|
||||
|
||||
struct plugin_for_each_args {
|
||||
struct qemu_plugin_ctx *ctx;
|
||||
qemu_plugin_vcpu_simple_cb_t cb;
|
||||
qemu_plugin_vcpu_udata_cb_t cb;
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
static void plugin_vcpu_for_each(gpointer k, gpointer v, gpointer udata)
|
||||
{
|
||||
struct plugin_for_each_args *args = udata;
|
||||
int cpu_index = *(int *)k;
|
||||
args->cb(cpu_index);
|
||||
args->cb(cpu_index, args->userdata);
|
||||
}
|
||||
|
||||
void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id,
|
||||
qemu_plugin_vcpu_simple_cb_t cb)
|
||||
qemu_plugin_vcpu_udata_cb_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
struct plugin_for_each_args args;
|
||||
|
||||
@@ -318,6 +320,7 @@ void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id,
|
||||
qemu_rec_mutex_lock(&plugin.lock);
|
||||
args.ctx = plugin_id_to_ctx_locked(id);
|
||||
args.cb = cb;
|
||||
args.userdata = userdata;
|
||||
g_hash_table_foreach(plugin.cpu_ht, plugin_vcpu_for_each, &args);
|
||||
qemu_rec_mutex_unlock(&plugin.lock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user