plugins: add userdata to qemu_plugin_register_vcpu_syscall_filter_cb
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-21-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
d7706f7e89af0e65249127f316db139f54696bf4
5 files changed
+14
-9
include/plugins/qemu-plugin.h
+6
-2
@@ -863,6 +863,7 @@ typedef void
863
* @a7: the 7th syscall argument
864
* @a8: the 8th syscall argument
865
* @sysret: reference of the syscall return value, must set this if filtered
866
+ * @userdata: user data for callback
867
*
868
* Returns true if you want to filter this syscall (i.e. stop it being
869
* handled further), otherwise returns false.
@@ -872,7 +873,8 @@ typedef bool
873
int64_t num, uint64_t a1, uint64_t a2,
874
uint64_t a3, uint64_t a4, uint64_t a5,
875
uint64_t a6, uint64_t a7, uint64_t a8,
875
- uint64_t *sysret);
876
+ uint64_t *sysret,
877
+ void *userdata);
878
879
/**
880
* typedef qemu_plugin_vcpu_syscall_ret_cb_t - vCPU syscall return callback
@@ -906,6 +908,7 @@ void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
908
* callback
909
* @id: plugin id
910
* @cb: callback of type qemu_plugin_vcpu_syscall_filter_cb_t
911
+ * @userdata: user data for callback
912
*
913
* This registers a callback for every syscall executed by the guest. The @cb
914
* function is executed before a syscall is handled by the host. If the
@@ -916,7 +919,8 @@ void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
919
QEMU_PLUGIN_API
920
void
921
qemu_plugin_register_vcpu_syscall_filter_cb(qemu_plugin_id_t id,
919
- qemu_plugin_vcpu_syscall_filter_cb_t cb);
922
+ qemu_plugin_vcpu_syscall_filter_cb_t cb,
923
+ void *userdata);
924
925
/**
926
* qemu_plugin_register_vcpu_syscall_ret_cb() - register a syscall entry
plugins/api.c
+3
-2
@@ -217,9 +217,10 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id,
217
218
void
219
qemu_plugin_register_vcpu_syscall_filter_cb(qemu_plugin_id_t id,
220
- qemu_plugin_vcpu_syscall_filter_cb_t cb)
220
+ qemu_plugin_vcpu_syscall_filter_cb_t cb,
221
+ void *userdata)
222
{
222
- plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER, cb);
223
+ plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER, cb, userdata);
224
}
225
226
/*
plugins/core.c
+1
-1
@@ -591,7 +591,7 @@ qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1,
591
qemu_plugin_vcpu_syscall_filter_cb_t func = cb->f.vcpu_syscall_filter;
592
593
if (func(cpu->cpu_index, num, a1, a2, a3, a4,
594
- a5, a6, a7, a8, sysret)) {
594
+ a5, a6, a7, a8, sysret, cb->udata)) {
595
filtered = true;
596
break;
597
}
tests/tcg/plugins/setpc.c
+2
-2
@@ -27,7 +27,7 @@ static bool vcpu_syscall_filter(unsigned int vcpu_index,
27
int64_t num, uint64_t a1, uint64_t a2,
28
uint64_t a3, uint64_t a4, uint64_t a5,
29
uint64_t a6, uint64_t a7, uint64_t a8,
30
- uint64_t *sysret)
30
+ uint64_t *sysret, void *userdata)
31
{
32
if (num == MAGIC_SYSCALL) {
33
if (a1 == SETPC) {
@@ -99,7 +99,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
99
int argc, char **argv)
100
{
101
102
- qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter);
102
+ qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter, NULL);
103
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans, NULL);
104
return 0;
105
}
tests/tcg/plugins/syscall.c
+2
-2
@@ -175,7 +175,7 @@ static bool vcpu_syscall_filter(unsigned int vcpu_index,
175
int64_t num, uint64_t a1, uint64_t a2,
176
uint64_t a3, uint64_t a4, uint64_t a5,
177
uint64_t a6, uint64_t a7, uint64_t a8,
178
- uint64_t *sysret)
178
+ uint64_t *sysret, void *userdata)
179
{
180
/* Special syscall to test the filter functionality. */
181
if (num == 4096 && a1 == 0x66CCFF) {
@@ -274,7 +274,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
274
275
qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall, NULL);
276
qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret);
277
- qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter);
277
+ qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter, NULL);
278
qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
279
return 0;
280
}