[PATCH 5/5] plugins/core: allow reading of registers during discon events

Alex Bennée posted 5 patches 2 months, 1 week ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Markus Armbruster <armbru@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
There is a newer version of this series
[PATCH 5/5] plugins/core: allow reading of registers during discon events
Posted by Alex Bennée 2 months, 1 week ago
We have protections that prevent callbacks that didn't declare
themselves as wanting to access registers. However for discontinuities
the system state is fully rectified so they should always be able to
read the register values.

a1688bc86ce (plugins: add hooks for new discontinuity related callbacks)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Julian Ganz <neither@nut.email>
---
 plugins/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plugins/core.c b/plugins/core.c
index 8f8bc7219c2..b4b783008f7 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -119,6 +119,7 @@ static void plugin_vcpu_cb__discon(CPUState *cpu,
     struct qemu_plugin_cb *cb, *next;
     uint64_t to = cpu->cc->get_pc(cpu);
 
+    qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS);
     if (cpu->cpu_index < plugin.num_vcpus) {
         /* iterate safely; plugins might uninstall themselves at any time */
         QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
@@ -127,6 +128,7 @@ static void plugin_vcpu_cb__discon(CPUState *cpu,
             func(cb->ctx->id, cpu->cpu_index, type, from, to);
         }
     }
+    qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS);
 }
 
 /*
-- 
2.47.3


Re: [PATCH 5/5] plugins/core: allow reading of registers during discon events
Posted by Julian Ganz 2 months, 1 week ago
Hi Alex,

November 28, 2025 at 7:21 PM, "Alex Bennée" wrote:
> We have protections that prevent callbacks that didn't declare
> themselves as wanting to access registers. However for discontinuities
> the system state is fully rectified so they should always be able to
> read the register values.
> 
> a1688bc86ce (plugins: add hooks for new discontinuity related callbacks)
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Julian Ganz <neither@nut.email>
> ---
>  plugins/core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/plugins/core.c b/plugins/core.c
> index 8f8bc7219c2..b4b783008f7 100644
> --- a/plugins/core.c
> +++ b/plugins/core.c
> @@ -119,6 +119,7 @@ static void plugin_vcpu_cb__discon(CPUState *cpu,
>  struct qemu_plugin_cb *cb, *next;
>  uint64_t to = cpu->cc->get_pc(cpu);
>  
> + qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS);
>  if (cpu->cpu_index < plugin.num_vcpus) {
>  /* iterate safely; plugins might uninstall themselves at any time */
>  QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
> @@ -127,6 +128,7 @@ static void plugin_vcpu_cb__discon(CPUState *cpu,
>  func(cb->ctx->id, cpu->cpu_index, type, from, to);
>  }
>  }
> + qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS);
>  }

Yes, we definitely want this.

Reviewed-by: Julian Ganz <neither@nut.email>

Regards,
Julian