Re: [PATCH 18/25] plugins: add userdata to qemu_plugin_register_vcpu_syscall_cb

2026-06-15 Thread Pierrick Bouvier
On 6/10/2026 11:00 PM, Manos Pitsidianakis wrote:
> On Wed, 03 Jun 2026 23:51, Pierrick Bouvier
>  wrote:
>> Signed-off-by: Pierrick Bouvier 
>> ---
>> include/plugins/qemu-plugin.h | 8 ++--
>> plugins/api.c | 5 +++--
>> plugins/core.c    | 2 +-
>> tests/tcg/plugins/syscall.c   | 5 +++--
>> 4 files changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/plugins/qemu-plugin.h b/include/plugins/qemu-
>> plugin.h
>> index d82d996bce6..909f19b7128 100644
>> --- a/include/plugins/qemu-plugin.h
>> +++ b/include/plugins/qemu-plugin.h
>> @@ -840,12 +840,14 @@ void qemu_plugin_update_ns(const void *handle,
>> int64_t time);
>>  * @a6: the 6th syscall argument
>>  * @a7: the 7th syscall argument
>>  * @a8: the 8th syscall argument
>> + * @userdata: user data for callback
>>  */
>> typedef void
>> (*qemu_plugin_vcpu_syscall_cb_t)(unsigned int vcpu_index,
>>  int64_t num, uint64_t a1, uint64_t a2,
>>  uint64_t a3, uint64_t a4, uint64_t a5,
>> - uint64_t a6, uint64_t a7, uint64_t a8);
>> + uint64_t a6, uint64_t a7, uint64_t a8,
>> + void *userdata);
>>
>> /**
>>  * typedef qemu_plugin_vcpu_syscall_filter_cb_t - vCPU syscall filter
>> callback
>> @@ -891,13 +893,15 @@ typedef void
>>  * qemu_plugin_register_vcpu_syscall_cb() - register a syscall entry
>> callback
>>  * @id: plugin id
>>  * @cb: callback of type qemu_plugin_vcpu_syscall_cb_t
>> + * @userdata: user data for callback
> 
> Suggestion: I noticed in some patches you say "for @cb" and sometimes
> "for callback", if you re-spin this series you could make them
> consistent if you wish.
>

I added a commit on top changing all comments to "user data for
callback", since cb may or may not be present, depending if it's
callback registration, or type.

> Reviewed-by: Manos Pitsidianakis 
>
...

Regards,
Pierrick



Re: [PATCH 18/25] plugins: add userdata to qemu_plugin_register_vcpu_syscall_cb

2026-06-10 Thread Manos Pitsidianakis

On Wed, 03 Jun 2026 23:51, Pierrick Bouvier  
wrote:

Signed-off-by: Pierrick Bouvier 
---
include/plugins/qemu-plugin.h | 8 ++--
plugins/api.c | 5 +++--
plugins/core.c| 2 +-
tests/tcg/plugins/syscall.c   | 5 +++--
4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/plugins/qemu-plugin.h b/include/plugins/qemu-plugin.h
index d82d996bce6..909f19b7128 100644
--- a/include/plugins/qemu-plugin.h
+++ b/include/plugins/qemu-plugin.h
@@ -840,12 +840,14 @@ void qemu_plugin_update_ns(const void *handle, int64_t 
time);
 * @a6: the 6th syscall argument
 * @a7: the 7th syscall argument
 * @a8: the 8th syscall argument
+ * @userdata: user data for callback
 */
typedef void
(*qemu_plugin_vcpu_syscall_cb_t)(unsigned int vcpu_index,
 int64_t num, uint64_t a1, uint64_t a2,
 uint64_t a3, uint64_t a4, uint64_t a5,
- uint64_t a6, uint64_t a7, uint64_t a8);
+ uint64_t a6, uint64_t a7, uint64_t a8,
+ void *userdata);

/**
 * typedef qemu_plugin_vcpu_syscall_filter_cb_t - vCPU syscall filter callback
@@ -891,13 +893,15 @@ typedef void
 * qemu_plugin_register_vcpu_syscall_cb() - register a syscall entry callback
 * @id: plugin id
 * @cb: callback of type qemu_plugin_vcpu_syscall_cb_t
+ * @userdata: user data for callback


Suggestion: I noticed in some patches you say "for @cb" and sometimes 
"for callback", if you re-spin this series you could make them 
consistent if you wish.


Reviewed-by: Manos Pitsidianakis 


 *
 * This registers a callback for every syscall executed by the guest. The @cb
 * function is executed before a syscall is handled by the host.
 */
QEMU_PLUGIN_API
void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
-  qemu_plugin_vcpu_syscall_cb_t cb);
+  qemu_plugin_vcpu_syscall_cb_t cb,
+  void *userdata);

/**
 * qemu_plugin_register_vcpu_syscall_filter_cb() - register a syscall filter
diff --git a/plugins/api.c b/plugins/api.c
index 774b1b80214..a72cec541dc 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -202,9 +202,10 @@ void 
qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id,
}

void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
-  qemu_plugin_vcpu_syscall_cb_t cb)
+  qemu_plugin_vcpu_syscall_cb_t cb,
+  void *userdata)
{
-plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb);
+plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb, userdata);
}

void
diff --git a/plugins/core.c b/plugins/core.c
index 878fc47cbe1..45136bf950a 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -533,7 +533,7 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, 
uint64_t a1, uint64_t a2,
qemu_plugin_vcpu_syscall_cb_t func = cb->f.vcpu_syscall;

qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS_PC);
-func(cpu->cpu_index, num, a1, a2, a3, a4, a5, a6, a7, a8);
+func(cpu->cpu_index, num, a1, a2, a3, a4, a5, a6, a7, a8, cb->udata);
qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS);
}
}
diff --git a/tests/tcg/plugins/syscall.c b/tests/tcg/plugins/syscall.c
index bfe12ad5558..8a823acfca7 100644
--- a/tests/tcg/plugins/syscall.c
+++ b/tests/tcg/plugins/syscall.c
@@ -128,7 +128,8 @@ static void hexdump(const GByteArray *data)
static void vcpu_syscall(unsigned int vcpu_index,
 int64_t num, uint64_t a1, uint64_t a2,
 uint64_t a3, uint64_t a4, uint64_t a5,
- uint64_t a6, uint64_t a7, uint64_t a8)
+ uint64_t a6, uint64_t a7, uint64_t a8,
+ void *userdata)
{
if (statistics) {
SyscallStats *entry;
@@ -271,7 +272,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t 
id,
memory_buffer = g_byte_array_new();
}

-qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall);
+qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall, NULL);
qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret);
qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter);
qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
--
2.43.0






[PATCH 18/25] plugins: add userdata to qemu_plugin_register_vcpu_syscall_cb

2026-06-03 Thread Pierrick Bouvier
Signed-off-by: Pierrick Bouvier 
---
 include/plugins/qemu-plugin.h | 8 ++--
 plugins/api.c | 5 +++--
 plugins/core.c| 2 +-
 tests/tcg/plugins/syscall.c   | 5 +++--
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/plugins/qemu-plugin.h b/include/plugins/qemu-plugin.h
index d82d996bce6..909f19b7128 100644
--- a/include/plugins/qemu-plugin.h
+++ b/include/plugins/qemu-plugin.h
@@ -840,12 +840,14 @@ void qemu_plugin_update_ns(const void *handle, int64_t 
time);
  * @a6: the 6th syscall argument
  * @a7: the 7th syscall argument
  * @a8: the 8th syscall argument
+ * @userdata: user data for callback
  */
 typedef void
 (*qemu_plugin_vcpu_syscall_cb_t)(unsigned int vcpu_index,
  int64_t num, uint64_t a1, uint64_t a2,
  uint64_t a3, uint64_t a4, uint64_t a5,
- uint64_t a6, uint64_t a7, uint64_t a8);
+ uint64_t a6, uint64_t a7, uint64_t a8,
+ void *userdata);
 
 /**
  * typedef qemu_plugin_vcpu_syscall_filter_cb_t - vCPU syscall filter callback
@@ -891,13 +893,15 @@ typedef void
  * qemu_plugin_register_vcpu_syscall_cb() - register a syscall entry callback
  * @id: plugin id
  * @cb: callback of type qemu_plugin_vcpu_syscall_cb_t
+ * @userdata: user data for callback
  *
  * This registers a callback for every syscall executed by the guest. The @cb
  * function is executed before a syscall is handled by the host.
  */
 QEMU_PLUGIN_API
 void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
-  qemu_plugin_vcpu_syscall_cb_t cb);
+  qemu_plugin_vcpu_syscall_cb_t cb,
+  void *userdata);
 
 /**
  * qemu_plugin_register_vcpu_syscall_filter_cb() - register a syscall filter
diff --git a/plugins/api.c b/plugins/api.c
index 774b1b80214..a72cec541dc 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -202,9 +202,10 @@ void 
qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id,
 }
 
 void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id,
-  qemu_plugin_vcpu_syscall_cb_t cb)
+  qemu_plugin_vcpu_syscall_cb_t cb,
+  void *userdata)
 {
-plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb);
+plugin_register_cb_udata(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb, userdata);
 }
 
 void
diff --git a/plugins/core.c b/plugins/core.c
index 878fc47cbe1..45136bf950a 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -533,7 +533,7 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, 
uint64_t a1, uint64_t a2,
 qemu_plugin_vcpu_syscall_cb_t func = cb->f.vcpu_syscall;
 
 qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS_PC);
-func(cpu->cpu_index, num, a1, a2, a3, a4, a5, a6, a7, a8);
+func(cpu->cpu_index, num, a1, a2, a3, a4, a5, a6, a7, a8, cb->udata);
 qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS);
 }
 }
diff --git a/tests/tcg/plugins/syscall.c b/tests/tcg/plugins/syscall.c
index bfe12ad5558..8a823acfca7 100644
--- a/tests/tcg/plugins/syscall.c
+++ b/tests/tcg/plugins/syscall.c
@@ -128,7 +128,8 @@ static void hexdump(const GByteArray *data)
 static void vcpu_syscall(unsigned int vcpu_index,
  int64_t num, uint64_t a1, uint64_t a2,
  uint64_t a3, uint64_t a4, uint64_t a5,
- uint64_t a6, uint64_t a7, uint64_t a8)
+ uint64_t a6, uint64_t a7, uint64_t a8,
+ void *userdata)
 {
 if (statistics) {
 SyscallStats *entry;
@@ -271,7 +272,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t 
id,
 memory_buffer = g_byte_array_new();
 }
 
-qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall);
+qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall, NULL);
 qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret);
 qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter);
 qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
-- 
2.43.0