From patchwork Tue Oct 13 00:28:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 11834539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C02B114D5 for ; Tue, 13 Oct 2020 00:30:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 699AE21655 for ; Tue, 13 Oct 2020 00:30:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ePKiuh2D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 699AE21655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:43402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kS8Ca-00017l-SZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Oct 2020 20:30:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kS8B2-0007t2-QQ for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:28 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:44773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kS8B1-0004mc-Bp for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:28 -0400 Received: by mail-pl1-x644.google.com with SMTP id h2so9663135pll.11 for ; Mon, 12 Oct 2020 17:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ChWuKq12YEBlrVQq4Iva9E7cg0lDlX98+uvW3A3EDFU=; b=ePKiuh2D+XewheeHdwXV9LmhBtd20Y3xPfwOWGM2LISqb2jg45l67QdbTVF3uidRCz owTcpdQ4J7x2iI9H7vChqU25E9WJri2oS205Y1ibUJ/Z0/7D6O9bbEBeP5CGfULAJhXD wEla8/UQrHKNPHUzlJXCjCHvaLUUAdD8DPaildb66YvRPes++mvk4KCR1+oDujY0HteH yNsl8Bmjiei8AT6KCxY7TH4p4LOBqOJw0/Kd0qK6D8yCL3uQjyIjjUWECPAGWVZ5tNa+ pG7oCBDKuD8DKSA71PJxNVmcA2zmXTLOrapaVGzhEBe0FtCNUp10Cc8uaUGFkH2s1b+8 swxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ChWuKq12YEBlrVQq4Iva9E7cg0lDlX98+uvW3A3EDFU=; b=Dugcq9z0m+QqzbEJZ4tSoqonG2+jekgjkxqECniPmzhYl3w3fRFbrOQZnxpB1DZwQh uaX4PsyKedHvaVXtk1pYZkV6QDIyix9Tcv8GDSRPEsidGyG2/JgjBvHf7z7tHbazlHal zDzeCQSd0r55x6jG9ZfQk0LIZvOw0xgIo+k8REhsiNT/zLeBUKxeuRgXyda1go/jCMMl 5MSjXu5jMC7InxRs5288J+74rNp5EAb64B3WKkK5DLwGsElSPMWnRzjvLQpLDdPdz7Lk 2rB0mQzL54TARExDrcYdKw/4YblFdjs3FSsffgHvkgdfp5Fk7z5+zbsbMDzAZDov7BaR ufuw== X-Gm-Message-State: AOAM533JeD1J93bSEzxlZg0bHSCosk3CeSoaj/aLq5v2v3+fOqZ+w7Ge nIs80kQvVbnqIbz9fO2o7YhCtKgbbiVLsw== X-Google-Smtp-Source: ABdhPJy1t0/ivvgk17yuXbu22t5/1KW7JJJR2ABog2xXo2sw6uydJgGHyDyIqC6kJE9gxv7O8Y13DQ== X-Received: by 2002:a17:902:8482:b029:d2:6356:82f8 with SMTP id c2-20020a1709028482b02900d2635682f8mr24498904plo.75.1602548904639; Mon, 12 Oct 2020 17:28:24 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y5sm22565925pge.62.2020.10.12.17.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 17:28:23 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v6 1/5] plugins: getting qemu_plugin_get_hwaddr only expose one function prototype Date: Tue, 13 Oct 2020 08:28:02 +0800 Message-Id: <20201013002806.1447-2-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201013002806.1447-1-luoyonggang@gmail.com> References: <20201013002806.1447-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Yonggang Luo , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is used for counting how much function are export to qemu plugin. Signed-off-by: Yonggang Luo Reviewed-by: Alex Bennée --- plugins/api.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/api.c b/plugins/api.c index bbdc5a4eb4..13177d3578 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -251,10 +251,12 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) #ifdef CONFIG_SOFTMMU static __thread struct qemu_plugin_hwaddr hwaddr_info; +#endif struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, uint64_t vaddr) { +#ifdef CONFIG_SOFTMMU CPUState *cpu = current_cpu; unsigned int mmu_idx = info >> TRACE_MEM_MMU_SHIFT; hwaddr_info.is_store = info & TRACE_MEM_ST; @@ -266,14 +268,10 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, } return &hwaddr_info; -} #else -struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, - uint64_t vaddr) -{ return NULL; -} #endif +} bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr) { From patchwork Tue Oct 13 00:28:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 11834541 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50EC592C for ; Tue, 13 Oct 2020 00:30:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDF5E21655 for ; Tue, 13 Oct 2020 00:30:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ee+Q6fhy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDF5E21655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:43636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kS8Cf-0001EB-03 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Oct 2020 20:30:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kS8B4-0007vZ-Jh for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:30 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:36218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kS8B3-0004ml-2c for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:30 -0400 Received: by mail-pf1-x442.google.com with SMTP id b26so15387288pff.3 for ; Mon, 12 Oct 2020 17:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dUzCYJf1zGH8bjxVLC2B7lv4j1gP+ZwtRM63BTbI6Lk=; b=ee+Q6fhybk6tc1EGZlQIY8Bba+F0V5ID852XnSQiPIPJ5ZwfSdseTsb8WeZlLbppY0 JbM7YHPlG5p38WDE/1czhEuF/+dHfWdvPe+9FcOpGusZSFOTcbgvzMMghD1f5CCe66zr nQxtXcuFrqts/pALcePlAh/PUCsSgMZM9VMGAC+0TJRXqy52JoBgQh+5D8LpWoRzAeyC cTfY8ppnGEz74mu363Uku1G0Z5lCz9KDRYkfimpO8qAG2hcgRxSvROkgksLmpCdNeMou +2GTZ9mNTY3TdoDXgH9nKE6dZPIm7kOrYgHDWvCQW1R9VPlrxhctgXDiZ7bGDbiW+60Y d94A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dUzCYJf1zGH8bjxVLC2B7lv4j1gP+ZwtRM63BTbI6Lk=; b=je3Ek7vjfZ3+V3OfOKXIGSnVVGE6ECUOxlaqmZaLp7nPyuL3q2SC4Agx9WzkYb+v+V i0ZT4rqOgkbViSFVPYjnZPJ+oysCvF9H9SM/3qBKg3CtTgakM3LHj0YppnXQ0f+1SO6h +Xd/rF5yJb1GA470scAueH2S/X5BGTkqkgvXkLL5jufK6hWLzLCn26lfbOwenj/FBL1s XCZ/0PbTgmOTsaK56DlFVNZXn3EMZB9hKQOmeXgfSoevIbyzeLaFAu+qUkohmYu2fdLk R7r+KnNOVgHSgEKLuLFumm5FuYpYhuegVEzlwbWlp1cK9Nxuk1VaWvqn5ZooczHvb23c toxA== X-Gm-Message-State: AOAM533Jd1NnkUs5/v9K6yO1ZO7aTmFcSnDymUmr/vcajdpxo13Gbd1o gsLM41NYcDK3E+Bkzjrs9Cghp+lE05kuOQ== X-Google-Smtp-Source: ABdhPJxaVQShyoVOU7Q8W/L5ls40C9zSuJ4Uow8ohe0ob7cl8W1KCSpAT4zchF6UnyRSpIIj8Lf7dg== X-Received: by 2002:a63:4f1b:: with SMTP id d27mr14728227pgb.53.1602548907156; Mon, 12 Oct 2020 17:28:27 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y5sm22565925pge.62.2020.10.12.17.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 17:28:26 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v6 2/5] plugins: Fixes typo in qemu-plugin.h Date: Tue, 13 Oct 2020 08:28:03 +0800 Message-Id: <20201013002806.1447-3-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201013002806.1447-1-luoyonggang@gmail.com> References: <20201013002806.1447-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=luoyonggang@gmail.com; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Yonggang Luo , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Getting the comment consistence with the function name Signed-off-by: Yonggang Luo --- include/qemu/qemu-plugin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index bab8b0d4b3..daac8291b8 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -218,7 +218,7 @@ void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t cb); /** - * qemu_plugin_register_vcpu_tb_trans_exec_cb() - register execution callback + * qemu_plugin_register_vcpu_tb_exec_cb() - register execution callback * @tb: the opaque qemu_plugin_tb handle for the translation * @cb: callback function * @flags: does the plugin read or write the CPU's registers? @@ -236,7 +236,7 @@ enum qemu_plugin_op { }; /** - * qemu_plugin_register_vcpu_tb_trans_exec_inline() - execution inline op + * qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op * @tb: the opaque qemu_plugin_tb handle for the translation * @op: the type of qemu_plugin_op (e.g. ADD_U64) * @ptr: the target memory location for the op From patchwork Tue Oct 13 00:28:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 11834543 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4217592C for ; Tue, 13 Oct 2020 00:30:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C246621655 for ; Tue, 13 Oct 2020 00:30:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a98uxeOg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C246621655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kS8D9-0001bm-Qk for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Oct 2020 20:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kS8B9-00088q-Ni for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:35 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:32910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kS8B6-0004n0-3V for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:35 -0400 Received: by mail-pl1-x62b.google.com with SMTP id b19so9682087pld.0 for ; Mon, 12 Oct 2020 17:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=njq8LwCRNcFNSShSa2dCop+cPHvQa+V3OA16N3iGgms=; b=a98uxeOg91xO3hS0pMf1yGSSx/ZSTOUOB20C5DhhPwAdxcIIyybtYfQlafb6J/SjwX RrYM9g316fH7rEcpgzoJF6H0RzBrKXHmlCy7OQoDxkmp9ksjCwQ0k5c1N2ycDy0IaWs3 srZ+jzyFXtdf1Bp2Vg2KJjd77vEBX+PSAv2iFion9T3c0RElZcJpgKFtw9BnnVnJg/pc ondVvasty4WfC5nBbQE+8M4n9u899XdG/gHjPaulkaHP27F2MkeQmBUXWD6i4P5gpw0Q w/0yezFy0GNcD7C3aTV1oKoVWlWAI7q8uMSVwoL+UBoQvxrPY9GxyehrwBWpbsBM0CZB 4YFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=njq8LwCRNcFNSShSa2dCop+cPHvQa+V3OA16N3iGgms=; b=I1JHbKaHl8EXTNWPmUa6nj5WJVxxHQm9hnk+kWSZo0XoKYkdIHwfBCioFqi69BHgQq CYSTgE4Ux7vtHA8a1zNMhPPYf5LZSMoOWPnX9EsbfiTXpcWvLfDPejWQj3Fi1xoLBE5C IqPIAaNhtKznrbsLum3JtKCAV1iDEzMoMHSqzXaUCo6Wr6wDNEcZWAe1ecM19cPDC8At V4OUXp3Y/Zbp0+KiogjvrbZ/l5Beu6UERoR7bLZIWO7bbFybP+ffVwwLhoScclDos1jO vhYeNVpJ5t290tCqyZVXj7oymh+UfUfOAXpZ3vjZsIK8piXV/LVhDt4LRP9gZ39PPM+Z /Gyg== X-Gm-Message-State: AOAM533bfOUiAvHVMR2kEpVSC6dtfl/4xCIBmKb/hLdcpTIN77jX824p 8qAaf9Xt5nQw6GIADwcfzDU2DNdQgsiNKg== X-Google-Smtp-Source: ABdhPJydNAB9G+qbBJYRlrWWCRK5B7AtyOyZJKizm4HaJJPcJ+g82vQt51QjaL0D1OGdzTNVFMulhw== X-Received: by 2002:a17:902:fe86:b029:d4:d451:eb56 with SMTP id x6-20020a170902fe86b02900d4d451eb56mr9774423plm.79.1602548909794; Mon, 12 Oct 2020 17:28:29 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y5sm22565925pge.62.2020.10.12.17.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 17:28:28 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v6 3/5] plugins: Getting qemu-plugin works under win32. Date: Tue, 13 Oct 2020 08:28:04 +0800 Message-Id: <20201013002806.1447-4-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201013002806.1447-1-luoyonggang@gmail.com> References: <20201013002806.1447-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x62b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Yonggang Luo , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Define QEMU_PLUGIN_API_IMPLEMENTATION in api.c and core.c We removed the need of .symbols file, so is the configure script, if we one expose a function to qemu-plugin just need prefix the function with QEMU_PLUGIN_EXPORT We use QEMU_PLUGIN_EXPORT export the functions in api.c and core.c and loading it in qemu_plugin_initialize, so we need a list of function pointer deceleration such as QEMU_PLUGIN_EXTERN qemu_plugin_uninstall_t qemu_plugin_uninstall; Signed-off-by: Yonggang Luo --- Makefile | 1 - configure | 71 ------------- include/qemu/qemu-plugin.h | 198 +++++++++++++++++++++++++++-------- meson.build | 6 +- plugins/api.c | 105 +++++++++++-------- plugins/core.c | 15 ++- plugins/loader.c | 50 ++++++++- plugins/meson.build | 10 +- plugins/plugin.h | 1 + plugins/qemu-plugins.symbols | 40 ------- 10 files changed, 277 insertions(+), 220 deletions(-) delete mode 100644 plugins/qemu-plugins.symbols diff --git a/Makefile b/Makefile index c37e513431..cd6079bb78 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,6 @@ config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION # Force configure to re-run if the API symbols are updated ifeq ($(CONFIG_PLUGIN),y) -config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols .PHONY: plugins plugins: diff --git a/configure b/configure index 0829b7d3b4..f26212813e 100755 --- a/configure +++ b/configure @@ -5201,61 +5201,6 @@ if compile_prog "" "" ; then atomic64=yes fi -######################################### -# See if --dynamic-list is supported by the linker -ld_dynamic_list="no" -if test "$static" = "no" ; then - cat > $TMPTXT < $TMPC < -void foo(void); - -void foo(void) -{ - printf("foo\n"); -} - -int main(void) -{ - foo(); - return 0; -} -EOF - - if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then - ld_dynamic_list="yes" - fi -fi - -######################################### -# See if -exported_symbols_list is supported by the linker - -ld_exported_symbols_list="no" -if test "$static" = "no" ; then - cat > $TMPTXT <> $config_host_mak - # Copy the export object list to the build dir - if test "$ld_dynamic_list" = "yes" ; then - echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak - ld_symbols=qemu-plugins-ld.symbols - cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols - elif test "$ld_exported_symbols_list" = "yes" ; then - echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak - ld64_symbols=qemu-plugins-ld64.symbols - echo "# Automatically generated by configure - do not modify" > $ld64_symbols - grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \ - sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols - else - error_exit \ - "If \$plugins=yes, either \$ld_dynamic_list or " \ - "\$ld_exported_symbols_list should have been set to 'yes'." - fi fi if test -n "$gdb_bin" ; then diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index daac8291b8..af2f6ccb78 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -21,11 +21,7 @@ * https://gcc.gnu.org/wiki/Visibility */ #if defined _WIN32 || defined __CYGWIN__ - #ifdef BUILDING_DLL - #define QEMU_PLUGIN_EXPORT __declspec(dllexport) - #else - #define QEMU_PLUGIN_EXPORT __declspec(dllimport) - #endif + #define QEMU_PLUGIN_EXPORT __declspec(dllexport) #define QEMU_PLUGIN_LOCAL #else #if __GNUC__ >= 4 @@ -52,7 +48,9 @@ typedef uint64_t qemu_plugin_id_t; extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; -#define QEMU_PLUGIN_VERSION 0 +#define QEMU_PLUGIN_VERSION 1 + +typedef void *(*qemu_plugin_global_dlsym_t)(void *context, const char *name); typedef struct { /* string describing architecture */ @@ -73,8 +71,23 @@ typedef struct { int max_vcpus; } system; }; + void *context; + qemu_plugin_global_dlsym_t dlsym; } qemu_info_t; +/** + * qemu_plugin_initialize() - Initialize a plugin before install + * @info: a block describing some details about the guest + * + * All plugins must export this symbol, and in most case using qemu-plugin.h + * provided implementation directly. + * For plugin provide this function, the QEMU_PLUGIN_VERSION should >= 1 + * + * Note: This function only used to loading qemu's exported functions, nothing + * else should doding in this function. + */ +QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info); + /** * qemu_plugin_install() - Install a plugin * @id: this plugin's opaque ID @@ -121,7 +134,7 @@ typedef void (*qemu_plugin_vcpu_udata_cb_t)(unsigned int vcpu_index, * * Note: Calling this function from qemu_plugin_install() is a bug. */ -void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); +typedef void (*qemu_plugin_uninstall_t)(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); /** * qemu_plugin_reset() - Reset a plugin @@ -134,7 +147,7 @@ void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); * Plugins are reset asynchronously, and therefore the given plugin receives * callbacks until @cb is called. */ -void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); +typedef void (*qemu_plugin_reset_t)(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); /** * qemu_plugin_register_vcpu_init_cb() - register a vCPU initialization callback @@ -145,7 +158,7 @@ void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); * * See also: qemu_plugin_register_vcpu_exit_cb() */ -void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_vcpu_init_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); /** @@ -157,7 +170,7 @@ void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, * * See also: qemu_plugin_register_vcpu_init_cb() */ -void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_vcpu_exit_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); /** @@ -167,7 +180,7 @@ void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, * * The @cb function is called every time a vCPU idles. */ -void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_vcpu_idle_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); /** @@ -177,7 +190,7 @@ void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, * * The @cb function is called every time a vCPU resumes execution. */ -void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_vcpu_resume_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); /* @@ -214,7 +227,7 @@ enum qemu_plugin_mem_rw { typedef void (*qemu_plugin_vcpu_tb_trans_cb_t)(qemu_plugin_id_t id, struct qemu_plugin_tb *tb); -void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_vcpu_tb_trans_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t cb); /** @@ -226,7 +239,7 @@ void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, * * The @cb function is called every time a translated unit executes. */ -void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, +typedef void (*qemu_plugin_register_vcpu_tb_exec_cb_t)(struct qemu_plugin_tb *tb, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, void *userdata); @@ -246,7 +259,7 @@ enum qemu_plugin_op { * Useful if you just want to increment a single counter somewhere in * memory. */ -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, +typedef void (*qemu_plugin_register_vcpu_tb_exec_inline_t)(struct qemu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); @@ -259,7 +272,7 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, * * The @cb function is called every time an instruction is executed */ -void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, +typedef void (*qemu_plugin_register_vcpu_insn_exec_cb_t)(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, void *userdata); @@ -275,26 +288,26 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, * Insert an inline op to every time an instruction executes. Useful * if you just want to increment a single counter somewhere in memory. */ -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); +typedef void (*qemu_plugin_register_vcpu_insn_exec_inline_t)( + struct qemu_plugin_insn *insn, enum qemu_plugin_op op, + void *ptr, uint64_t imm); /* * Helpers to query information about the instructions in a block */ -size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb); +typedef size_t (*qemu_plugin_tb_n_insns_t)(const struct qemu_plugin_tb *tb); -uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); +typedef uint64_t (*qemu_plugin_tb_vaddr_t)(const struct qemu_plugin_tb *tb); -struct qemu_plugin_insn * -qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx); +typedef struct qemu_plugin_insn * +(*qemu_plugin_tb_get_insn_t)(const struct qemu_plugin_tb *tb, size_t idx); -const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn); +typedef const void *(*qemu_plugin_insn_data_t)(const struct qemu_plugin_insn *insn); -size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn); +typedef size_t (*qemu_plugin_insn_size_t)(const struct qemu_plugin_insn *insn); -uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn); -void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn); +typedef uint64_t (*qemu_plugin_insn_vaddr_t)(const struct qemu_plugin_insn *insn); +typedef void *(*qemu_plugin_insn_haddr_t)(const struct qemu_plugin_insn *insn); /* * Memory Instrumentation @@ -307,10 +320,10 @@ typedef uint32_t qemu_plugin_meminfo_t; struct qemu_plugin_hwaddr; /* meminfo queries */ -unsigned int qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info); -bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info); -bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); -bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); +typedef unsigned int (*qemu_plugin_mem_size_shift_t)(qemu_plugin_meminfo_t info); +typedef bool (*qemu_plugin_mem_is_sign_extended_t)(qemu_plugin_meminfo_t info); +typedef bool (*qemu_plugin_mem_is_big_endian_t)(qemu_plugin_meminfo_t info); +typedef bool (*qemu_plugin_mem_is_store_t)(qemu_plugin_meminfo_t info); /* * qemu_plugin_get_hwaddr(): @@ -324,7 +337,7 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); * information about the handle should be recovered before the * callback returns. */ -struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, +typedef struct qemu_plugin_hwaddr *(*qemu_plugin_get_hwaddr_t)(qemu_plugin_meminfo_t info, uint64_t vaddr); /* @@ -332,21 +345,22 @@ 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(const struct qemu_plugin_hwaddr *haddr); -uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr); +typedef bool (*qemu_plugin_hwaddr_is_io_t)(const struct qemu_plugin_hwaddr *haddr); +typedef uint64_t (*qemu_plugin_hwaddr_device_offset_t)( + const struct qemu_plugin_hwaddr *haddr); typedef void (*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index, qemu_plugin_meminfo_t info, uint64_t vaddr, void *userdata); -void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, +typedef void (*qemu_plugin_register_vcpu_mem_cb_t)(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_mem_cb_t cb, enum qemu_plugin_cb_flags flags, enum qemu_plugin_mem_rw rw, void *userdata); -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, +typedef void (*qemu_plugin_register_vcpu_mem_inline_t)(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, void *ptr, uint64_t imm); @@ -359,15 +373,15 @@ typedef void uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8); -void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_vcpu_syscall_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_cb_t cb); typedef void (*qemu_plugin_vcpu_syscall_ret_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_idx, int64_t num, int64_t ret); -void -qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, +typedef void +(*qemu_plugin_register_vcpu_syscall_ret_cb_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_ret_cb_t cb); @@ -378,7 +392,7 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, * Returns an allocated string containing the disassembly */ -char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn); +typedef char *(*qemu_plugin_insn_disas_t)(const struct qemu_plugin_insn *insn); /** * qemu_plugin_vcpu_for_each() - iterate over the existing vCPU @@ -389,25 +403,117 @@ char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn); * * See also: qemu_plugin_register_vcpu_init_cb() */ -void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, +typedef void (*qemu_plugin_vcpu_for_each_t)(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); -void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_flush_cb_t)(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); -void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, +typedef void (*qemu_plugin_register_atexit_cb_t)(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb, void *userdata); /* returns -1 in user-mode */ -int qemu_plugin_n_vcpus(void); +typedef int (*qemu_plugin_n_vcpus_t)(void); /* returns -1 in user-mode */ -int qemu_plugin_n_max_vcpus(void); +typedef int (*qemu_plugin_n_max_vcpus_t)(void); /** * qemu_plugin_outs() - output string via QEMU's logging system * @string: a string */ -void qemu_plugin_outs(const char *string); +typedef void (*qemu_plugin_outs_t)(const char *string); + +#if !defined(QEMU_PLUGIN_API_IMPLEMENTATION) + +#define qemu_plugin_decl_symbol(symbol_name) symbol_name##_t symbol_name + +#define qemu_plugin_load_symbol(info, symbol_name) do {\ + symbol_name = info->dlsym(info->context, #symbol_name); \ + if (NULL == symbol_name) { \ + return -1; \ + } \ +} while (0) + +qemu_plugin_decl_symbol(qemu_plugin_uninstall); +qemu_plugin_decl_symbol(qemu_plugin_reset); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_init_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_exit_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_idle_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_resume_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_tb_trans_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_tb_exec_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_tb_exec_inline); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_insn_exec_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_insn_exec_inline); +qemu_plugin_decl_symbol(qemu_plugin_tb_n_insns); +qemu_plugin_decl_symbol(qemu_plugin_tb_vaddr); +qemu_plugin_decl_symbol(qemu_plugin_tb_get_insn); +qemu_plugin_decl_symbol(qemu_plugin_insn_data); +qemu_plugin_decl_symbol(qemu_plugin_insn_size); +qemu_plugin_decl_symbol(qemu_plugin_insn_vaddr); +qemu_plugin_decl_symbol(qemu_plugin_insn_haddr); +qemu_plugin_decl_symbol(qemu_plugin_mem_size_shift); +qemu_plugin_decl_symbol(qemu_plugin_mem_is_sign_extended); +qemu_plugin_decl_symbol(qemu_plugin_mem_is_big_endian); +qemu_plugin_decl_symbol(qemu_plugin_mem_is_store); +qemu_plugin_decl_symbol(qemu_plugin_get_hwaddr); +qemu_plugin_decl_symbol(qemu_plugin_hwaddr_is_io); +qemu_plugin_decl_symbol(qemu_plugin_hwaddr_device_offset); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_mem_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_mem_inline); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_syscall_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_vcpu_syscall_ret_cb); +qemu_plugin_decl_symbol(qemu_plugin_insn_disas); +qemu_plugin_decl_symbol(qemu_plugin_vcpu_for_each); +qemu_plugin_decl_symbol(qemu_plugin_register_flush_cb); +qemu_plugin_decl_symbol(qemu_plugin_register_atexit_cb); +qemu_plugin_decl_symbol(qemu_plugin_n_vcpus); +qemu_plugin_decl_symbol(qemu_plugin_n_max_vcpus); +qemu_plugin_decl_symbol(qemu_plugin_outs); + +QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info) +{ + qemu_plugin_load_symbol(info, qemu_plugin_uninstall); + qemu_plugin_load_symbol(info, qemu_plugin_reset); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_init_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_exit_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_idle_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_resume_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_tb_trans_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_tb_exec_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_tb_exec_inline); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_insn_exec_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_insn_exec_inline); + qemu_plugin_load_symbol(info, qemu_plugin_tb_n_insns); + qemu_plugin_load_symbol(info, qemu_plugin_tb_vaddr); + qemu_plugin_load_symbol(info, qemu_plugin_tb_get_insn); + qemu_plugin_load_symbol(info, qemu_plugin_insn_data); + qemu_plugin_load_symbol(info, qemu_plugin_insn_size); + qemu_plugin_load_symbol(info, qemu_plugin_insn_vaddr); + qemu_plugin_load_symbol(info, qemu_plugin_insn_haddr); + qemu_plugin_load_symbol(info, qemu_plugin_mem_size_shift); + qemu_plugin_load_symbol(info, qemu_plugin_mem_is_sign_extended); + qemu_plugin_load_symbol(info, qemu_plugin_mem_is_big_endian); + qemu_plugin_load_symbol(info, qemu_plugin_mem_is_store); + qemu_plugin_load_symbol(info, qemu_plugin_get_hwaddr); + qemu_plugin_load_symbol(info, qemu_plugin_hwaddr_is_io); + qemu_plugin_load_symbol(info, qemu_plugin_hwaddr_device_offset); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_mem_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_mem_inline); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_syscall_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_vcpu_syscall_ret_cb); + qemu_plugin_load_symbol(info, qemu_plugin_insn_disas); + qemu_plugin_load_symbol(info, qemu_plugin_vcpu_for_each); + qemu_plugin_load_symbol(info, qemu_plugin_register_flush_cb); + qemu_plugin_load_symbol(info, qemu_plugin_register_atexit_cb); + qemu_plugin_load_symbol(info, qemu_plugin_n_vcpus); + qemu_plugin_load_symbol(info, qemu_plugin_n_max_vcpus); + qemu_plugin_load_symbol(info, qemu_plugin_outs); + return 0; +} + +#endif /* QEMU_PLUGIN_API_IMPLEMENTATION */ + #endif /* QEMU_PLUGIN_API_H */ diff --git a/meson.build b/meson.build index 8ad600a91a..4c073f5460 100644 --- a/meson.build +++ b/meson.build @@ -326,7 +326,11 @@ endif rt = cc.find_library('rt', required: false) libdl = not_found if 'CONFIG_PLUGIN' in config_host - libdl = cc.find_library('dl', required: true) + if targetos == 'windows' + libdl = declare_dependency(compile_args: [], link_args: []) + else + libdl = cc.find_library('dl', required: true) + endif endif libiscsi = not_found if 'CONFIG_LIBISCSI' in config_host diff --git a/plugins/api.c b/plugins/api.c index 13177d3578..9964b8bdc7 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -35,6 +35,7 @@ */ #include "qemu/osdep.h" +#define QEMU_PLUGIN_API_IMPLEMENTATION #include "qemu/plugin.h" #include "cpu.h" #include "sysemu/sysemu.h" @@ -48,14 +49,18 @@ #endif #include "trace/mem.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-prototypes" + /* Uninstall and Reset handlers */ -void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) +QEMU_PLUGIN_EXPORT void qemu_plugin_uninstall( + qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { plugin_reset_uninstall(id, cb, false); } -void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) +QEMU_PLUGIN_EXPORT void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { plugin_reset_uninstall(id, cb, true); } @@ -67,19 +72,19 @@ void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) * during the translation. */ -void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INIT, cb); } -void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXIT, cb); } -void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, void *udata) @@ -88,25 +93,28 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, cb, flags, udata); } -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_tb_exec_inline( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) { plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, imm); } -void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, - qemu_plugin_vcpu_udata_cb_t cb, - enum qemu_plugin_cb_flags flags, - void *udata) +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_insn_exec_cb( + struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *udata) { plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], cb, flags, udata); } -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_insn_exec_inline( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], 0, op, ptr, imm); @@ -114,38 +122,40 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, -void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, - qemu_plugin_vcpu_mem_cb_t cb, - enum qemu_plugin_cb_flags flags, - enum qemu_plugin_mem_rw rw, - void *udata) +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_mem_cb( + struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], cb, flags, rw, udata); } -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm) +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_mem_inline( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm) { plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], rw, op, ptr, imm); } -void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_TB_TRANS, cb); } -void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb); } -void +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_ret_cb_t cb) { @@ -168,17 +178,17 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, * each translated instruction. */ -size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb) +QEMU_PLUGIN_EXPORT size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb) { return tb->n; } -uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb) +QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb) { return tb->vaddr; } -struct qemu_plugin_insn * +QEMU_PLUGIN_EXPORT struct qemu_plugin_insn * qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx) { if (unlikely(idx >= tb->n)) { @@ -194,27 +204,27 @@ qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx) * instruction being translated. */ -const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn) +QEMU_PLUGIN_EXPORT const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn) { return insn->data->data; } -size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn) +QEMU_PLUGIN_EXPORT size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn) { return insn->data->len; } -uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn) +QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn) { return insn->vaddr; } -void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn) +QEMU_PLUGIN_EXPORT void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn) { return insn->haddr; } -char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn) +QEMU_PLUGIN_EXPORT char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn) { CPUState *cpu = current_cpu; return plugin_disas(cpu, insn->vaddr, insn->data->len); @@ -225,22 +235,22 @@ char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn) * memory access. */ -unsigned qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info) +QEMU_PLUGIN_EXPORT unsigned qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info) { return info & TRACE_MEM_SZ_SHIFT_MASK; } -bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info) +QEMU_PLUGIN_EXPORT bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info) { return !!(info & TRACE_MEM_SE); } -bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info) +QEMU_PLUGIN_EXPORT bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info) { return !!(info & TRACE_MEM_BE); } -bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) +QEMU_PLUGIN_EXPORT bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) { return !!(info & TRACE_MEM_ST); } @@ -253,8 +263,8 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) static __thread struct qemu_plugin_hwaddr hwaddr_info; #endif -struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, - uint64_t vaddr) +QEMU_PLUGIN_EXPORT struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr( + qemu_plugin_meminfo_t info, uint64_t vaddr) { #ifdef CONFIG_SOFTMMU CPUState *cpu = current_cpu; @@ -273,7 +283,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, #endif } -bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr) +QEMU_PLUGIN_EXPORT bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr) { #ifdef CONFIG_SOFTMMU return haddr->is_io; @@ -282,7 +292,8 @@ bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr) #endif } -uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr) +QEMU_PLUGIN_EXPORT uint64_t qemu_plugin_hwaddr_device_offset( + const struct qemu_plugin_hwaddr *haddr) { #ifdef CONFIG_SOFTMMU if (haddr) { @@ -313,7 +324,7 @@ static MachineState * get_ms(void) } #endif -int qemu_plugin_n_vcpus(void) +QEMU_PLUGIN_EXPORT int qemu_plugin_n_vcpus(void) { #ifdef CONFIG_USER_ONLY return -1; @@ -322,7 +333,7 @@ int qemu_plugin_n_vcpus(void) #endif } -int qemu_plugin_n_max_vcpus(void) +QEMU_PLUGIN_EXPORT int qemu_plugin_n_max_vcpus(void) { #ifdef CONFIG_USER_ONLY return -1; @@ -334,7 +345,9 @@ int qemu_plugin_n_max_vcpus(void) /* * Plugin output */ -void qemu_plugin_outs(const char *string) +QEMU_PLUGIN_EXPORT void qemu_plugin_outs(const char *string) { qemu_log_mask(CPU_LOG_PLUGIN, "%s", string); } + +#pragma GCC diagnostic pop diff --git a/plugins/core.c b/plugins/core.c index 51bfc94787..3df3e7d9af 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -32,6 +32,9 @@ #include "trace/mem-internal.h" /* mem_info macros */ #include "plugin.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-prototypes" + struct qemu_plugin_cb { struct qemu_plugin_ctx *ctx; union qemu_plugin_cb_sig f; @@ -233,7 +236,7 @@ static void plugin_vcpu_for_each(gpointer k, gpointer v, gpointer udata) args->cb(args->ctx->id, cpu_index); } -void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { struct plugin_for_each_args args; @@ -384,19 +387,19 @@ void qemu_plugin_vcpu_resume_cb(CPUState *cpu) plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); } -void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_IDLE, cb); } -void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb); } -void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { plugin_register_cb(id, QEMU_PLUGIN_EV_FLUSH, cb); @@ -463,7 +466,7 @@ void qemu_plugin_atexit_cb(void) plugin_cb__udata(QEMU_PLUGIN_EV_ATEXIT); } -void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, +QEMU_PLUGIN_EXPORT void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb, void *udata) { @@ -500,3 +503,5 @@ static void __attribute__((__constructor__)) plugin_init(void) QHT_MODE_AUTO_RESIZE); atexit(qemu_plugin_atexit_cb); } + +#pragma GCC diagnostic pop diff --git a/plugins/loader.c b/plugins/loader.c index 8ac5dbc20f..38e050ff9b 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -63,6 +63,7 @@ QemuOptsList qemu_plugin_opts = { }, }; +typedef int (*qemu_plugin_initialize_func_t)(const qemu_info_t *); typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, const qemu_info_t *, int, char **); extern struct qemu_plugin_state plugin; @@ -152,10 +153,12 @@ static uint64_t xorshift64star(uint64_t x) static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info) { + qemu_plugin_initialize_func_t initialize = NULL; qemu_plugin_install_func_t install; struct qemu_plugin_ctx *ctx; gpointer sym; int rc; + int version = -1; ctx = qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx)); @@ -184,7 +187,7 @@ static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info) desc->path, g_module_error()); goto err_symbol; } else { - int version = *(int *)sym; + version = *(int *)sym; if (version < QEMU_PLUGIN_MIN_VERSION) { error_report("TCG plugin %s requires API version %d, but " "this QEMU supports only a minimum version of %d", @@ -198,6 +201,21 @@ static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info) } } + if (version >= QEMU_PLUGIN_VERSION_1) { + /* This version should call to qemu_plugin_initialize first */ + if (!g_module_symbol(ctx->handle, "qemu_plugin_initialize", &sym)) { + error_report("%s: %s", __func__, g_module_error()); + goto err_symbol; + } + initialize = (qemu_plugin_initialize_func_t) sym; + /* symbol was found; it could be NULL though */ + if (initialize == NULL) { + error_report("%s: %s: qemu_plugin_initialize is NULL", + __func__, desc->path); + goto err_symbol; + } + } + qemu_rec_mutex_lock(&plugin.lock); /* find an unused random id with &ctx as the seed */ @@ -216,6 +234,16 @@ static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info) } } QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); + if (initialize != NULL) { + rc = initialize(info); + if (rc) { + error_report("%s: qemu_plugin_initialize returned error code %d", + __func__, rc); + /* qemu_plugin_initialize only loading function symbols */ + goto err_symbol; + } + } + ctx->installing = true; rc = install(ctx->id, info, desc->argc, desc->argv); ctx->installing = false; @@ -254,6 +282,17 @@ static void plugin_desc_free(struct qemu_plugin_desc *desc) g_free(desc); } +static void *qemu_plugin_global_dlsym(void* context, const char *name) +{ + GModule *global_handle = context; + gpointer sym = NULL; + if (!g_module_symbol(global_handle, name, &sym)) { + error_report("%s: %s", __func__, g_module_error()); + return NULL; + } + return sym; +} + /** * qemu_plugin_load_list - load a list of plugins * @head: head of the list of descriptors of the plugins to be loaded @@ -267,6 +306,7 @@ int qemu_plugin_load_list(QemuPluginList *head) { struct qemu_plugin_desc *desc, *next; g_autofree qemu_info_t *info = g_new0(qemu_info_t, 1); + GModule *global_handle = NULL; info->target_name = TARGET_NAME; info->version.min = QEMU_PLUGIN_MIN_VERSION; @@ -276,6 +316,12 @@ int qemu_plugin_load_list(QemuPluginList *head) info->system_emulation = true; info->system.smp_vcpus = ms->smp.cpus; info->system.max_vcpus = ms->smp.max_cpus; + global_handle = g_module_open(NULL, G_MODULE_BIND_LOCAL); + if (global_handle == NULL) { + goto err_dlopen; + } + info->dlsym = qemu_plugin_global_dlsym; + info->context = (void *)global_handle; #else info->system_emulation = false; #endif @@ -289,6 +335,8 @@ int qemu_plugin_load_list(QemuPluginList *head) } QTAILQ_REMOVE(head, desc, entry); } + +err_dlopen: return 0; } diff --git a/plugins/meson.build b/plugins/meson.build index e77723010e..b48d2046ff 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -1,13 +1,5 @@ -if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host - plugin_ldflags = ['-Wl,--dynamic-list=' + (meson.build_root() / 'qemu-plugins-ld.symbols')] -elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host - plugin_ldflags = ['-Wl,-exported_symbols_list,' + (meson.build_root() / 'qemu-plugins-ld64.symbols')] -else - plugin_ldflags = [] -endif - specific_ss.add(when: 'CONFIG_PLUGIN', if_true: [files( 'loader.c', 'core.c', 'api.c', -), declare_dependency(link_args: plugin_ldflags)]) +), declare_dependency(link_args: [], compile_args: [])]) diff --git a/plugins/plugin.h b/plugins/plugin.h index 1aa29dcadd..406f246a72 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -15,6 +15,7 @@ #include #define QEMU_PLUGIN_MIN_VERSION 0 +#define QEMU_PLUGIN_VERSION_1 1 /* global state */ struct qemu_plugin_state { diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols deleted file mode 100644 index 4bdb381f48..0000000000 --- a/plugins/qemu-plugins.symbols +++ /dev/null @@ -1,40 +0,0 @@ -{ - qemu_plugin_uninstall; - qemu_plugin_reset; - qemu_plugin_register_vcpu_init_cb; - qemu_plugin_register_vcpu_exit_cb; - qemu_plugin_register_vcpu_idle_cb; - qemu_plugin_register_vcpu_resume_cb; - qemu_plugin_register_vcpu_insn_exec_cb; - qemu_plugin_register_vcpu_insn_exec_inline; - qemu_plugin_register_vcpu_mem_cb; - qemu_plugin_register_vcpu_mem_haddr_cb; - qemu_plugin_register_vcpu_mem_inline; - qemu_plugin_ram_addr_from_host; - qemu_plugin_register_vcpu_tb_trans_cb; - qemu_plugin_register_vcpu_tb_exec_cb; - qemu_plugin_register_vcpu_tb_exec_inline; - qemu_plugin_register_flush_cb; - qemu_plugin_register_vcpu_syscall_cb; - qemu_plugin_register_vcpu_syscall_ret_cb; - qemu_plugin_register_atexit_cb; - qemu_plugin_tb_n_insns; - qemu_plugin_tb_get_insn; - qemu_plugin_tb_vaddr; - qemu_plugin_insn_data; - qemu_plugin_insn_size; - qemu_plugin_insn_vaddr; - qemu_plugin_insn_haddr; - qemu_plugin_insn_disas; - qemu_plugin_mem_size_shift; - qemu_plugin_mem_is_sign_extended; - qemu_plugin_mem_is_big_endian; - qemu_plugin_mem_is_store; - qemu_plugin_get_hwaddr; - qemu_plugin_hwaddr_is_io; - qemu_plugin_hwaddr_to_raddr; - qemu_plugin_vcpu_for_each; - qemu_plugin_n_vcpus; - qemu_plugin_n_max_vcpus; - qemu_plugin_outs; -}; From patchwork Tue Oct 13 00:28:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 11834565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06F4E14D5 for ; Tue, 13 Oct 2020 00:33:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3ED1206B5 for ; Tue, 13 Oct 2020 00:33:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QmVfaBHb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3ED1206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:50180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kS8Fz-00043g-Ci for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Oct 2020 20:33:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kS8BA-00089m-3h for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:36 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:44954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kS8B8-0004n5-7I for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:35 -0400 Received: by mail-pl1-x634.google.com with SMTP id h2so9663284pll.11 for ; Mon, 12 Oct 2020 17:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6EEWtf959v7hUyUxi3MVaZ6cv8vfOrUV9fQH+OQchcM=; b=QmVfaBHbdibNYWTsXW5fn9cmR8+8VSx3RISHjy/0KvrDXhLPonSjFVYVs7yAIFRD0U e2rkzkJ4pA97d+y6zP6paTbdfA7Ya+OeXCsx1S1t5SUAo8jwSo224GkLXEzs7JKwhhHm 6ikb0+pYXW/Sa6mzQXnwScQbY09grbbeAI0Fo+U9S57aP0IiFGditfqeoBtlclsu65LR N2tBun9OYoximlBeNAmfKs7SIgthBKkOu0I3zcGbJBRdkA0NgNItEhoNiMMuiXdE5h3M ChILpG8yZAYLP3CcxQ+41/rAMM78EAre6KuHwnFdftvPwRURIOLbuiqHo9KGslo/T3yf 3L2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6EEWtf959v7hUyUxi3MVaZ6cv8vfOrUV9fQH+OQchcM=; b=dy5C85Ogr1GGQFxI1XvSbjU/tvY8qzNvwS0yQmvlOntX7aguLxZ5pNdcgqdfZmPWEd buPUXrR5hPQddkDXQpvzfLfa938/c7g9sBIJGHDCUGD3DiacuNuMhacVaQLsO6Wqg8iV zbfe9S5CHQai90shbgCzO2tFJc815RHaPnz3sVeJO82DumGdxKvLIB7QX0744XOTD2eN 3rx6V1uX98K7+0UedYW0ZuUHW10W4YQhzFk/YKxV0J0os55o1SFkw45wCvrYOfFbRPkk R2gV1Me4k3Y36GM6HllPMfuslIaf92HMG1v8ckxdHeIhnvDuBhzuyJ4DJApnaGrGe7Gr kZNg== X-Gm-Message-State: AOAM531teJ4C5xSyXGQDxrFB+v0Be/DhIjaMDnlLWrS0VlHNYm1k6Duq otvyP/1957ly0q1jEXNM5caIjQjjUKqB6g== X-Google-Smtp-Source: ABdhPJy/IQFDqlIEDsCgXhRr3uXj80AfmZaBhVPbynymGr05VNHJ9vvuvJXyQxaq93cVqX551pQdpg== X-Received: by 2002:a17:902:aa94:b029:d3:b593:2736 with SMTP id d20-20020a170902aa94b02900d3b5932736mr25905862plr.57.1602548912361; Mon, 12 Oct 2020 17:28:32 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y5sm22565925pge.62.2020.10.12.17.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 17:28:31 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v6 4/5] plugins: Getting qemu-plugin.h can be included in multiple source file Date: Tue, 13 Oct 2020 08:28:05 +0800 Message-Id: <20201013002806.1447-5-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201013002806.1447-1-luoyonggang@gmail.com> References: <20201013002806.1447-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x634.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Yonggang Luo , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" If we only have a single .c file in a plugin, then define QEMU_PLUGIN_EXTERN to empty is OK, but if we have multiple .c files in a plugin, then we need distinguish the implementation and the deceleration. only the main .c file should define the macro QEMU_PLUGIN_IMPLEMENTATION other sources are user and should use extern Signed-off-by: Yonggang Luo --- contrib/plugins/hotblocks.c | 1 + contrib/plugins/hotpages.c | 1 + contrib/plugins/howvec.c | 1 + contrib/plugins/lockstep.c | 1 + include/qemu/qemu-plugin.h | 6 ++++++ plugins/core.c | 1 + tests/plugin/bb.c | 1 + tests/plugin/empty.c | 1 + tests/plugin/insn.c | 1 + tests/plugin/mem.c | 1 + 10 files changed, 15 insertions(+) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 37435a3fc7..39e77d2980 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -13,6 +13,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/contrib/plugins/hotpages.c b/contrib/plugins/hotpages.c index ecd6c18732..1ae3f44aed 100644 --- a/contrib/plugins/hotpages.c +++ b/contrib/plugins/hotpages.c @@ -16,6 +16,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 3b9a6939f2..db1b4e5780 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -18,6 +18,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index a696673dff..7173b2910d 100644 --- a/contrib/plugins/lockstep.c +++ b/contrib/plugins/lockstep.c @@ -31,6 +31,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index af2f6ccb78..a6ebb295de 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -426,7 +426,11 @@ typedef void (*qemu_plugin_outs_t)(const char *string); #if !defined(QEMU_PLUGIN_API_IMPLEMENTATION) +#if defined(QEMU_PLUGIN_IMPLEMENTATION) #define qemu_plugin_decl_symbol(symbol_name) symbol_name##_t symbol_name +#else +#define qemu_plugin_decl_symbol(symbol_name) extern symbol_name##_t symbol_name +#endif #define qemu_plugin_load_symbol(info, symbol_name) do {\ symbol_name = info->dlsym(info->context, #symbol_name); \ @@ -472,6 +476,7 @@ qemu_plugin_decl_symbol(qemu_plugin_n_vcpus); qemu_plugin_decl_symbol(qemu_plugin_n_max_vcpus); qemu_plugin_decl_symbol(qemu_plugin_outs); +#if defined(QEMU_PLUGIN_IMPLEMENTATION) QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info) { qemu_plugin_load_symbol(info, qemu_plugin_uninstall); @@ -512,6 +517,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info) qemu_plugin_load_symbol(info, qemu_plugin_outs); return 0; } +#endif /* QEMU_PLUGIN_IMPLEMENTATION */ #endif /* QEMU_PLUGIN_API_IMPLEMENTATION */ diff --git a/plugins/core.c b/plugins/core.c index 3df3e7d9af..dd1ec7b3fc 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -12,6 +12,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "qemu/osdep.h" +#define QEMU_PLUGIN_API_IMPLEMENTATION #include "qemu/error-report.h" #include "qemu/config-file.h" #include "qapi/error.h" diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index de09bdde4e..cda3fbdde9 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -12,6 +12,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/tests/plugin/empty.c b/tests/plugin/empty.c index 8fa6bacd93..0c3adf7aa0 100644 --- a/tests/plugin/empty.c +++ b/tests/plugin/empty.c @@ -11,6 +11,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index a9a6e41237..bf86fdafe6 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -12,6 +12,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 4725bd851d..f39be9c969 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -12,6 +12,7 @@ #include #include +#define QEMU_PLUGIN_IMPLEMENTATION #include QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; From patchwork Tue Oct 13 00:28:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 11834615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 070E392C for ; Tue, 13 Oct 2020 00:35:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DA8721655 for ; Tue, 13 Oct 2020 00:35:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n9Fl8MIt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DA8721655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kS8I9-0005Tu-9D for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Oct 2020 20:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kS8BC-0008GA-Tq for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:38 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kS8BA-0004nD-GQ for qemu-devel@nongnu.org; Mon, 12 Oct 2020 20:28:38 -0400 Received: by mail-pg1-x536.google.com with SMTP id y14so16107643pgf.12 for ; Mon, 12 Oct 2020 17:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GMFUUawRaQBbY91Y4UXpQaHmWWpu/P1MsSjv1nTQRvk=; b=n9Fl8MIttTAkPMnVx+8EJtpoekhKSYyI9CyaZYspLnoC5b0nNKmA6kQjB5FnP8Tts8 EJaC1aRN9xD7BpY1DMo4z7EagaJF8lAdL4GLL461RKn3ms+u8sjjN9ahdoEf69WDBZJf oee1XsAD2b+jnrSTPGQUfU59gtkNILihJ1mKxyg/jWI4QtsEy3iGB+ppCHICTb25GlRr pAKIA9fXUMKurjV4+efsghBgMQlABVCikAnMsasQzG6gjFCmQ6kJom0OrGK1cdBMbQ+p bTiTi8wG42G+T5/pyz3IFG5mqfBNVa+orxQBcylD7Kz3Rbswn57s+ZRLGmgz7btWO3Vf gHXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GMFUUawRaQBbY91Y4UXpQaHmWWpu/P1MsSjv1nTQRvk=; b=YrcNqHHLjLVAbw8fI7TAclW5AcJBzSo/y8vPjMedwSpu3aRpUCuTpv0ze4HtVH17zv 0odhwYtyEc8554uYwavztl5mlsxo/rk3Lfl4gq//KKNTfOyNfq8Ha3ANokN4nLnKo05K F3SwCwKTmW5h6ECNepBi57q9QLCfxTk+JEnhycR3OFtNGSU5CDUDV3tP284SrHbAFAvD +z1SsVJg/QheH7sHb9KxkgfGfLEn09dwxdOmyUoyKUVGkqCjqLsxWBU0OmNmM3H1Xwwi tWC7CCrjoqju/W0chcxUfXUAGEoPSqo4NshPAa8XV9HhwjFSGOrnrXooXHWDv+CoDdqa thOQ== X-Gm-Message-State: AOAM533PobFvkF7qhGhI+dUP93Ba1ijvDZtL1APHJCMD4Nt0kJDEqf/U 0J7S4cwXV/7XtTXJWKdeFtmt/c8OZWJD8Q== X-Google-Smtp-Source: ABdhPJxhLWDP4qZ8mDa5TuV4GgZjle/RN6USrpbWnwyxtXNep7gz6NkymZC7dy5Z1K4LdjcdAqjL0A== X-Received: by 2002:a17:90a:c28d:: with SMTP id f13mr21968261pjt.145.1602548914807; Mon, 12 Oct 2020 17:28:34 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y5sm22565925pge.62.2020.10.12.17.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 17:28:34 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v6 5/5] cirrus: Enable plugins in cirrus for windows Date: Tue, 13 Oct 2020 08:28:06 +0800 Message-Id: <20201013002806.1447-6-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201013002806.1447-1-luoyonggang@gmail.com> References: <20201013002806.1447-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=luoyonggang@gmail.com; helo=mail-pg1-x536.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Yonggang Luo , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Yonggang Luo --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index 2c6bf45e6d..56ccb25bec 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -129,6 +129,7 @@ windows_msys2_task: script: - C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build" - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure + --enable-plugins --python=python3 --ninja=ninja" - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j8" test_script: