1
2
3
4
5
6
7
8
9
10
11
12#ifndef PLUGIN_H
13#define PLUGIN_H
14
15#include <gmodule.h>
16#include "qemu/qht.h"
17
18#define QEMU_PLUGIN_MIN_VERSION 0
19
20
21struct qemu_plugin_state {
22 QTAILQ_HEAD(, qemu_plugin_ctx) ctxs;
23 QLIST_HEAD(, qemu_plugin_cb) cb_lists[QEMU_PLUGIN_EV_MAX];
24
25
26
27
28 GHashTable *id_ht;
29
30
31
32
33 GHashTable *cpu_ht;
34 DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX);
35
36
37
38
39
40
41 QemuRecMutex lock;
42
43
44
45
46 struct qht dyn_cb_arr_ht;
47};
48
49
50struct qemu_plugin_ctx {
51 GModule *handle;
52 qemu_plugin_id_t id;
53 struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX];
54 QTAILQ_ENTRY(qemu_plugin_ctx) entry;
55
56
57
58
59 struct qemu_plugin_desc *desc;
60 bool installing;
61 bool uninstalling;
62 bool resetting;
63};
64
65struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id);
66
67void plugin_register_inline_op(GArray **arr,
68 enum qemu_plugin_mem_rw rw,
69 enum qemu_plugin_op op, void *ptr,
70 uint64_t imm);
71
72void plugin_reset_uninstall(qemu_plugin_id_t id,
73 qemu_plugin_simple_cb_t cb,
74 bool reset);
75
76void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
77 void *func);
78
79void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,
80 enum qemu_plugin_event ev);
81
82void
83plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev,
84 void *func, void *udata);
85
86void
87plugin_register_dyn_cb__udata(GArray **arr,
88 qemu_plugin_vcpu_udata_cb_t cb,
89 enum qemu_plugin_cb_flags flags, void *udata);
90
91
92void plugin_register_vcpu_mem_cb(GArray **arr,
93 void *cb,
94 enum qemu_plugin_cb_flags flags,
95 enum qemu_plugin_mem_rw rw,
96 void *udata);
97
98void exec_inline_op(struct qemu_plugin_dyn_cb *cb);
99
100#endif
101