From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967713; cv=none; d=zohomail.com; s=zohoarc; b=X3xqaMwUySMl4RgORMwfIaXwCRZRNM2+nLbqMfqQXYbaoj4SHtnYE19pFKCiWPpSuVEvDdYQuPLVVnIx5e45XX9RJCS8eWVncmPTOAN+xeW1f/+J9GAJ/C+0l27hhPbVFzHGOKfZ564mSQ8sFK7JmXeAk3tiKeIr/q5o2UNNwYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967713; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qhmHsNmAxlc9cgZSHsaFvxxQAkUFKHHtR2wF32S33cU=; b=RT5mBW9e4/iX94gkI0CD4SHRLhziB0nOxAGYeKhfbuA6qCnLw0OllcknfSrdH5dvbmRakiA84J0WscEgXqEZ5wiBczy8M7EdAYwpI95fGmLgU6rU5Xhnx7wV85rN3RRIGfjcI1BrEK4M6FI71KzlJT/9DSR06tleFD2vqpWa32k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967713928442.90026639166615; Tue, 13 Dec 2022 13:41:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Czl-0000Nt-En; Tue, 13 Dec 2022 16:39:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5Cza-0000I5-6b for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:14 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5CzX-0007fj-JD for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:13 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaP8030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967543; bh=qhmHsNmAxlc9cgZSHsaFvxxQAkUFKHHtR2wF32S33cU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LJuy556R0K7ZVisHDE4AFZ1HpKCxWhDfhINd5ytr/I4D19jqTldCyYO/oJJPs1Dne jRfaZ0bFTRuafpF/dGMFmxSRMCW4gbbTHdKz9RY2JlCjBLlKJQ7WKagjJ1ULIBGrBx VgBoB1pT2G3h8JRTdWf6CQFEQwQVzqAvMPxwAKZen29JzvFgYsUwEJSIDDgi9SqY0r kxxPYEey8AQHomPFdJlaez9TQ8lSZVLUi4WMwxsay5ZFu1+mPTMWlNYlgABV5oKFq+ X90GiSNgu7z3ACeG/1BLXRQ/h7uHvU7a7a+z22IXRWicNBYjpJXM1wePoCu6vIQOKO c6ae/kv0K94fQ== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 1/8] docs/devel: describe QPP API Date: Tue, 13 Dec 2022 16:37:50 -0500 Message-Id: <20221213213757.4123265-2-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967714565100001 Content-Type: text/plain; charset="utf-8" From: Elysia Witham The new QPP API allows plugin-to-plugin interaction for creating and using callbacks as well as importing and exporting functions. The new test plugins qpp_srv and qpp_client demonstrate how plugins use the new API. Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano Reviewed-by: Alex Benn=C3=A9e --- docs/devel/tcg-plugins.rst | 91 +++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 9740a70406..70ac09b96b 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -281,6 +281,14 @@ run:: 160 1 0 135 1 0 =20 +- tests/plugins/qpp_srv.c & tests/plugins/qpp_client.c + +These plugins demonstrate QPP interactions. The qpp_srv plugin defines +a few exported functions and its own callback which are then imported and +used by the qpp_client plugin. The qpp_client plugin registers its own +function to run on qpp_srv's defined callback. The tests for these plugins +are modified as both plugins must be loaded in order to work. + - contrib/plugins/hotblocks.c =20 The hotblocks plugin allows you to examine the where hot paths of @@ -573,6 +581,88 @@ The plugin has a number of arguments, all of them are = optional: configuration arguments implies ``l2=3Don``. (default: N =3D 2097152 (2MB), B =3D 64, A =3D 16) =20 +Plugin-to-Plugin Interactions +----------------------------- + +Plugins may interact with other plugins through the QEMU Plugin-to-Plugin +("QPP") API by including ```` in addition to ````. +This API supports direct function calls between plugins. An inter-plugin +callback system is supported within the core code as long as +``qemu_plugin_version >=3D 2``. + +Plugin names +~~~~~~~~~~~~ +Plugin names must be exported as ``qemu_plugin_name`` to use the QPP API i= n the same way +``qemu_plugin_version`` is exported. This name can then be used by other p= lugins +to import functions and use callbacks belonging to that plugin. + +Plugin dependencies +~~~~~~~~~~~~~~~~~~~ +For a plugin to use another plugin's functions or callbacks it must declar= e that +dependency through exporting ``qemu_plugin_uses`` which is a string array = containing +names of plugins used by that plugin. Those plugins must be loaded first. = Note that this +array must be null terminated, e.g. ``{plugin_a, NULL}``. + +QPP function calls +~~~~~~~~~~~~~~~~~~ +When a plugin (e.g., ``plugin_a``) wishes to make some of its functions (e= .g., +``func_1``) available to other plugins, it must: + +1. Mark the function definition with the ``QEMU_PLUGIN_EXPORT`` macro. For +example : ``QEMU_PLUGIN_EXPORT int func_1(int x) {...}`` +2. Provide prototypes for exported functions in a header file using the ma= cro +``QPP_FUN_PROTOTYPE`` with arguments of the plugin's name, the function's +return type, the function's name, and any arguments the function takes. For +example: ``QPP_FUN_PROTOTYPE(my_plugin, int, do_add, int);``. +3. Import this header from the plugin. + +When other plugins wish to use the functions exported by ``plugin_a``, they +must: + +1. Import the header file with the function prototype(s). +2. Call the function when desired by combining the target plugin name, an + underscore, and the target function name with ``_qpp`` on the end, + e.g., ``plugin_a_func_1_qpp()``. + +QPP callbacks +~~~~~~~~~~~~~ + +The QPP API also allows a plugin to define callback events and for other p= lugins +to request to be notified whenever these events happens. The plugin that d= efines +the callback is responsible for triggering the callback when it so wishes.= Other +plugins that wish to be notified on these events must define a function of= an +appropriate type and register it to run on this event. +In particular, these plugins must: + + +When a plugin (e.g., ``plugin_a``) wishes to define a callback (an event t= hat +other plugins can request to be notified about), it must: + +1. Define the callback using the ``qemu_plugin_create_callback`` function = which + takes two arguments: the unique ``qemu_plugin_id_t id`` and the callbac= k name. +2. Call ``qemu_plugin_run_callback`` at appropriate places in the code to = call registered + callback functions. It takes four arguments: the unique ``qemu_plugin_i= d_t id``, + the callback name, and the callback arguments which are standardized to= be + ``gpointer evdata, gpointer udata``. The callback arguments point to tw= o structs + which are defined by the plugin and can vary based on the use case of t= he callback. + +When other plugins wish to register a function to run on such an event, th= ey +must: + +1. Define a function that matches the ``cb_func_t`` type: + ``typedef void (*cb_func_t) (gpointer evdata, gpointer udata)``. +2. Register this function to be run on the plugin defined callback using + ``qemu_plugin_reg_callback``. This function takes three arguments: the = name of the + plugin which defines the callback, the callback name, and a ``cb_func_t= `` function + pointer. + +When other plugins wish to unregister a function which is registered to ru= n on a plugin +defined event callback, they must: + +1. Call ``qemu_plugin_unreg_callback``. This function takes the same argum= ents as + ``qemu_plugin_reg_callback``. It will return true if it successfully fi= nds and + unregisters the function. + API --- =20 @@ -581,4 +671,3 @@ The following API is generated from the inline document= ation in include the full kernel-doc annotations. =20 .. kernel-doc:: include/qemu/qemu-plugin.h - --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967762; cv=none; d=zohomail.com; s=zohoarc; b=SM5kcsS8dOUpw2jXAVLskf/5Vr0SFe3y1/W54ivgLtYpkd2HjvawfUJGtw96F6r93aHwNrsK5EL9i6b7R2LoGl0TaPPTG3FXZy6+yym4aQDzMYERwA4iYd1vunQFyFa7wYGq40YBAUGHQdWFuVJhV+vcwFXG7tkIND0a9HkTNrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967762; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZFqDgDpvqgvL67HbOiFhNpFqQ1ztb5o8G6x1h8Nifgg=; b=elFq+gID1pC6mAbPKjHzuRtWcbHflc00t5at9BdoCEskBN822ftYh1He6aXhEQ/+iDbxyoR/9cPMFMKJkoYbQI6uTgJA4ZRBsi7WIQPAqb2ZSoImI72BBXobaPJV8vWunSnvZ04fR0M/KSJOPDedGb+w9X+0WLdRNDWa+2yr/xY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967762963841.7549676489793; Tue, 13 Dec 2022 13:42:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Czw-0000u7-SI; Tue, 13 Dec 2022 16:39:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5Czv-0000pB-3i for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:35 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5Czt-0007j1-8W for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:34 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaP9030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967567; bh=ZFqDgDpvqgvL67HbOiFhNpFqQ1ztb5o8G6x1h8Nifgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=n5mayuXrLGwSSUlV2qkzECJQsiSUnFKWUWgy9vmdenfASpaah9zJagjVlyswuJ5eL aoja/5FtV7wBG2XGuqV5IAcz+asAWhcfDPNlHTXBnmTtxdoOg23LOQ+t5+wacquPfs kAPePV5Kjc4oKQnoR731PjjRWFAurjtTUWPj5N5K5pcgpPRZ33qT+EUErD2aXwrm16 7Xiom0KALEItO/05enuqpm9ZQz7e97iuZcwthYG0nFQ/bMYzPO/iibqIbUXOnrei4D SOPAfF15Gt9GIoK6rcXPW16+ypSYyqBH6z1jGEKoawwu96dHix6xUgb3ndz6NMWX3F u1MOdXfufYd8g== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 2/8] plugins: version 2, require unique plugin names Date: Tue, 13 Dec 2022 16:37:51 -0500 Message-Id: <20221213213757.4123265-3-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967764820100003 Content-Type: text/plain; charset="utf-8" From: Elysia Witham In order for the QPP API to resolve interactions between plugins, plugins must export their own names which cannot match any other loaded plugins. Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano --- include/qemu/qemu-plugin.h | 2 +- plugins/core.c | 12 +++++++++ plugins/loader.c | 50 +++++++++++++++++++++++++++++++++----- plugins/plugin.h | 7 ++++++ tests/plugin/bb.c | 1 + tests/plugin/empty.c | 1 + tests/plugin/insn.c | 1 + tests/plugin/mem.c | 1 + tests/plugin/syscall.c | 1 + 9 files changed, 69 insertions(+), 7 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index d0e9d03adf..5326f33ce8 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -51,7 +51,7 @@ typedef uint64_t qemu_plugin_id_t; =20 extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; =20 -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 =20 /** * struct qemu_info_t - system information for plugins diff --git a/plugins/core.c b/plugins/core.c index ccb770a485..5fbdcb5768 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -236,6 +236,18 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu) qemu_rec_mutex_unlock(&plugin.lock); } =20 +int name_to_plugin_version(const char *name) +{ + struct qemu_plugin_ctx *ctx; + QTAILQ_FOREACH(ctx, &plugin.ctxs, entry) { + if (strcmp(ctx->name, name) =3D=3D 0) { + return ctx->version; + } + } + warn_report("Could not find any plugin named %s.", name); + return -1; +} + struct plugin_for_each_args { struct qemu_plugin_ctx *ctx; qemu_plugin_vcpu_simple_cb_t cb; diff --git a/plugins/loader.c b/plugins/loader.c index 88c30bde2d..12c0680e03 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -177,7 +177,7 @@ QEMU_DISABLE_CFI static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *i= nfo, Error **errp) { qemu_plugin_install_func_t install; - struct qemu_plugin_ctx *ctx; + struct qemu_plugin_ctx *ctx, *ctx2; gpointer sym; int rc; =20 @@ -208,17 +208,55 @@ static int plugin_load(struct qemu_plugin_desc *desc,= const qemu_info_t *info, E desc->path, g_module_error()); goto err_symbol; } else { - int version =3D *(int *)sym; - if (version < QEMU_PLUGIN_MIN_VERSION) { + ctx->version =3D *(int *)sym; + if (ctx->version < QEMU_PLUGIN_MIN_VERSION) { error_setg(errp, "Could not load plugin %s: plugin requires AP= I version %d, but " "this QEMU supports only a minimum version of %d", - desc->path, version, QEMU_PLUGIN_MIN_VERSION); + desc->path, ctx->version, QEMU_PLUGIN_MIN_VERSION); goto err_symbol; - } else if (version > QEMU_PLUGIN_VERSION) { + } else if (ctx->version > QEMU_PLUGIN_VERSION) { error_setg(errp, "Could not load plugin %s: plugin requires AP= I version %d, but " "this QEMU supports only up to version %d", - desc->path, version, QEMU_PLUGIN_VERSION); + desc->path, ctx->version, QEMU_PLUGIN_VERSION); goto err_symbol; + } else if (ctx->version < QPP_MINIMUM_VERSION) { + ctx->name =3D NULL; + } else { + if (!g_module_symbol(ctx->handle, "qemu_plugin_name", &sym)) { + error_setg(errp, "Could not load plugin %s: plugin does no= t " + "declare plugin name %s", + desc->path, g_module_error()); + goto err_symbol; + } + ctx->name =3D (const char *)strdup(*(const char **)sym); + QTAILQ_FOREACH(ctx2, &plugin.ctxs, entry) { + if (strcmp(ctx2->name, ctx->name) =3D=3D 0) { + error_setg(errp, "Could not load plugin %s as the name= %s " + "is already in use by plugin at %s", + desc->path, ctx->name, ctx2->desc->path); + goto err_symbol; + } + } + if (g_module_symbol(ctx->handle, "qemu_plugin_uses", &sym)) { + const char **dependencies =3D &(*(const char **)sym); + bool found =3D false; + while (*dependencies) { + found =3D false; + QTAILQ_FOREACH(ctx2, &plugin.ctxs, entry) { + if (strcmp(ctx2->name, *dependencies) =3D=3D 0) { + dependencies++; + found =3D true; + break; + } + } + if (!found) { + error_setg(errp, "Could not load plugin %s as it i= s " + "dependent on %s which is not loaded", + ctx->name, *dependencies); + goto err_symbol; + } + } + } } } =20 diff --git a/plugins/plugin.h b/plugins/plugin.h index 5eb2fdbc85..ce885bfa98 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -16,6 +16,7 @@ #include "qemu/qht.h" =20 #define QEMU_PLUGIN_MIN_VERSION 0 +#define QPP_MINIMUM_VERSION 2 =20 /* global state */ struct qemu_plugin_state { @@ -50,6 +51,8 @@ struct qemu_plugin_state { struct qemu_plugin_ctx { GModule *handle; qemu_plugin_id_t id; + const char *name; + int version; struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX]; QTAILQ_ENTRY(qemu_plugin_ctx) entry; /* @@ -64,6 +67,8 @@ struct qemu_plugin_ctx { =20 struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); =20 +struct qemu_plugin_ctx *plugin_name_to_ctx_locked(const char* name); + void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, void *ptr, @@ -97,4 +102,6 @@ void plugin_register_vcpu_mem_cb(GArray **arr, =20 void exec_inline_op(struct qemu_plugin_dyn_cb *cb); =20 +int name_to_plugin_version(const char *name); + #endif /* PLUGIN_H */ diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index 7d470a1011..c04e5aaf90 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -15,6 +15,7 @@ #include =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "bb"; =20 typedef struct { GMutex lock; diff --git a/tests/plugin/empty.c b/tests/plugin/empty.c index 8fa6bacd93..0f3d2b92b9 100644 --- a/tests/plugin/empty.c +++ b/tests/plugin/empty.c @@ -14,6 +14,7 @@ #include =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "empty"; =20 /* * Empty TB translation callback. diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index cd5ea5d4ae..3f71138139 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -15,6 +15,7 @@ #include =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "insn"; =20 #define MAX_CPUS 8 /* lets not go nuts */ =20 diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 4570f7d815..35e5d7fe2a 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -15,6 +15,7 @@ #include =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "mem"; =20 static uint64_t inline_mem_count; static uint64_t cb_mem_count; diff --git a/tests/plugin/syscall.c b/tests/plugin/syscall.c index 96040c578f..922bdbd2e6 100644 --- a/tests/plugin/syscall.c +++ b/tests/plugin/syscall.c @@ -15,6 +15,7 @@ #include =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "syscall"; =20 typedef struct { int64_t num; --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967782; cv=none; d=zohomail.com; s=zohoarc; b=nnoOSvVqEDMTiGxdRhD33763dQwQoR4LuQmEGWit7stLX9pqczQDT7sP3VqlAVwNOerZz7qaHlVkfgTnHzHDbIz+EWwPlqBnrvaO804bXBwWB8QjXAYQAdgwNdhYmU/jI/Y9nbJWMGSitNBt9WiILibXG4b3d5xv1UzaNH69zgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967782; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b/fRDQjk1a1CUz1f4lwvRtAJOQhJid7h6LlJif5e9Qk=; b=EIXDB3SYQwOrIU295Ffyciyg/Vflo1XgOybs/5XEX0D6rorzyph91PjtwYYhbuFOEJxnQbx8oBazZAKDlrt9TSQona2laPlFgUPuVYldgoDfGU4Vqh0aNKuNSUAur9pSPHA2Gzzh+FFJDDjbEfijsRVA8Y7y28FORudwqAtIurA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967782938462.901333656965; Tue, 13 Dec 2022 13:43:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5D04-0001I7-1q; Tue, 13 Dec 2022 16:39:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D00-0001Ea-S9 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:41 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5Czz-0007jY-9X for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:40 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaPA030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967574; bh=b/fRDQjk1a1CUz1f4lwvRtAJOQhJid7h6LlJif5e9Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Re+IXSkO82sIvAiugHKM0M5MOjygXQVHZ60AwcxOAk5N5C2ZU1vYkj7pFS51f0z+D owhAdwuM0wBDr5cDX0FMHQRCgOwVi0c1IwaVBGLGaO5L3WnVufPMd3eVg9w2Eol/El OF+ML6mFGBQ4exZt9IVyXUPOnKyO/NVXvWWdhBXeHtUzqfyNRlYsI6lHnmRIocKUDd gB6Ccu2qxbnDT4F8RhuTKGULyhwDOjm+i3ecEUy1DtKjJ5Y4ex/6BfXxY2uSvAgJYk k6eey1l2c7EZiCcQDNrg2sXs6O8jsG4bYtjOc2rTugAcmU54veozI39MMGQ5A6+9A7 d+GukysafNJ4Q== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 3/8] plugins: add id_to_plugin_name Date: Tue, 13 Dec 2022 16:37:52 -0500 Message-Id: <20221213213757.4123265-4-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967784911100003 Content-Type: text/plain; charset="utf-8" From: Elysia Witham 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 Signed-off-by: Andrew Fasano --- 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; } =20 +const char *id_to_plugin_name(qemu_plugin_id_t id) +{ + const char *plugin =3D plugin_id_to_ctx_locked(id)->name; + if (plugin) { + return plugin; + } else { + warn_report("Unnamed plugin cannot use QPP, not supported in plugi= n " + "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); =20 int name_to_plugin_version(const char *name); =20 +const char *id_to_plugin_name(qemu_plugin_id_t id); + #endif /* PLUGIN_H */ --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967884; cv=none; d=zohomail.com; s=zohoarc; b=LCyR8WzUVhzCWwDzPsqIcEbUgqKbBU/C4CnuG6yGPie2aXezFzey7tXKsOq+1MMGYqrMhnVRZlH4ASyFiMbuCMa3x2q28l9QRKvgxrQLZCeVusUqWVFuQzcsfTFeK7/vfmecCOTJNrmXBzhvq+KKzVhwc93SKQamYB9kNSHdNz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967884; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZeqRkWTd2BT5/GKlC7ST3zyaMAEqj7qslbCZ6CRnJI0=; b=ShAwqZG8bP2u+L9R75ijjlRnuq2KGzbnd4lTTHM8DG0m+PSBaXDkgFEw+TmX/aq8l2/bFlX+WN58+1DDwyKZl2k0EZySNn1wA37q6sKGpbz9N1PzcP+TGsfsWRy9b0XeVfo8URHSjjlO83lOLshzJfg2pThpE65g8kjXtPtwoD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967884739298.63087718638644; Tue, 13 Dec 2022 13:44:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5D0M-0001SS-Qu; Tue, 13 Dec 2022 16:40:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D04-0001IX-KP for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:46 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D02-0007k0-UT for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:44 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaPB030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967577; bh=ZeqRkWTd2BT5/GKlC7ST3zyaMAEqj7qslbCZ6CRnJI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bFtvMAK8Nrfa6I+BLJ8G7VvNVO85Eaz/Ang7RP+PTLU0R6h97WzMLdg6f/sxsNB+9 YDU2ca+RpwLrJbRDrhnCjlFGFa1kXGDfJgRzN2eQ3K7fvyldu0/6lwh4vqRRikxiNt UdgZ00VHhi1i56apMqsg3In3TE/e8Uy6d7iJL8ks5heS2rQhYlhCvq0iyauKdg1gBd TBJCw9GnZ6QbnDCKaW9Q5NgcmAC8dgu1DXiy2A+qEZFdb3DH48Z392yv93A9SviSJX joNFsnnZUDahgP5MJvhFBSkMghytLZbra+DcJOUWVPhaJTu0MJqz0foXtW24a3v+wB 20fEw5hPnxHTA== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 4/8] plugins: add core API functions for QPP callbacks Date: Tue, 13 Dec 2022 16:37:53 -0500 Message-Id: <20221213213757.4123265-5-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967885431100005 Content-Type: text/plain; charset="utf-8" From: Elysia Witham Plugin callbacks and their registered functions are stored in a separate struct which is accessible from the plugin's ctx. In order for plugins to use another plugin's callbacks, we have internal functions that resolve a plugin's name to its ctx and find a target plugin. Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano --- include/qemu/qemu-plugin.h | 10 ++++++++++ plugins/core.c | 23 +++++++++++++++++++++++ plugins/loader.c | 10 ++++++++++ plugins/plugin.h | 15 +++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 5326f33ce8..3ec82ce97f 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -14,6 +14,7 @@ #include #include #include +#include =20 /* * For best performance, build the plugin with -fvisibility=3Dhidden so th= at @@ -38,6 +39,15 @@ */ typedef uint64_t qemu_plugin_id_t; =20 +/** + * typedef cb_func_t - callback function pointer type + * @evdata: plugin callback defined event data + * @udata: plugin defined user data + * + * No return value. + */ +typedef void (*cb_func_t) (gpointer evdata, gpointer udata); + /* * Versioning plugins: * diff --git a/plugins/core.c b/plugins/core.c index 6a50b4a6e6..0415a55ec5 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -236,6 +236,17 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu) qemu_rec_mutex_unlock(&plugin.lock); } =20 +struct qemu_plugin_ctx *plugin_name_to_ctx_locked(const char* name) +{ + struct qemu_plugin_ctx *ctx; + QTAILQ_FOREACH(ctx, &plugin.ctxs, entry) { + if (strcmp(ctx->name, name) =3D=3D 0) { + return plugin_id_to_ctx_locked(ctx->id); + } + } + return NULL; +} + int name_to_plugin_version(const char *name) { struct qemu_plugin_ctx *ctx; @@ -260,6 +271,18 @@ const char *id_to_plugin_name(qemu_plugin_id_t id) } } =20 +struct qemu_plugin_qpp_cb *plugin_find_qpp_cb(struct qemu_plugin_ctx *ctx, + const char *name) +{ + struct qemu_plugin_qpp_cb *cb; + QTAILQ_FOREACH(cb, &ctx->qpp_cbs, entry) { + if (strcmp(cb->name, name) =3D=3D 0) { + return cb; + } + } + return NULL; +} + struct plugin_for_each_args { struct qemu_plugin_ctx *ctx; qemu_plugin_vcpu_simple_cb_t cb; diff --git a/plugins/loader.c b/plugins/loader.c index 12c0680e03..ab01d0753c 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -277,6 +277,7 @@ static int plugin_load(struct qemu_plugin_desc *desc, c= onst qemu_info_t *info, E break; } } + QTAILQ_INIT(&ctx->qpp_cbs); QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); ctx->installing =3D true; rc =3D install(ctx->id, info, desc->argc, desc->argv); @@ -303,6 +304,15 @@ static int plugin_load(struct qemu_plugin_desc *desc, = const qemu_info_t *info, E return 1; } =20 +void plugin_add_qpp_cb(struct qemu_plugin_ctx *ctx, const char *name) +{ + struct qemu_plugin_qpp_cb *new_cb; + new_cb =3D qemu_memalign(qemu_dcache_linesize, sizeof(*new_cb)); + memset(new_cb, 0, sizeof(*new_cb)); + new_cb->name =3D name; + QTAILQ_INSERT_TAIL(&ctx->qpp_cbs, new_cb, entry); +} + /* call after having removed @desc from the list */ static void plugin_desc_free(struct qemu_plugin_desc *desc) { diff --git a/plugins/plugin.h b/plugins/plugin.h index 9e710c23a7..fee4741bc6 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -47,6 +47,14 @@ struct qemu_plugin_state { struct qht dyn_cb_arr_ht; }; =20 +typedef void (*cb_func_t) (gpointer evdata, gpointer udata); + +struct qemu_plugin_qpp_cb { + const char *name; + cb_func_t registered_cb_funcs[QEMU_PLUGIN_EV_MAX]; + int counter; + QTAILQ_ENTRY(qemu_plugin_qpp_cb) entry; +}; =20 struct qemu_plugin_ctx { GModule *handle; @@ -54,6 +62,7 @@ struct qemu_plugin_ctx { const char *name; int version; struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX]; + QTAILQ_HEAD(, qemu_plugin_qpp_cb) qpp_cbs; QTAILQ_ENTRY(qemu_plugin_ctx) entry; /* * keep a reference to @desc until uninstall, so that plugins do not h= ave @@ -106,4 +115,10 @@ int name_to_plugin_version(const char *name); =20 const char *id_to_plugin_name(qemu_plugin_id_t id); =20 +struct qemu_plugin_qpp_cb *plugin_find_qpp_cb(struct qemu_plugin_ctx *plug= in_ctx, + const char *cb_name); + +/* loader.c */ +void plugin_add_qpp_cb(struct qemu_plugin_ctx *ctx, const char *name); + #endif /* PLUGIN_H */ --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967655; cv=none; d=zohomail.com; s=zohoarc; b=Bl+nhl8Ot91dyYt1j47kFoc+CVJY/ATkSTCo/m8FUuIUUNLNzdlei3YBxhrWEPIs/cFE5KSC0wNCk3Ks6K0PMtja8hAYmj73YHtikYfGxL3jaQfoTAt/yAWc1FT+kCgk6++brWau/ks6SPoWW1JrnBs1UVW/BddLsLRlgwpPlMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967655; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MO+yNbqxssUgwRZwoPiy6Wwl9yYxJ9O7XdO8prt82i0=; b=UQybU8RUU82VOiPOb9fbdkyFvGFyblX7v/RvhE4NPeBYAbqNcLRwLSb6XZ8mtbjQ9WhZqF6GHMJ6LBka1wMYE+fqej/B/jEU1vx7mpt6KLqtgeiWFtjLmZUU6fmjsFSJ0J8hMGcHrdTujRnnxK/dgD362X0LMCWER9P6v6s3CgU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967655289856.0933221856194; Tue, 13 Dec 2022 13:40:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5D0c-0001VK-HH; Tue, 13 Dec 2022 16:40:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D09-0001JR-9C for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:49 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D07-0007km-60 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:48 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaPC030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967579; bh=MO+yNbqxssUgwRZwoPiy6Wwl9yYxJ9O7XdO8prt82i0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GmJyqnvRAfg0n/L/0te6z+/H0Z2wBXpkOhCTzrZEmNzeow3pSjcX68+RUc8BqoLeP by1fmGGoJX2ohUbwkfPGZ1hMkTZKCaAgd4N3t5R0sdTe2e5DdlIlWekwVFTHoraSt3 zYy3eELi3R/nL+7j0MQj7XZS7QlqSjLL3bdHisdGbT2Z6PIrZoDhzh8ZgHdD/0vfF5 gNoW2+h/gZb4gY5xRdlSjgz7mUQA96VtJI9WHByteSpWdKjp16rdCVEflatx7xTccJ orGdYCh2hWbJYi1fjh8eIavGwa9+pP0ogz5WH/8ExnLRiPQClIRDLbvdAaMl5aiDmu N5y8nDtxLfzlQ== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 5/8] plugins: implement QPP callbacks Date: Tue, 13 Dec 2022 16:37:54 -0500 Message-Id: <20221213213757.4123265-6-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967656364100001 Content-Type: text/plain; charset="utf-8" From: Elysia Witham Plugins are able to use API functions which are explained in to create and run their own callbacks and register functions on another plugin's callbacks. Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano --- include/qemu/qemu-plugin.h | 46 +++++++++++++++ plugins/api.c | 111 +++++++++++++++++++++++++++++++++++ plugins/loader.c | 1 + plugins/qemu-plugins.symbols | 4 ++ 4 files changed, 162 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 3ec82ce97f..4221545015 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -354,6 +354,52 @@ size_t qemu_plugin_tb_n_insns(const struct qemu_plugin= _tb *tb); */ uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); =20 +/** + * qemu_plugin_create_callback() - create a new cb with given name + * @id: unique plugin id + * @name: name of cb + * + * Returns: true on success, false otherwise + */ +bool qemu_plugin_create_callback(qemu_plugin_id_t id, const char *name); + +/** + * qemu_plugin_run_callback() - run all functions registered to cb with gi= ven + * name using given args + * @id: unique plugin id + * @name: name of cb + * @evdata: pointer to evdata struct + * @udata: pointer to udata struct + * + * Returns: true if any registerd functions were run, false otherwise + */ +bool qemu_plugin_run_callback(qemu_plugin_id_t id, const char *name, + gpointer evdata, gpointer udata); + +/** + * qemu_plugin_reg_callback() - register a function to be called on cb with + * given name + * @target_plugin: name of plugin that provides the callback + * @cb_name: name of the callback + * @function_pointer: pointer to function being registered + * + * Returns: true if function was registered successfully, false otherwise + */ +bool qemu_plugin_reg_callback(const char *target_plugin, const char *cb_na= me, + cb_func_t function_pointer); + +/** + * qemu_plugin_unreg_callback() - unregister a function to be called on cb + * with given name + * @target_plugin: name of plugin that provides the callback + * @cb_name: name of the callback + * @function_pointer: pointer to function being unregistered + * + * Returns: true if function was unregistered successfully, false otherwise + */ +bool qemu_plugin_unreg_callback(const char *target_plugin, const char *cb_= name, + cb_func_t function_pointer); + /** * qemu_plugin_tb_get_insn() - retrieve handle for instruction * @tb: opaque handle to TB passed to callback diff --git a/plugins/api.c b/plugins/api.c index 2078b16edb..1f7ea718dc 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -400,6 +400,117 @@ bool qemu_plugin_bool_parse(const char *name, const c= har *value, bool *ret) return name && value && qapi_bool_parse(name, value, ret, NULL); } =20 +bool qemu_plugin_create_callback(qemu_plugin_id_t id, const char *cb_name) +{ + struct qemu_plugin_ctx *ctx =3D plugin_id_to_ctx_locked(id); + if (ctx =3D=3D NULL) { + error_report("Cannot create callback with invalid plugin ID"); + return false; + } + + if (ctx->version < QPP_MINIMUM_VERSION) { + error_report("Plugin %s cannot create callbacks as its PLUGIN_VERS= ION" + " %d is below QPP_MINIMUM_VERSION (%d).", + ctx->name, ctx->version, QPP_MINIMUM_VERSION); + return false; + } + + if (plugin_find_qpp_cb(ctx, cb_name)) { + error_report("Plugin %s already created callback %s", ctx->name, + cb_name); + return false; + } + + plugin_add_qpp_cb(ctx, cb_name); + return true; +} + +bool qemu_plugin_run_callback(qemu_plugin_id_t id, const char *cb_name, + gpointer evdata, gpointer udata) { + struct qemu_plugin_ctx *ctx =3D plugin_id_to_ctx_locked(id); + if (ctx =3D=3D NULL) { + error_report("Cannot run callback with invalid plugin ID"); + return false; + } + + struct qemu_plugin_qpp_cb *cb =3D plugin_find_qpp_cb(ctx, cb_name); + if (!cb) { + error_report("Can not run previously-unregistered callback %s in " + "plugin %s", cb_name, ctx->name); + return false; + } + + for (int i =3D 0; i < cb->counter; i++) { + cb_func_t qpp_cb_func =3D cb->registered_cb_funcs[i]; + qpp_cb_func(evdata, udata); + } + + return (cb->registered_cb_funcs[0] !=3D NULL); +} + +bool qemu_plugin_reg_callback(const char *target_plugin, const char *cb_na= me, + cb_func_t function_pointer) { + struct qemu_plugin_ctx *ctx =3D plugin_name_to_ctx_locked(target_plugi= n); + if (ctx =3D=3D NULL) { + error_report("Cannot register callback with unknown plugin %s", + target_plugin); + return false; + } + + struct qemu_plugin_qpp_cb *cb =3D plugin_find_qpp_cb(ctx, cb_name); + if (!cb) { + error_report("Cannot register a function to run on callback %s in " + "plugin %s as that callback does not exist", + cb_name, target_plugin); + return false; + } + + if (cb->counter =3D=3D QEMU_PLUGIN_EV_MAX) { + error_report("The maximum number of allowed callbacks are already " + "registered for callback %s in plugin %s", + cb_name, target_plugin); + return false; + } + + cb->registered_cb_funcs[cb->counter] =3D function_pointer; + cb->counter++; + return true; +} + +bool qemu_plugin_unreg_callback(const char *target_plugin, const char *cb_= name, + cb_func_t function_pointer) { + struct qemu_plugin_ctx *ctx =3D plugin_name_to_ctx_locked(target_plugi= n); + if (ctx =3D=3D NULL) { + error_report("Cannot remove callback function from unknown plugin = %s", + target_plugin); + return false; + } + + struct qemu_plugin_qpp_cb *cb =3D plugin_find_qpp_cb(ctx, cb_name); + if (!cb) { + error_report("Cannot remove a function to run on callback %s in " + "plugin %s as that callback does not exist", + cb_name, target_plugin); + return false; + } + + for (int i =3D 0; i < cb->counter; i++) { + if (cb->registered_cb_funcs[i] =3D=3D function_pointer) { + for (int j =3D i + 1; j < cb->counter; j++) { + cb->registered_cb_funcs[i] =3D cb->registered_cb_funcs[j]; + i++; + } + cb->registered_cb_funcs[i] =3D NULL; + cb->counter--; + return true; + } + } + error_report("Function to remove not found in registered functions " + "for callback %s in plugin %s", + cb_name, target_plugin); + return false; +} + /* * Binary path, start and end locations */ diff --git a/plugins/loader.c b/plugins/loader.c index ab01d0753c..7f047ebc99 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -310,6 +310,7 @@ void plugin_add_qpp_cb(struct qemu_plugin_ctx *ctx, con= st char *name) new_cb =3D qemu_memalign(qemu_dcache_linesize, sizeof(*new_cb)); memset(new_cb, 0, sizeof(*new_cb)); new_cb->name =3D name; + new_cb->counter =3D 0; QTAILQ_INSERT_TAIL(&ctx->qpp_cbs, new_cb, entry); } =20 diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 71f6c90549..b7013980cf 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -3,6 +3,10 @@ qemu_plugin_end_code; qemu_plugin_entry_code; qemu_plugin_get_hwaddr; + qemu_plugin_create_callback; + qemu_plugin_run_callback; + qemu_plugin_reg_callback; + qemu_plugin_unreg_callback; qemu_plugin_hwaddr_device_name; qemu_plugin_hwaddr_is_io; qemu_plugin_hwaddr_phys_addr; --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967864; cv=none; d=zohomail.com; s=zohoarc; b=iJrpy5p/3tP6u5OUkROf40tcvMy3F2lPfmrrEDuWnkGvzZZLHCnBRXQN3ao7qZbumm/mGZg4gwj89cPbKErKiLrNoY9YyGCszBl1g3cTllvzYzgK4dxhiQi9Fempbt1xXMewYEGOujvR2HJOUE6DCH2aagCeMDB9yvHahVh82k8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967864; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tHc5D/gEd+UlFFhOqMfSMnRWShH86mwYdoibrKxpBTs=; b=J7JUA+o6e/z09DWxhvXDeHm70THDN3j0YDwfFaHtLbgMSQlNjE6sZYFThA1qP5eBL+1pQwoK1bDEXvah6loKnJ1k/nhrUxFC3Lyfho4FbbGvXKVWBYbF0oPfc02rZkNA2bnv2+EF1hw1UrINJtCPp0qPnBVir1s5Y361vbVfJIU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967864347499.92328257163115; Tue, 13 Dec 2022 13:44:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5D0f-0001WH-Cl; Tue, 13 Dec 2022 16:40:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D0A-0001Jw-7Z for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:51 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D07-0007oW-NO for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:50 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaPD030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967582; bh=tHc5D/gEd+UlFFhOqMfSMnRWShH86mwYdoibrKxpBTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ezx+ujGURbwvVVBtdGxwjlP13BETBFaKcKVkmdvcQnmlizhxN+mteDHg/wXRbY0IZ CLIOLMYqhrWf9DiWQSWGZ5jzxIdsKJSxsalp83Tl6E4gJoCTbxwfasRcPPpUFn0ZWK xrJ4vVV9QIJc2aqcK9htNLvhY6ZLimN6cKrBlAfEVXAeLaclwjlZ2+5FiD9rK/DiEf Q0KbRClRR09scgV4BXDWzpveI3zsF3dkFM00FEUOd73x6Hgt1SkeQQG4xilIbX+TPA ALV55fkS+6cns8jNKlTRIzSmLZGag4OZgZRDw4/ESOboaWhWVP0NvtmhWTGfmXiBV8 UwC6S64vnOhmw== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 6/8] plugins: implement QPP import function Date: Tue, 13 Dec 2022 16:37:55 -0500 Message-Id: <20221213213757.4123265-7-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967865405100003 Content-Type: text/plain; charset="utf-8" From: Elysia Witham Plugins can export functions or import functions from other plugins using their name and the function name. This is also described in . Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano --- include/qemu/qemu-plugin.h | 10 ++++++++++ plugins/api.c | 21 +++++++++++++++++++++ plugins/qemu-plugins.symbols | 1 + 3 files changed, 32 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 4221545015..a0516e9a0e 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -354,6 +354,16 @@ size_t qemu_plugin_tb_n_insns(const struct qemu_plugin= _tb *tb); */ uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); =20 +/** + * qemu_plugin_import_function() - return pointer to a function in another + * plugin + * @plugin: plugin name + * @function: function name + * + * Returns: NULL on failure, function pointer on success + */ +gpointer qemu_plugin_import_function(const char *plugin, const char *funct= ion); + /** * qemu_plugin_create_callback() - create a new cb with given name * @id: unique plugin id diff --git a/plugins/api.c b/plugins/api.c index 1f7ea718dc..a998df6942 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -400,6 +400,27 @@ bool qemu_plugin_bool_parse(const char *name, const ch= ar *value, bool *ret) return name && value && qapi_bool_parse(name, value, ret, NULL); } =20 +/* + * QPP: inter-plugin function resolution and callbacks + */ + +gpointer qemu_plugin_import_function(const char *target_plugin, + const char *function) { + gpointer function_pointer =3D NULL; + struct qemu_plugin_ctx *ctx =3D plugin_name_to_ctx_locked(target_plugi= n); + if (ctx =3D=3D NULL) { + error_report("Unable to load plugin %s by name", target_plugin); + } else if (g_module_symbol(ctx->handle, function, + (gpointer *)&function_pointer)) { + return function_pointer; + } else { + error_report("function: %s not found in plugin: %s", function, + target_plugin); + } + abort(); + return NULL; +} + bool qemu_plugin_create_callback(qemu_plugin_id_t id, const char *cb_name) { struct qemu_plugin_ctx *ctx =3D plugin_id_to_ctx_locked(id); diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index b7013980cf..70a518839d 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -3,6 +3,7 @@ qemu_plugin_end_code; qemu_plugin_entry_code; qemu_plugin_get_hwaddr; + qemu_plugin_import_function; qemu_plugin_create_callback; qemu_plugin_run_callback; qemu_plugin_reg_callback; --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967801; cv=none; d=zohomail.com; s=zohoarc; b=aApBcNKUuVL7n7cfttif61WaMIia9JaUjI5TvxdgMcqQvIMivNQPTFCnxt0lL9pbyxFkpcKnHW0YZiNmw+5z38Nq9nyTId7Jb6I/UspWwJ+bj3UfrNseCKRP6gLaCj+BGXkNRrRP9c0kqqLjTTvf9kYEtmiFTO7rYmMbyd7EVoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967801; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7noylMOefmKqet5bCgbsxpsvO0xxjBERKsJphKKHIj4=; b=LZr75fmZox+euqACBi67uQC2TxRuBF02j+SVDGK+WCHphonVOXWGszJfHIu/pBh/rOo2s/2PFPAyo3/N52R9U7Ktvj1sJs7ZmIU8L3Fehg0n9oQ1r8wY3RP8qoS4duyT03LTifEwR88ebziRsL4VhIdVeQ6eD8FwiRAlguXdgmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167096780166632.34999996426836; Tue, 13 Dec 2022 13:43:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5D0S-0001Uf-As; Tue, 13 Dec 2022 16:40:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D0E-0001Oj-Jc for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:58 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D0B-0007vA-1E for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:52 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaPE030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967585; bh=7noylMOefmKqet5bCgbsxpsvO0xxjBERKsJphKKHIj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OUTJE2uhLQiDrzoJ4UTUMMiZw9eWUYWdkAm9KYbguwCIqCUExPZwzDA+I7dGx8IVj NVC32jzmnFia/8zw2zfMOlxjWE8nYykeirECQWIYhqq5p1hRRmrX3lN3I0VErFEwlS nkz/1tx7pAh4Fg8RGLTqibo385LiUwt6rx0dciV4gN+oVw8Np4ME8/TKURLAuQSlp9 qaZFQWwwVqsCT4tquXN6yEhLBKBRz/hJgri8fDE5evmSGBMmEr1sbRN2op16dyFXZQ RHIgiQX5qbHamJz7/giJGrG+1k4lzFEcDEZcVb1EIB+x5FARTgLSDyeNolBnUUuW8R 3VNjAij9+2O+w== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 7/8] include/qemu: added macro for QPP import function Date: Tue, 13 Dec 2022 16:37:56 -0500 Message-Id: <20221213213757.4123265-8-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967803281100003 Content-Type: text/plain; charset="utf-8" From: Elysia Witham Plugins can use this macro in a header file which can be included by both the exporting and importing plugins. The macro will either use qemu_plugin_import_function to import the function or just define it if the plugin is the same one that exports it. If importing a function, "_qpp" will be appended to the end of the function name. Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano --- include/qemu/plugin-qpp.h | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 include/qemu/plugin-qpp.h diff --git a/include/qemu/plugin-qpp.h b/include/qemu/plugin-qpp.h new file mode 100644 index 0000000000..7aea98a14d --- /dev/null +++ b/include/qemu/plugin-qpp.h @@ -0,0 +1,54 @@ +#ifndef PLUGIN_QPP_H +#define PLUGIN_QPP_H + +/* + * Facilities for "Plugin to plugin" (QPP) interactions between tcg plugin= s. + * These allows for direct function calls between loaded plugins. For more + * details see docs/devel/plugin.rst. + */ + + +/* + * Internal macros + */ +#define _PLUGIN_STR(s) #s +#define PLUGIN_STR(s) _PLUGIN_STR(s) +#define _PLUGIN_CONCAT(x, y) x##y +#define PLUGIN_CONCAT(x, y) _PLUGIN_CONCAT(x, y) +#define _QPP_SETUP_NAME(fn) PLUGIN_CONCAT(_qpp_setup_, fn) + +/* + * A header file that defines an exported function should use + * the QPP_FUN_PROTOTYPE macro to create the necessary types. + * + * The generated function named after the output of QPP_SETUP_NAME should + * dynamically resolve a target function in another plugin or raise a fatal + * error on failure. This function has the constructor attribute so it will + * run immediately when the plugin shared object object is loaded. + * + * Note that the variable qemu_plugin_name must be set before this macro is + * used. In other words the plugin that includes a header file with these + * macros should set qemu_plugin_name before including such headers. When = the + * generated function is run it compares the current plugin name to the na= me + * of the plugin that provides the target function. + * + * If the target plugin is not the current plugin it will resolve the func= tion + * pointer from qemu_plugin_import_function, correctly cast it, and assign= the + * function pointer "[function_name]_qpp" which can then be used by the pl= ugin + * that imported it. + */ + +#define QPP_FUN_PROTOTYPE(plugin_name, fn_ret, fn, args) = \ + fn_ret fn(args); = \ + typedef fn_ret(*PLUGIN_CONCAT(fn, _t))(args); = \ + fn##_t fn##_qpp; = \ + void _QPP_SETUP_NAME(fn) (void); = \ + = \ + void __attribute__ ((constructor)) _QPP_SETUP_NAME(fn) (void) { = \ + if (strcmp(qemu_plugin_name, #plugin_name) !=3D 0) { = \ + fn##_qpp =3D (fn##_t)qemu_plugin_import_function( = \ + PLUGIN_STR(plugin_na= me),\ + PLUGIN_STR(fn)); = \ + } = \ + } +#endif /* PLUGIN_QPP_H */ --=20 2.34.1 From nobody Sat May 18 01:13:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mit.edu ARC-Seal: i=1; a=rsa-sha256; t=1670967807; cv=none; d=zohomail.com; s=zohoarc; b=WaDDcBkoVPxVKIvW8klUd2pvORic0/GU4XCwvvOhAWZGkkJYsrTaTmwXjdiOWrZ2uQDEoJ1WNXgQXs7y62sTMGBfYOwglUGszw9qMq0bWZEiXTZLoI1M8gIVrjQxx5RiVxGKsCD7Bjx79mmgnHtJOHVmzF9jFXp7zSqTzYSMigY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967807; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=04+GIoDwHme3ZeKgdIBJSxOVCToSjQdjHcp9Buqf1fc=; b=E+/nHra4aWo3DNoZsjMPq7GK3NyB3LmUk8WZAfId0yr7NuzU/PQs1eV4A3Nm2sT+Mr/M7SUhf7R0v2ouE/YvVqCW0CqudZ2gtm+WDGew6Np1PrD1vxkPlesNj1XL/w6Kn5iBsidvkj7jycdVyZVS5I2Pvh9czKPxtWX7uOJ31Ec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670967807794952.3723067662884; Tue, 13 Dec 2022 13:43:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5D0t-0001eF-3z; Tue, 13 Dec 2022 16:40:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D0G-0001Q0-P9 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:58 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5D0E-00087R-Cf for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:39:56 -0500 Received: from panda194.. ([18.4.85.108]) (authenticated bits=0) (User authenticated as fasano@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2BDLcaPF030603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:39:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1670967587; bh=04+GIoDwHme3ZeKgdIBJSxOVCToSjQdjHcp9Buqf1fc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S6IJkfjOwyTaB2Y8cKNJCEvhuT/6Ag7jo8rFbDLcRnI9JIcNAPaoUgz4++yWQaPEu ZixCixEvW5hzYONvHgC7NQFdHJQNiqT6BYF0pCv+03LzYUOMYej3nspi2dbnj8wpzx WYswxo9U882dXEoqd+lL6ar7DRHoTbw+dsRVWPQWcN+TR8i1Rna5h89wunLiVlPO/i KfpNzl83Ul121/PRjWIH6vdn19824Q9k6nDKvIcFSJSoAfPHhlbi3K80OJrwNRbaG1 PwUGPvjR5hapE0Z8cX0Yqd8jUXu+kU+nyF+mcKldrKOei+uMaC3breY8c8k+b5/ZfC uofFO0V+WAAgw== From: Andrew Fasano To: qemu-devel@nongnu.org Cc: elysia.witham@ll.mit.edu, alex.bennee@linaro.org, erdnaxe@crans.org, ma.mandourr@gmail.com, Andrew Fasano Subject: [PATCH 8/8] tests: build and run QPP tests Date: Tue, 13 Dec 2022 16:37:57 -0500 Message-Id: <20221213213757.4123265-9-fasano@mit.edu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213213757.4123265-1-fasano@mit.edu> References: <20221213213757.4123265-1-fasano@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=18.9.28.11; envelope-from=fasano@mit.edu; helo=outgoing.mit.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mit.edu) X-ZM-MESSAGEID: 1670967809188100003 Content-Type: text/plain; charset="utf-8" From: Elysia Witham These test plugins demonstrate the QPP API changes by exporting and importing functions and creating and registering callbacks. These tests are integrated into the `make check-tcg` tests. Signed-off-by: Elysia Witham Signed-off-by: Andrew Fasano Reviewed-by: Alex Benn=C3=A9e --- tests/Makefile.include | 2 +- tests/meson.build | 1 + tests/plugin_qpp/meson.build | 7 +++++ tests/plugin_qpp/qpp_client.c | 32 ++++++++++++++++++++ tests/plugin_qpp/qpp_srv.c | 37 +++++++++++++++++++++++ tests/plugin_qpp/qpp_srv.h | 12 ++++++++ tests/tcg/Makefile.target | 29 ++++++++++++++++++ tests/tcg/aarch64/Makefile.softmmu-target | 2 ++ tests/tcg/arm/Makefile.softmmu-target | 1 + tests/tcg/arm/Makefile.target | 2 ++ tests/tcg/multiarch/Makefile.target | 2 ++ 11 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 tests/plugin_qpp/meson.build create mode 100644 tests/plugin_qpp/qpp_client.c create mode 100644 tests/plugin_qpp/qpp_srv.c create mode 100644 tests/plugin_qpp/qpp_srv.h diff --git a/tests/Makefile.include b/tests/Makefile.include index 9422ddaece..08dd667aad 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -73,7 +73,7 @@ $(TCG_TESTS_TARGETS:%=3Ddistclean-tcg-tests-%): distclean= -tcg-tests-%: build-tcg: $(BUILD_TCG_TARGET_RULES) =20 .PHONY: check-tcg -.ninja-goals.check-tcg =3D all $(if $(CONFIG_PLUGIN),test-plugins) +.ninja-goals.check-tcg =3D all $(if $(CONFIG_PLUGIN),test-plugins test-plu= gins-qpp) check-tcg: $(RUN_TCG_TARGET_RULES) =20 .PHONY: clean-tcg diff --git a/tests/meson.build b/tests/meson.build index 8e318ec513..12d3ec9c4b 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -86,6 +86,7 @@ endif if get_option('tcg').allowed() if 'CONFIG_PLUGIN' in config_host subdir('plugin') + subdir('plugin_qpp') endif endif =20 diff --git a/tests/plugin_qpp/meson.build b/tests/plugin_qpp/meson.build new file mode 100644 index 0000000000..25555d0ec2 --- /dev/null +++ b/tests/plugin_qpp/meson.build @@ -0,0 +1,7 @@ +t =3D [] +foreach i : ['qpp_srv', 'qpp_client'] + t +=3D shared_module(i, files(i + '.c'), + include_directories: '../../include/qemu', + dependencies: glib) +endforeach +alias_target('test-plugins-qpp', t) diff --git a/tests/plugin_qpp/qpp_client.c b/tests/plugin_qpp/qpp_client.c new file mode 100644 index 0000000000..69b7cc4ac5 --- /dev/null +++ b/tests/plugin_qpp/qpp_client.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "qpp_client"; +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_uses[] =3D {"qpp_srv", NULL}; + +#include "qpp_srv.h" + +void my_cb_exit_callback(gpointer evdata, gpointer udata); + +QEMU_PLUGIN_EXPORT void my_cb_exit_callback(gpointer evdata, gpointer udat= a) +{ + *(bool *)evdata =3D true; + qemu_plugin_outs("called my on exit callback\n"); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int argc, char **argv) { + + g_autoptr(GString) report =3D g_string_new("QPP client: Call " + "qpp_srv's do_add(0) do_sub(3= ) =3D> "); + g_string_append_printf(report, "%d %d\n", qpp_srv_do_add_qpp(0), + qpp_srv_do_sub_qpp(3)); + qemu_plugin_outs(report->str); + qemu_plugin_reg_callback("qpp_srv", "my_on_exit", &my_cb_exit_callback= ); + + return 0; +} + diff --git a/tests/plugin_qpp/qpp_srv.c b/tests/plugin_qpp/qpp_srv.c new file mode 100644 index 0000000000..88b1907a7e --- /dev/null +++ b/tests/plugin_qpp/qpp_srv.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; +QEMU_PLUGIN_EXPORT const char *qemu_plugin_name =3D "qpp_srv"; +#include "qpp_srv.h" + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + qemu_plugin_outs("QPP srv: exit triggered, running all registered" + " QPP callbacks\n"); + bool called =3D false; + qemu_plugin_run_callback(id, "my_on_exit", &called, NULL); + assert(called); +} + +QEMU_PLUGIN_EXPORT int qpp_srv_do_add(int x) +{ + return x + 1; +} + +QEMU_PLUGIN_EXPORT int qpp_srv_do_sub(int x) +{ + return x - 1; +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int argc, char **argv) { + qemu_plugin_outs("qpp_srv loaded\n"); + qemu_plugin_create_callback(id, "my_on_exit"); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/tests/plugin_qpp/qpp_srv.h b/tests/plugin_qpp/qpp_srv.h new file mode 100644 index 0000000000..16d9bc2df4 --- /dev/null +++ b/tests/plugin_qpp/qpp_srv.h @@ -0,0 +1,12 @@ +#ifndef QPP_SRV_H +#define QPP_SRV_H + + +/* + * Prototypes for the do_add and do_sub functions. Both return an int and + * take an int as an argument. + */ +QPP_FUN_PROTOTYPE(qpp_srv, int, qpp_srv_do_add, int); +QPP_FUN_PROTOTYPE(qpp_srv, int, qpp_srv_do_sub, int); + +#endif /* QPP_SRV_H */ diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 75257f2b29..c478f1b2de 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -145,6 +145,9 @@ RUN_TESTS=3D$(patsubst %,run-%, $(TESTS)) ifeq ($(CONFIG_PLUGIN),y) PLUGIN_SRC=3D$(SRC_PATH)/tests/plugin PLUGIN_LIB=3D../../plugin + +PLUGIN_LIB_QPP=3D../../plugin_qpp + VPATH+=3D$(PLUGIN_LIB) PLUGINS=3D$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))) =20 @@ -156,6 +159,11 @@ $(foreach p,$(PLUGINS), \ $(foreach t,$(TESTS),\ $(eval run-plugin-$(t)-with-$(p): $t $p) \ $(eval RUN_TESTS+=3Drun-plugin-$(t)-with-$(p)))) + +$(foreach t,$(TESTS),\ + $(eval run-plugin-qpp-$(t): $t) \ + $(eval RUN_TESTS+=3Drun-plugin-qpp-$(t))) + endif =20 strip-plugin =3D $(wordlist 1, 1, $(subst -with-, ,$1)) @@ -167,18 +175,39 @@ ifeq ($(filter %-softmmu, $(TARGET)),) run-%: % $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<) =20 +run-plugin-qpp-%: + $(call run-test, $@, \ + $(QEMU) \ + -plugin $(PLUGIN_LIB_QPP)/libqpp_srv.so \ + -plugin $(PLUGIN_LIB_QPP)/libqpp_client.so \ + $(call extract-plugin,$@) \ + -d plugin -D $*.pout \ + $(QEMU_OPTS) $<) + run-plugin-%: $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ -d plugin -D $*.pout \ $(call strip-plugin,$<)) + else + run-%: % $(call run-test, $<, \ $(QEMU) -monitor none -display none \ -chardev file$(COMMA)path=3D$<.out$(COMMA)id=3Doutput \ $(QEMU_OPTS) $<) =20 +run-plugin-qpp-%: + $(call run-test, $@, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=3D$@.out$(COMMA)id=3Doutput \ + -plugin $(PLUGIN_LIB_QPP)/libqpp_srv.so \ + -plugin $(PLUGIN_LIB_QPP)/libqpp_client.so \ + $(call extract-plugin,$@) \ + -d plugin -D $*.pout \ + $(QEMU_OPTS) $<) + run-plugin-%: $(call run-test, $@, \ $(QEMU) -monitor none -display none \ diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/= Makefile.softmmu-target index a1368905f5..f87a1a799b 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -45,6 +45,8 @@ QEMU_SEMIHOST=3D-chardev stdio,mux=3Don,id=3Dstdio0 -semi= hosting-config enable=3Don,char run-semiconsole: QEMU_OPTS=3D$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel run-semiconsole: semiconsole $(call skip-test, $<, "MANUAL ONLY") +run-plugin-qpp-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") run-plugin-semiconsole-with-%: semiconsole $(call skip-test, $<, "MANUAL ONLY") =20 diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile= .softmmu-target index 7df88ddea8..f4bfab41bf 100644 --- a/tests/tcg/arm/Makefile.softmmu-target +++ b/tests/tcg/arm/Makefile.softmmu-target @@ -24,3 +24,4 @@ test-armv6m-undef: EXTRA_CFLAGS+=3D-mcpu=3Dcortex-m0 -mfl= oat-abi=3Dsoft =20 run-test-armv6m-undef: QEMU_OPTS+=3D-semihosting -M microbit -kernel run-plugin-test-armv6m-undef-%: QEMU_OPTS+=3D-semihosting -M microbit -ker= nel +run-plugin-qpp-test-armv6m-undef: QEMU_OPTS+=3D-semihosting -M microbit -k= ernel diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index b3b1504a1c..2aa3479952 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -62,6 +62,8 @@ semiconsole-arm: semihosting.c run-semiconsole-arm: semiconsole-arm $(call skip-test, $<, "MANUAL ONLY") =20 +run-plugin-qpp-semiconsole-arm: + $(call skip-test, $<, "MANUAL ONLY") run-plugin-semiconsole-arm-with-%: $(call skip-test, $<, "MANUAL ONLY") =20 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index 5f0fee1aad..a77b30aa94 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -108,6 +108,8 @@ semiconsole: CFLAGS+=3D-I$(SRC_PATH)/tests/tcg/$(TARGET= _NAME) run-semiconsole: semiconsole $(call skip-test, $<, "MANUAL ONLY") =20 +run-plugin-qpp-semiconsole: + $(call skip-test, $<, "MANUAL ONLY") run-plugin-semiconsole-with-%: $(call skip-test, $<, "MANUAL ONLY") =20 --=20 2.34.1