diff mbox series

[3/8] plugins: add id_to_plugin_name

Message ID 20221213213757.4123265-4-fasano@mit.edu
State New
Headers show
Series Inter-plugin interactions with QPP | expand

Commit Message

Andrew Fasano Dec. 13, 2022, 9:37 p.m. UTC
From: Elysia Witham <elysia.witham@ll.mit.edu>

Plugins will pass their unique id when creating callbacks to
ensure they are associated with the correct plugin. This
internal function resolves those ids to the declared names.

Signed-off-by: Elysia Witham <elysia.witham@ll.mit.edu>
Signed-off-by: Andrew Fasano <fasano@mit.edu>
---
 plugins/core.c   | 12 ++++++++++++
 plugins/plugin.h |  2 ++
 2 files changed, 14 insertions(+)

Comments

Alex Bennée March 9, 2023, 2:45 p.m. UTC | #1
Andrew Fasano <fasano@mit.edu> writes:

> From: Elysia Witham <elysia.witham@ll.mit.edu>
>
> Plugins will pass their unique id when creating callbacks to
> ensure they are associated with the correct plugin. This
> internal function resolves those ids to the declared names.
>
> Signed-off-by: Elysia Witham <elysia.witham@ll.mit.edu>
> Signed-off-by: Andrew Fasano <fasano@mit.edu>
> ---
>  plugins/core.c   | 12 ++++++++++++
>  plugins/plugin.h |  2 ++
>  2 files changed, 14 insertions(+)
>
> diff --git a/plugins/core.c b/plugins/core.c
> index 5fbdcb5768..6a50b4a6e6 100644
> --- a/plugins/core.c
> +++ b/plugins/core.c
> @@ -248,6 +248,18 @@ int name_to_plugin_version(const char *name)
>      return -1;
>  }
>  
> +const char *id_to_plugin_name(qemu_plugin_id_t id)
> +{
> +    const char *plugin = plugin_id_to_ctx_locked(id)->name;
> +    if (plugin) {
> +        return plugin;
> +    } else {
> +        warn_report("Unnamed plugin cannot use QPP, not supported in plugin "
> +                    "version. Please update plugin.");
> +        return NULL;
> +    }
> +}
> +

I don't see this function being used in this series.
diff mbox series

Patch

diff --git a/plugins/core.c b/plugins/core.c
index 5fbdcb5768..6a50b4a6e6 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -248,6 +248,18 @@  int name_to_plugin_version(const char *name)
     return -1;
 }
 
+const char *id_to_plugin_name(qemu_plugin_id_t id)
+{
+    const char *plugin = plugin_id_to_ctx_locked(id)->name;
+    if (plugin) {
+        return plugin;
+    } else {
+        warn_report("Unnamed plugin cannot use QPP, not supported in plugin "
+                    "version. Please update plugin.");
+        return NULL;
+    }
+}
+
 struct plugin_for_each_args {
     struct qemu_plugin_ctx *ctx;
     qemu_plugin_vcpu_simple_cb_t cb;
diff --git a/plugins/plugin.h b/plugins/plugin.h
index ce885bfa98..9e710c23a7 100644
--- a/plugins/plugin.h
+++ b/plugins/plugin.h
@@ -104,4 +104,6 @@  void exec_inline_op(struct qemu_plugin_dyn_cb *cb);
 
 int name_to_plugin_version(const char *name);
 
+const char *id_to_plugin_name(qemu_plugin_id_t id);
+
 #endif /* PLUGIN_H */