Skip to contentSkip to conversation

plugins: Move declarations around and rename 'hwaddr' argument

PATCH Applied Philippe Mathieu-Daudé 3 participants 6 messages May 10, 2020 – May 12, 2020

lore
Share & tools
lore
#0 lore raw

cover plugins: Move declarations around and rename 'hwaddr' argument

Rename qemu_plugin_hwaddr_is_io() 'hwaddr' argument to later allow declaration of the 'hwaddr' type to be poisoned (see [*]).

[*] https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg02254.html
"exec/cpu: Poison 'hwaddr' type in user-mode emulation"

Philippe Mathieu-Daudé (3):
qemu/plugin: Trivial code movement
qemu/plugin: Move !CONFIG_PLUGIN stubs altogether qemu/qemu-plugin: Make qemu_plugin_hwaddr_is_io() hwaddr argument
const

 include/qemu/plugin.h      | 65 ++++++++++++++++++--------------------
 include/qemu/qemu-plugin.h |  2 +-
 plugins/api.c              |  4 +--
 3 files changed, 34 insertions(+), 37 deletions(-)
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/3 qemu/plugin: Trivial code movement

Move the qemu_plugin_event enum declaration earlier. This will make the next commit easier to review.

---
 include/qemu/plugin.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
include/qemu/plugin.h +16 -16
index 11687e8cdc..e45f950fe3 100644
@@ -13,6 +13,22 @@
 #include "qemu/queue.h"
 #include "qemu/option.h"
 
+/*
+ * Events that plugins can subscribe to.
+ */
+enum qemu_plugin_event {
+    QEMU_PLUGIN_EV_VCPU_INIT,
+    QEMU_PLUGIN_EV_VCPU_EXIT,
+    QEMU_PLUGIN_EV_VCPU_TB_TRANS,
+    QEMU_PLUGIN_EV_VCPU_IDLE,
+    QEMU_PLUGIN_EV_VCPU_RESUME,
+    QEMU_PLUGIN_EV_VCPU_SYSCALL,
+    QEMU_PLUGIN_EV_VCPU_SYSCALL_RET,
+    QEMU_PLUGIN_EV_FLUSH,
+    QEMU_PLUGIN_EV_ATEXIT,
+    QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */
+};
+
 /*
  * Option parsing/processing.
  * Note that we can load an arbitrary number of plugins.
@@ -47,22 +63,6 @@ static inline int qemu_plugin_load_list(QemuPluginList *head)
 }
 #endif /* !CONFIG_PLUGIN */
 
-/*
- * Events that plugins can subscribe to.
- */
-enum qemu_plugin_event {
-    QEMU_PLUGIN_EV_VCPU_INIT,
-    QEMU_PLUGIN_EV_VCPU_EXIT,
-    QEMU_PLUGIN_EV_VCPU_TB_TRANS,
-    QEMU_PLUGIN_EV_VCPU_IDLE,
-    QEMU_PLUGIN_EV_VCPU_RESUME,
-    QEMU_PLUGIN_EV_VCPU_SYSCALL,
-    QEMU_PLUGIN_EV_VCPU_SYSCALL_RET,
-    QEMU_PLUGIN_EV_FLUSH,
-    QEMU_PLUGIN_EV_ATEXIT,
-    QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */
-};
-
 union qemu_plugin_cb_sig {
     qemu_plugin_simple_cb_t          simple;
     qemu_plugin_udata_cb_t           udata;
Signature · 1 line
2.21.3
#2 lore raw

PATCH 2/3 qemu/plugin: Move !CONFIG_PLUGIN stubs altogether

In reply to Philippe Mathieu-Daudé

Simplify the ifdef'ry by moving all stubs together.

---
 include/qemu/plugin.h | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)
include/qemu/plugin.h +15 -18
index e45f950fe3..ab790ad105 100644
@@ -46,22 +46,6 @@ static inline void qemu_plugin_add_opts(void)
 
 void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head);
 int qemu_plugin_load_list(QemuPluginList *head);
-#else /* !CONFIG_PLUGIN */
-static inline void qemu_plugin_add_opts(void)
-{ }
-
-static inline void qemu_plugin_opt_parse(const char *optarg,
-                                         QemuPluginList *head)
-{
-    error_report("plugin interface not enabled in this build");
-    exit(1);
-}
-
-static inline int qemu_plugin_load_list(QemuPluginList *head)
-{
-    return 0;
-}
-#endif /* !CONFIG_PLUGIN */
 
 union qemu_plugin_cb_sig {
     qemu_plugin_simple_cb_t          simple;
@@ -182,8 +166,6 @@ struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb)
     return insn;
 }
 
-#ifdef CONFIG_PLUGIN
-
 void qemu_plugin_vcpu_init_hook(CPUState *cpu);
 void qemu_plugin_vcpu_exit_hook(CPUState *cpu);
 void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb);
@@ -207,6 +189,21 @@ void qemu_plugin_disable_mem_helpers(CPUState *cpu);
 
 #else /* !CONFIG_PLUGIN */
 
+static inline void qemu_plugin_add_opts(void)
+{ }
+
+static inline void qemu_plugin_opt_parse(const char *optarg,
+                                         QemuPluginList *head)
+{
+    error_report("plugin interface not enabled in this build");
+    exit(1);
+}
+
+static inline int qemu_plugin_load_list(QemuPluginList *head)
+{
+    return 0;
+}
+
 static inline void qemu_plugin_vcpu_init_hook(CPUState *cpu)
 { }
 
Signature · 1 line
2.21.3
#3 lore raw

PATCH 3/3 qemu/qemu-plugin: Make qemu_plugin_hwaddr_is_io() hwaddr argument const

In reply to Philippe Mathieu-Daudé

Rename qemu_plugin_hwaddr_is_io() address argument 'haddr' similarly to qemu_plugin_hwaddr_device_offset(), and make it const.

---
Having the variable named similarly to the 'hwaddr' typedef is slighly confusing. Also if we declare 'hwaddr' typedef poisoned, GCC complains qemu_plugin_hwaddr_is_io() use a poisoned variable...

---
 include/qemu/qemu-plugin.h | 2 +-
 plugins/api.c              | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/qemu/qemu-plugin.h +1 -1
index 5502e112c8..89ed579f55 100644
@@ -331,7 +331,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
  * to return information about it. For non-IO accesses the device
  * offset will be into the appropriate block of RAM.
  */
-bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr);
+bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr);
 uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr);
 
 typedef void
plugins/api.c +2 -2
index 53c8a73582..bbdc5a4eb4 100644
@@ -275,10 +275,10 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
 }
 #endif
 
-bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr)
+bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr)
 {
 #ifdef CONFIG_SOFTMMU
-    return hwaddr->is_io;
+    return haddr->is_io;
 #else
     return false;
 #endif
Signature · 1 line
2.21.3
Reviewed-by on the v1 series
#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Rename qemu_plugin_hwaddr_is_io() 'hwaddr' argument to later allow declaration of the 'hwaddr' type to be poisoned (see [*]).

[*] https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg02254.html
"exec/cpu: Poison 'hwaddr' type in user-mode emulation"

Philippe Mathieu-Daudé (3):
qemu/plugin: Trivial code movement
qemu/plugin: Move !CONFIG_PLUGIN stubs altogether qemu/qemu-plugin: Make qemu_plugin_hwaddr_is_io() hwaddr argument
const

for the series.

Thanks,

		E.
Applied
#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Rename qemu_plugin_hwaddr_is_io() 'hwaddr' argument to later allow declaration of the 'hwaddr' type to be poisoned (see [*]).

[*] https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg02254.html
"exec/cpu: Poison 'hwaddr' type in user-mode emulation"

Queued to plugins/next, thanks.

Quoted 11 lines

Philippe Mathieu-Daudé (3):
qemu/plugin: Trivial code movement
qemu/plugin: Move !CONFIG_PLUGIN stubs altogether qemu/qemu-plugin: Make qemu_plugin_hwaddr_is_io() hwaddr argument
const

 include/qemu/plugin.h      | 65 ++++++++++++++++++--------------------
 include/qemu/qemu-plugin.h |  2 +-
 plugins/api.c              |  4 +--
 3 files changed, 34 insertions(+), 37 deletions(-)
Signature · 1 line
Alex Bennée