On 5/11/25 6:13 AM, Julian Ganz wrote:
We recently introduced new plugin API for registration of discontinuity
related callbacks. This change introduces a minimal plugin showcasing
the new API. It simply counts the occurances of interrupts, exceptions
and host calls per CPU and reports the counts when exitting.
Signed-off-by: Julian Ganz <neither@nut.email>
---
contrib/plugins/meson.build | 3 +-
contrib/plugins/traps.c | 100 ++++++++++++++++++++++++++++++++++++
docs/about/emulation.rst | 8 +++
3 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 contrib/plugins/traps.c
+typedef struct {
+ uint64_t interrupts;
+ uint64_t exceptions;
+ uint64_t hostcalls;
+ bool active;
The scoreboard is automatically resized only when a new vcpu is
initialized, so if an entry is present, it means it's present by definition.
Thus, you can remove the active field.
+} TrapCounters;
+
+static struct qemu_plugin_scoreboard *traps;
+static size_t max_vcpus;
+
You can use qemu_plugin_num_vcpus() instead of keeping a copy of
max_vcpus. It returns the number of vcpus started, which guarantees
you'll find associated entries in any scoreboard.
[...]
With those small changes,
Reviewed-by: Pierrick Bouvier <pierrick.bouv...@linaro.org>