plugins: add userdata to qemu_plugin_register_flush_cb
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-4-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Pierrick Bouvier committed
Jun 15, 2026 at 12:35 UTC
58ba4498d8dce4ad32c44cbfc5c5ea97a079f319
2 files changed
+8
-27
include/plugins/qemu-plugin.h
+3
-1
@@ -973,6 +973,7 @@ void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id,
973
* qemu_plugin_register_flush_cb() - register code cache flush callback
974
* @id: plugin ID
975
* @cb: callback
976
+ * @userdata: user data for callback
977
*
978
* The @cb function is called every time the code cache is flushed.
979
* The callback can be used to free resources associated with existing
@@ -981,7 +982,8 @@ void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id,
982
*/
983
QEMU_PLUGIN_API
984
void qemu_plugin_register_flush_cb(qemu_plugin_id_t id,
984
- qemu_plugin_simple_cb_t cb);
985
+ qemu_plugin_udata_cb_t cb,
986
+ void *userdata);
987
988
/**
989
* qemu_plugin_register_atexit_cb() - register exit callback
plugins/core.c
+5
-26
@@ -131,29 +131,6 @@ static void plugin_vcpu_cb__discon(CPUState *cpu,
131
qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS);
132
}
133
134
-/*
135
- * Disable CFI checks.
136
- * The callback function has been loaded from an external library so we do not
137
- * have type information
138
- */
139
-QEMU_DISABLE_CFI
140
-static void plugin_cb__simple(enum qemu_plugin_event ev)
141
-{
142
- struct qemu_plugin_cb *cb, *next;
143
-
144
- switch (ev) {
145
- case QEMU_PLUGIN_EV_FLUSH:
146
- QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
147
- qemu_plugin_simple_cb_t func = cb->f.simple;
148
-
149
- func(cb->ctx->id);
150
- }
151
- break;
152
- default:
153
- g_assert_not_reached();
154
- }
155
-}
156
-
134
/*
135
* Disable CFI checks.
136
* The callback function has been loaded from an external library so we do not
@@ -166,6 +143,7 @@ static void plugin_cb__udata(enum qemu_plugin_event ev)
143
144
switch (ev) {
145
case QEMU_PLUGIN_EV_ATEXIT:
146
+ case QEMU_PLUGIN_EV_FLUSH:
147
QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
148
qemu_plugin_udata_cb_t func = cb->f.udata;
149
@@ -690,9 +668,10 @@ void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id,
668
}
669
670
void qemu_plugin_register_flush_cb(qemu_plugin_id_t id,
693
- qemu_plugin_simple_cb_t cb)
671
+ qemu_plugin_udata_cb_t cb,
672
+ void *userdata)
673
{
695
- plugin_register_cb(id, QEMU_PLUGIN_EV_FLUSH, cb);
674
+ plugin_register_cb_udata(id, QEMU_PLUGIN_EV_FLUSH, cb, userdata);
675
}
676
677
static bool free_dyn_cb_arr(void *p, uint32_t h, void *userp)
@@ -706,7 +685,7 @@ void qemu_plugin_flush_cb(void)
685
qht_iter_remove(&plugin.dyn_cb_arr_ht, free_dyn_cb_arr, NULL);
686
qht_reset(&plugin.dyn_cb_arr_ht);
687
709
- plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH);
688
+ plugin_cb__udata(QEMU_PLUGIN_EV_FLUSH);
689
}
690
691
void exec_inline_op(enum plugin_dyn_cb_type type,