mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
plugins: add userdata for qemu_plugin_{uninstall, reset}
We do both at the same time because they internally use the same implementation. Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260615193526.2883349-3-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
This commit is contained in:
@@ -77,7 +77,7 @@ static char *path_to_unlink;
|
||||
|
||||
static bool verbose;
|
||||
|
||||
static void plugin_cleanup(qemu_plugin_id_t id)
|
||||
static void plugin_cleanup(qemu_plugin_id_t id, void *userdata)
|
||||
{
|
||||
/* Free our block data */
|
||||
g_slist_free_full(blocks, &g_free);
|
||||
@@ -98,7 +98,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
|
||||
g_string_append_printf(out, "Executed ~%ld instructions\n", insn_count);
|
||||
qemu_plugin_outs(out->str);
|
||||
|
||||
plugin_cleanup(id);
|
||||
plugin_cleanup(id, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -189,7 +189,7 @@ static void report_divergance(ExecState *us, ExecState *them)
|
||||
}
|
||||
qemu_plugin_outs(out->str);
|
||||
qemu_plugin_outs("giving up\n");
|
||||
qemu_plugin_uninstall(our_id, plugin_cleanup);
|
||||
qemu_plugin_uninstall(our_id, plugin_cleanup, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
|
||||
qemu_plugin_outs(bytes < 0 ?
|
||||
"problem writing to socket" :
|
||||
"wrote less than expected to socket");
|
||||
qemu_plugin_uninstall(our_id, plugin_cleanup);
|
||||
qemu_plugin_uninstall(our_id, plugin_cleanup, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
|
||||
qemu_plugin_outs(bytes < 0 ?
|
||||
"problem reading from socket" :
|
||||
"read less than expected");
|
||||
qemu_plugin_uninstall(our_id, plugin_cleanup);
|
||||
qemu_plugin_uninstall(our_id, plugin_cleanup, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,6 +221,7 @@ typedef void (*qemu_plugin_vcpu_discon_cb_t)(qemu_plugin_id_t id,
|
||||
* qemu_plugin_uninstall() - Uninstall a plugin
|
||||
* @id: this plugin's opaque ID
|
||||
* @cb: callback to be called once the plugin has been removed
|
||||
* @userdata: any plugin data to pass to the @cb
|
||||
*
|
||||
* Do NOT assume that the plugin has been uninstalled once this function
|
||||
* returns. Plugins are uninstalled asynchronously, and therefore the given
|
||||
@@ -229,12 +230,14 @@ typedef void (*qemu_plugin_vcpu_discon_cb_t)(qemu_plugin_id_t id,
|
||||
* Note: Calling this function from qemu_plugin_install() is a bug.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb);
|
||||
void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_reset() - Reset a plugin
|
||||
* @id: this plugin's opaque ID
|
||||
* @cb: callback to be called once the plugin has been reset
|
||||
* @userdata: any plugin data to pass to the @cb
|
||||
*
|
||||
* Unregisters all callbacks for the plugin given by @id.
|
||||
*
|
||||
@@ -243,7 +246,8 @@ void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb);
|
||||
* callbacks until @cb is called.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb);
|
||||
void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* qemu_plugin_register_vcpu_init_cb() - register a vCPU initialization callback
|
||||
|
||||
@@ -51,14 +51,16 @@
|
||||
|
||||
/* Uninstall and Reset handlers */
|
||||
|
||||
void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb)
|
||||
void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
plugin_reset_uninstall(id, cb, false);
|
||||
plugin_reset_uninstall(id, cb, userdata, false);
|
||||
}
|
||||
|
||||
void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb)
|
||||
void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb,
|
||||
void *userdata)
|
||||
{
|
||||
plugin_reset_uninstall(id, cb, true);
|
||||
plugin_reset_uninstall(id, cb, userdata, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -253,7 +253,7 @@ static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info, E
|
||||
* call a full uninstall if the plugin did not yet call it.
|
||||
*/
|
||||
if (!ctx->uninstalling) {
|
||||
plugin_reset_uninstall(ctx->id, NULL, false);
|
||||
plugin_reset_uninstall(ctx->id, NULL, NULL, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,8 @@ int qemu_plugin_load_list(QemuPluginList *head, Error **errp)
|
||||
|
||||
struct qemu_plugin_reset_data {
|
||||
struct qemu_plugin_ctx *ctx;
|
||||
qemu_plugin_simple_cb_t cb;
|
||||
qemu_plugin_udata_cb_t cb;
|
||||
void *userdata;
|
||||
bool reset;
|
||||
};
|
||||
|
||||
@@ -338,7 +339,7 @@ static void plugin_reset_destroy__locked(struct qemu_plugin_reset_data *data)
|
||||
if (data->reset) {
|
||||
g_assert(ctx->resetting);
|
||||
if (data->cb) {
|
||||
data->cb(ctx->id);
|
||||
data->cb(ctx->id, data->userdata);
|
||||
}
|
||||
ctx->resetting = false;
|
||||
g_free(data);
|
||||
@@ -357,7 +358,7 @@ static void plugin_reset_destroy__locked(struct qemu_plugin_reset_data *data)
|
||||
g_assert(success);
|
||||
QTAILQ_REMOVE(&plugin.ctxs, ctx, entry);
|
||||
if (data->cb) {
|
||||
data->cb(ctx->id);
|
||||
data->cb(ctx->id, data->userdata);
|
||||
}
|
||||
if (!g_module_close(ctx->handle)) {
|
||||
warn_report("%s: %s", __func__, g_module_error());
|
||||
@@ -383,7 +384,8 @@ static void plugin_flush_destroy(CPUState *cpu, run_on_cpu_data arg)
|
||||
}
|
||||
|
||||
void plugin_reset_uninstall(qemu_plugin_id_t id,
|
||||
qemu_plugin_simple_cb_t cb,
|
||||
qemu_plugin_udata_cb_t cb,
|
||||
void *userdata,
|
||||
bool reset)
|
||||
{
|
||||
struct qemu_plugin_reset_data *data;
|
||||
@@ -401,6 +403,7 @@ void plugin_reset_uninstall(qemu_plugin_id_t id,
|
||||
data = g_new(struct qemu_plugin_reset_data, 1);
|
||||
data->ctx = ctx;
|
||||
data->cb = cb;
|
||||
data->userdata = userdata;
|
||||
data->reset = reset;
|
||||
/*
|
||||
* Only flush the code cache if the vCPUs have been created. If so,
|
||||
|
||||
@@ -76,7 +76,8 @@ void plugin_register_inline_op_on_entry(GArray **arr,
|
||||
uint64_t imm);
|
||||
|
||||
void plugin_reset_uninstall(qemu_plugin_id_t id,
|
||||
qemu_plugin_simple_cb_t cb,
|
||||
qemu_plugin_udata_cb_t cb,
|
||||
void *userdata,
|
||||
bool reset);
|
||||
|
||||
void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
|
||||
|
||||
@@ -14,7 +14,7 @@ static qemu_plugin_id_t plugin_id;
|
||||
static bool was_reset;
|
||||
static bool was_uninstalled;
|
||||
|
||||
static void after_uninstall(qemu_plugin_id_t id)
|
||||
static void after_uninstall(qemu_plugin_id_t id, void *userdata)
|
||||
{
|
||||
g_assert(was_reset && !was_uninstalled);
|
||||
qemu_plugin_outs("uninstall done\n");
|
||||
@@ -24,7 +24,7 @@ static void after_uninstall(qemu_plugin_id_t id)
|
||||
static void tb_exec_after_reset(unsigned int vcpu_index, void *userdata)
|
||||
{
|
||||
g_assert(was_reset && !was_uninstalled);
|
||||
qemu_plugin_uninstall(plugin_id, after_uninstall);
|
||||
qemu_plugin_uninstall(plugin_id, after_uninstall, NULL);
|
||||
}
|
||||
|
||||
static void tb_trans_after_reset(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
|
||||
@@ -34,7 +34,7 @@ static void tb_trans_after_reset(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
|
||||
QEMU_PLUGIN_CB_NO_REGS, NULL);
|
||||
}
|
||||
|
||||
static void after_reset(qemu_plugin_id_t id)
|
||||
static void after_reset(qemu_plugin_id_t id, void *userdata)
|
||||
{
|
||||
g_assert(!was_reset && !was_uninstalled);
|
||||
qemu_plugin_outs("reset done\n");
|
||||
@@ -45,7 +45,7 @@ static void after_reset(qemu_plugin_id_t id)
|
||||
static void tb_exec_before_reset(unsigned int vcpu_index, void *userdata)
|
||||
{
|
||||
g_assert(!was_reset && !was_uninstalled);
|
||||
qemu_plugin_reset(plugin_id, after_reset);
|
||||
qemu_plugin_reset(plugin_id, after_reset, NULL);
|
||||
}
|
||||
|
||||
static void tb_trans_before_reset(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
|
||||
|
||||
Reference in New Issue
Block a user