From patchwork Tue Oct 6 12:08:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 303611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33094C4363D for ; Tue, 6 Oct 2020 12:11:43 +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 6B14720663 for ; Tue, 6 Oct 2020 12:11:42 +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="bdAbn5U8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B14720663 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPloj-0004w7-5f for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPln4-0003Ds-Rq for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:09:58 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPln3-0004DA-6z for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:09:58 -0400 Received: by mail-pg1-x543.google.com with SMTP id g9so7364405pgh.8 for ; Tue, 06 Oct 2020 05:09:56 -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=vwWICdvW/zCGPD13s4UEGsuus824XjxUxjGQ4brZjgg=; b=bdAbn5U8O55gv9zt0BgJZGlpIr+TwRiQh1uosXXFEnxNI0lujoYGScM5iNxFwQ/9/f u321hqCbTRFyqWlzHtdovTZu7T6H8fJC8DcjOZZl2tDwoizW/VbsiAL4xcWUzgeQngxA Vw0Yteh9jx7OK8x/e0oCej6/zEQtbuZHVUvBAERKmuSh8z7EZwp31t/wqeb8zRHl7fgS SgC0tf1BdA0UIzgHETLUCc5aD/Z/n8YQcpKYWvG17cxp3LAjxLj+BZFDAxzn8AcqsdSI IyBYnsd0O7uh2TGvOeNK1j29ddfCJ/fVSHec/IM4DOn2rBjc7pFp2LLpyiYWApAO9MIx r1Zg== 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=vwWICdvW/zCGPD13s4UEGsuus824XjxUxjGQ4brZjgg=; b=LZoWpQiQgyqGfnXH+stljQ5ZnLftSuB6/sOV1+3TyCKmSYiswRd+eyB0EoIx4AQKEj KJ31eeYgEk89RkLrjJESUdl1PnhzFtzf1MsYNHYxX+mjLBTw4jBu1OqYRHIKsXH3dKhb 7+u1RkDBXmsc5iCGrQ2eNOXzyIOHWdkoVIZueWYB8mLfkLNGYH7vqYSbydy9dTwCxPNF sO2BS1geeBnzS9Xpx42MdlftSHc5crrJfMVZ/mLb4cNh3q6EMdxW/gOTkO0ftkznRjt0 ZwoWMEWABNtcJaTm4I8gKP+/l2PeHY2mW9t9Q13tZbkVgNWEEN/dht1nAVnrjuOb/pEQ eiRg== X-Gm-Message-State: AOAM533z8MNL932B30a0k9sVAP3VMSqQOpf1uqwFPPe9LyHOMPiLhvRI iiKwPFB/GamWoDicuhbNR9wUBUXJcDrKfQ== X-Google-Smtp-Source: ABdhPJwRFrysBkPxm75fACk4FnTODJOElwZIAW+fn0oi4Clr2JG5ZEsQkO2479DU0QqyXxsznK2TDA== X-Received: by 2002:a62:6c2:0:b029:142:2501:397c with SMTP id 185-20020a6206c20000b02901422501397cmr4196363pfg.65.1601986195433; Tue, 06 Oct 2020 05:09:55 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:09:54 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 1/7] plugins: Fixes a issue when dlsym failed, the handle not closed Date: Tue, 6 Oct 2020 20:08:54 +0800 Message-Id: <20201006120900.1579-2-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=luoyonggang@gmail.com; helo=mail-pg1-x543.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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Yonggang Luo Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- plugins/loader.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/loader.c b/plugins/loader.c index 685d334e1a..8ac5dbc20f 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -235,6 +235,7 @@ static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info) return rc; err_symbol: + g_module_close(ctx->handle); err_dlopen: qemu_vfree(ctx); return 1; From patchwork Tue Oct 6 12:08:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 271971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 879ADC4363D for ; Tue, 6 Oct 2020 12:11:52 +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 F2D5620663 for ; Tue, 6 Oct 2020 12:11:51 +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="mDptSu/T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2D5620663 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPlos-00055V-Sx for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:11:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPln7-0003JJ-PU for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:01 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:43634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPln6-0004DX-3U for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:01 -0400 Received: by mail-pl1-x641.google.com with SMTP id o9so1118920plx.10 for ; Tue, 06 Oct 2020 05:09:59 -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=oA6lwA9DRk6v/CqH7e4pibYzUGFI9UFOt7RD8ATdFPQ=; b=mDptSu/TJAdlaMSV4SNo6oO7zBvbrg9VaD+Lp4itrNOG4kSwyhdP1gkThzcy6gsgIx mlgnFY5C05NbZj3A9rENKLr9agYiCETEGtbWILmNGKUKOnM2uUAPZsVtkCSBRo0n2t19 GHHmjwVIkdptlO94nriY6w6vpGcGjcuLiiEDj9BpMYSG3Uc5YH7ojAcWlCevFmmSr0IX HP3RkFKM9K9dhQhEGB5hy+uDOMaq0vLY5YxhVUiZ2hltSe34uGdVEF8osrJ8C1kw9uQn nSkQY/F7abB0UksjP1Bo6HFQjwqARy9CRZjfbraKMAKBZyAT0xr4oO3o3dyZPFzcg6bB 2BvA== 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=oA6lwA9DRk6v/CqH7e4pibYzUGFI9UFOt7RD8ATdFPQ=; b=ITexIU1U7Ku0NWWbERhVFZAO/sdmmhdtxLyLalnTotdGKbBYF11SjHpe3+L5xTNwNM 4w+zZGZLBr8TUnwmKfY8J2alXFIe5mJJSG9dVdQJhG6CK/BxpiZ9FQnhWB1uYjtHlCtl EHSsss4nBlQdosJ28PBOb/hU22aEM5TBvbyTUE1idWtHfcAZIR7DdJ/HKOSXuRIZvrut QPTZI9lBtS8kDVFvVcMWoTl2U+UxkBlFehpVorsgWDGmxxEzfN0zJp3SwNjzt4YGDnu5 4nddeh7iNPhWJl85ebVbPt9a0J1s4QUViK7rwZPHaVJVo/8OzycGHj4x1WNluxNEoeE6 cROQ== X-Gm-Message-State: AOAM533h8gjLJqmEvU6RyZfT02UGEIhV+EaFUEEgkRcKpANsKsr4M2MY eI5wQ3DNE4j/2vgCU5AJ0uiVdes5vzCk2Q== X-Google-Smtp-Source: ABdhPJyD9ujyUCXnBno29fF1GG6x0UMJ5ZgVq7ozFDQdePY9E0BTIbjngJNSk+5nI4sj/rhMdpIv2Q== X-Received: by 2002:a17:90a:d983:: with SMTP id d3mr3493516pjv.144.1601986198006; Tue, 06 Oct 2020 05:09:58 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:09:57 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 2/7] plugin: Fixes compiling errors on msys2/mingw Date: Tue, 6 Oct 2020 20:08:55 +0800 Message-Id: <20201006120900.1579-3-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x641.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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Yonggang Luo Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- contrib/plugins/hotblocks.c | 2 +- tests/plugin/bb.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 3942a2ca54..37435a3fc7 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -102,7 +102,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { ExecCount *cnt; uint64_t pc = qemu_plugin_tb_vaddr(tb); - unsigned long insns = qemu_plugin_tb_n_insns(tb); + size_t insns = qemu_plugin_tb_n_insns(tb); uint64_t hash = pc ^ insns; g_mutex_lock(&lock); diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index e4cc7fdd6e..de09bdde4e 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -72,7 +72,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata) CPUCount *count = max_cpus ? g_ptr_array_index(counts, cpu_index) : &inline_count; - unsigned long n_insns = (unsigned long)udata; + uintptr_t n_insns = (uintptr_t)udata; g_mutex_lock(&count->lock); count->insn_count += n_insns; count->bb_count++; @@ -81,7 +81,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata) static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { - unsigned long n_insns = qemu_plugin_tb_n_insns(tb); + size_t n_insns = qemu_plugin_tb_n_insns(tb); if (do_inline) { qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, From patchwork Tue Oct 6 12:08:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 303610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C94EC41604 for ; Tue, 6 Oct 2020 12:11:53 +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 CFA3D20663 for ; Tue, 6 Oct 2020 12:11:52 +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="Q0nHtbtg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFA3D20663 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPlot-00058I-NB for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:11:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPlnA-0003Mm-BE for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:04 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPln7-0004Dm-Vr for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:04 -0400 Received: by mail-pl1-x641.google.com with SMTP id h2so1117082pll.11 for ; Tue, 06 Oct 2020 05:10:01 -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=Q0nHtbtgCA/rPt07KzbJ9+UaXJUZvRdskOPP47GpIoRdVyz4D2ik6TezGtkoIaxmHF fARW2a/0bPMCv7REiIAxMILK+aAEJGvnS2Ghcgej6DjKGFPR7thCIDn1+ZYLBmRsio9W fJ3Da+54SDY+DPCkxD1NvbwD1xhPrJicivJNTTVH6RsL17YbzjWpvBcAZIzgXris3pOg IzZUl3DBteHS30S+uuTiNTJfweWCpPk4Wh6CfPK8pv8MK9clMbgI2bfatMEnFJ+QBMqT zk6WXLUExYtHEdSQgI/gNXJYHmzQtGCKj8xdAKPIAXnkNDI4tBrdJQ/uHwhywbH9x3Ft WBXg== 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=EVvaHXdJOVSjSSh5bdCpO0ICK/0cHrys8p4vjXMuS6G+PUPud5a6OO8tuFJXYf+1FZ PbNfnyeuZ7hDQTBqQWuQGgts0HS4Rk30ISrltIWPPhmQrqNkieYeu9Tszm/yttdAwwVk GnZ7EG4EFiVDp6mOt0hYTl1I1HFYsHP3J7kXQ1H6FddPWmOpa9kRkQZW5xfDt4vLOFQf zTO/5KD3FLxERX/dB+fjWi7/mEYYWRajfVOxE0bPw8Xy1dvctzBViARx0K9ZqosQYlYQ YCKoqZbW6//JwO3JfBOs27XCt2YWgXHZ+3xojurpAannjQGKMoQMcVht/qvLCeqjOPAF ZL/w== X-Gm-Message-State: AOAM532U4S54JtZLNsY6tyg9B10VwHp8FUuF4FFsUMjlL3h+/hDVgBwB lAqQGtVE6CpPM6m5+g2RCO+JWJl8ufVy0A== X-Google-Smtp-Source: ABdhPJxnPS65Yk4e6fTu4UvMdrVzT9i8MaRPkgWO1SUeMLIXcHjDVX8kOcLU2GSjf/WYnxmklQsjxA== X-Received: by 2002:a17:90a:e088:: with SMTP id q8mr4260818pjy.172.1601986200303; Tue, 06 Oct 2020 05:10:00 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:09:59 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 3/7] plugin: getting qemu_plugin_get_hwaddr only expose one function prototype Date: Tue, 6 Oct 2020 20:08:56 +0800 Message-Id: <20201006120900.1579-4-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x641.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+qemu-devel=archiver.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 6 12:08:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 271970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E777EC4363D for ; Tue, 6 Oct 2020 12:12:38 +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 58AA820663 for ; Tue, 6 Oct 2020 12:12:38 +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="vbzT3j4Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58AA820663 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPlpd-00073C-EL for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:12:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPlnC-0003OQ-7x for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:06 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPlnA-0004EN-Fv for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:05 -0400 Received: by mail-pl1-x642.google.com with SMTP id h2so1117125pll.11 for ; Tue, 06 Oct 2020 05:10:04 -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=vbzT3j4Y1pCF30z/9/Ro3kcDdY9cjeq1lyJQdrx7sGwqicbjs1mRTGXJEStrS1xYJ9 BiEWpc7m0VWM/iSy2nx1J9b3HYQRJCUk6zAfyHBp66zHokUhlOC5kZIJmC2dY8kl5PC2 JUI4BrU1adsjDiwUMZd33dNiRtsicBnzXmFmicrDMXYtM8iGoiXydogR4AtIhvCvqXfb arzaV94kYMB+76BOpseREmquhNVEi0Ts9oJc00rcqmCmNBXMfTVlYl6yr0aCQS1BKXLI u+9WbBpJWhXVHEEHNO7lvH9AZElxmQxhI9vtdDNg8Zvw4GqyJbCaCLVmbk5OreSff+3y d1Ew== 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=PMi7cb46XeyrT0uSOmbJ14KEiNxNg4nCqL8YgDTbsjeML0l/+OSPWxhvpyhmirFw0J 19ur1ZMUpIRZrv+voPrMLU79vD9PH7I1D/WJzP8lVzTswXcCd4Z45iY0Zkfd47q/C9LM +Z7IUN+cgxcKXbrT/4HUNm40kNBwTztcJOgjwJiiC/hmeGvXObUAphvaqBg/jH0bWFu/ d5ng3q3AGow/OrD0fOo0e1ehQpDAs91GSvmJxxM+58ZBdD+u2U84KcFvDjpsOP2DmqrX kEbkvciHO4dyx00SkAjaNwcFInusSzG+vODJvOdS1u4KCjsAPRg8nJ2p5rwXtHQx4heB Bd/g== X-Gm-Message-State: AOAM5303lsSb98TT+SaftyAXWs55dp06BvyxCqOpI0o0+RUzuHFpkC7H uLMQXxnrR1zSRebPKnLk5Aqq3o03iim5DQ== X-Google-Smtp-Source: ABdhPJwvEqs1rpiA5GDP41oPh7zHTbuvm6dRzzWOn6YR48IL6+VfM25vVQqQnSdB/xmAcxD2woX1Vw== X-Received: by 2002:a17:90a:ae12:: with SMTP id t18mr4148025pjq.147.1601986202638; Tue, 06 Oct 2020 05:10:02 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:10:01 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 4/7] plugin: Fixes typo in qemu-plugin.h Date: Tue, 6 Oct 2020 20:08:57 +0800 Message-Id: <20201006120900.1579-5-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x642.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+qemu-devel=archiver.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 6 12:08:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 303608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FD21C4363D for ; Tue, 6 Oct 2020 12:14:35 +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 7A01E206BE for ; Tue, 6 Oct 2020 12:14:34 +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="dbpANuUQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A01E206BE 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPlrV-00013q-Kk for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:14:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPlnK-0003UP-Ui for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:16 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:40795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPlnF-0004Ev-1W for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:14 -0400 Received: by mail-pj1-x1029.google.com with SMTP id j8so1512324pjy.5 for ; Tue, 06 Oct 2020 05:10:08 -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=BOlOgUVB/LUsxUJM9RhelHXFkF/Bcu9HYVNIIx7ypx4=; b=dbpANuUQD0uQ7djawCn0sZpjdBSpE3YCUd8uyYbK3zZxd2yqlANdVc/V3EONclx0oD tR4LsjrV8i6iWWkHKm3m/Z4kvbpHC2XE/f8+jdvW8gsnSSp7/VGKRl5tb3gxX02BCAM1 Se/pBkfyfC1adB/hfNXeroLYORzQ+ZuJAgbbWkatbBdVb7sSjV0vRjQkVfWDHv78JZBO 1rWkHtYJc0zvpqktNBS6ZcyIIkruWza/FNjAcY2IPrn9gPwwB2ruMw32vQbhnZh+aBRW OFLby0SbHqaQn0hthzPHJW0N9SUcZAzNNFTaXZgHpAfQw/HxNl6pPXuEyxliDa6+Ji8D LmsA== 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=BOlOgUVB/LUsxUJM9RhelHXFkF/Bcu9HYVNIIx7ypx4=; b=r61OmZvySs3TCaxB4+tJ7vtQCW/yLsYFu2sCog6ZimE5UVQicpPMhgZfol1E1KQaG/ /sWLqjPBSsjCsTgHnWdiCp/OWYznm45zL0Ls76E+6rBbQZMfLv4xW6M0PGd6ixXb7NQx C6FDO+BK55c/jUlJVgYmrTc8WhzfOrGlBNHwnK3diPFqpkHXlV6rsWSpi+SqdrtoClmB prwBp173xLZV3vH5JKS/34ZG7kcmYEBotsZf45svzI0CGkZq8NziNxYMUCvCtyFmN+rp nlbRgKejv0IMgHThufoTHsdV3uRL8atDiQFrWSxVVtAVPF0flPVCGqOizXdTYnjo1/pK pmWQ== X-Gm-Message-State: AOAM532km4Q11Wa3y0WzU0BoSpjMJ2YnaBc0JW3Cw1DmhZ6QbKW+7GDj /5z+Ev+NUPUsyuv0onOATpD/dVOusLncPw== X-Google-Smtp-Source: ABdhPJyi5fGoffyZSSPZe90+Gaz4VkbT/TT5q/4jxYFCQBt9PEwb04Swq7xHrQ0vMan3XH8kywGfxg== X-Received: by 2002:a17:90a:634b:: with SMTP id v11mr3320447pjs.108.1601986206494; Tue, 06 Oct 2020 05:10:06 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:10:05 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 5/7] plugin: Getting qemu-plugin works under win32. Date: Tue, 6 Oct 2020 20:08:58 +0800 Message-Id: <20201006120900.1579-6-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=luoyonggang@gmail.com; helo=mail-pj1-x1029.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+qemu-devel=archiver.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 | 185 ++++++++++++++++++++++++++--------- meson.build | 6 +- plugins/api.c | 68 +++++++------ plugins/core.c | 15 ++- plugins/loader.c | 50 +++++++++- plugins/meson.build | 10 +- plugins/plugin.h | 1 + plugins/qemu-plugins.symbols | 40 -------- 10 files changed, 244 insertions(+), 203 deletions(-) delete mode 100644 plugins/qemu-plugins.symbols diff --git a/Makefile b/Makefile index f27bd4b2eb..f8f0450fc0 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 30d7711edf..0f094860ec 100755 --- a/configure +++ b/configure @@ -5245,61 +5245,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..8c725d429c 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, +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,21 @@ 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 +372,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 +391,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 +402,109 @@ 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_EXTERN + +QEMU_PLUGIN_EXTERN qemu_plugin_uninstall_t qemu_plugin_uninstall; +QEMU_PLUGIN_EXTERN qemu_plugin_reset_t qemu_plugin_reset; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_init_cb_t qemu_plugin_register_vcpu_init_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_exit_cb_t qemu_plugin_register_vcpu_exit_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_idle_cb_t qemu_plugin_register_vcpu_idle_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_resume_cb_t qemu_plugin_register_vcpu_resume_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_tb_trans_cb_t qemu_plugin_register_vcpu_tb_trans_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_tb_exec_cb_t qemu_plugin_register_vcpu_tb_exec_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_tb_exec_inline_t qemu_plugin_register_vcpu_tb_exec_inline; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_insn_exec_cb_t qemu_plugin_register_vcpu_insn_exec_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_insn_exec_inline_t qemu_plugin_register_vcpu_insn_exec_inline; +QEMU_PLUGIN_EXTERN qemu_plugin_tb_n_insns_t qemu_plugin_tb_n_insns; +QEMU_PLUGIN_EXTERN qemu_plugin_tb_vaddr_t qemu_plugin_tb_vaddr; +QEMU_PLUGIN_EXTERN qemu_plugin_tb_get_insn_t qemu_plugin_tb_get_insn; +QEMU_PLUGIN_EXTERN qemu_plugin_insn_data_t qemu_plugin_insn_data; +QEMU_PLUGIN_EXTERN qemu_plugin_insn_size_t qemu_plugin_insn_size; +QEMU_PLUGIN_EXTERN qemu_plugin_insn_vaddr_t qemu_plugin_insn_vaddr; +QEMU_PLUGIN_EXTERN qemu_plugin_insn_haddr_t qemu_plugin_insn_haddr; +QEMU_PLUGIN_EXTERN qemu_plugin_mem_size_shift_t qemu_plugin_mem_size_shift; +QEMU_PLUGIN_EXTERN qemu_plugin_mem_is_sign_extended_t qemu_plugin_mem_is_sign_extended; +QEMU_PLUGIN_EXTERN qemu_plugin_mem_is_big_endian_t qemu_plugin_mem_is_big_endian; +QEMU_PLUGIN_EXTERN qemu_plugin_mem_is_store_t qemu_plugin_mem_is_store; +QEMU_PLUGIN_EXTERN qemu_plugin_get_hwaddr_t qemu_plugin_get_hwaddr; +QEMU_PLUGIN_EXTERN qemu_plugin_hwaddr_is_io_t qemu_plugin_hwaddr_is_io; +QEMU_PLUGIN_EXTERN qemu_plugin_hwaddr_device_offset_t qemu_plugin_hwaddr_device_offset; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_mem_cb_t qemu_plugin_register_vcpu_mem_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_mem_inline_t qemu_plugin_register_vcpu_mem_inline; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_syscall_cb_t qemu_plugin_register_vcpu_syscall_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_vcpu_syscall_ret_cb_t qemu_plugin_register_vcpu_syscall_ret_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_insn_disas_t qemu_plugin_insn_disas; +QEMU_PLUGIN_EXTERN qemu_plugin_vcpu_for_each_t qemu_plugin_vcpu_for_each; +QEMU_PLUGIN_EXTERN qemu_plugin_register_flush_cb_t qemu_plugin_register_flush_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_register_atexit_cb_t qemu_plugin_register_atexit_cb; +QEMU_PLUGIN_EXTERN qemu_plugin_n_vcpus_t qemu_plugin_n_vcpus; +QEMU_PLUGIN_EXTERN qemu_plugin_n_max_vcpus_t qemu_plugin_n_max_vcpus; +QEMU_PLUGIN_EXTERN qemu_plugin_outs_t qemu_plugin_outs; + +QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info) +{ + qemu_plugin_uninstall = info->dlsym(info->context, "qemu_plugin_uninstall"); + qemu_plugin_reset = info->dlsym(info->context, "qemu_plugin_reset"); + qemu_plugin_register_vcpu_init_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_init_cb"); + qemu_plugin_register_vcpu_exit_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_exit_cb"); + qemu_plugin_register_vcpu_idle_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_idle_cb"); + qemu_plugin_register_vcpu_resume_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_resume_cb"); + qemu_plugin_register_vcpu_tb_trans_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_tb_trans_cb"); + qemu_plugin_register_vcpu_tb_exec_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_tb_exec_cb"); + qemu_plugin_register_vcpu_tb_exec_inline = info->dlsym(info->context, "qemu_plugin_register_vcpu_tb_exec_inline"); + qemu_plugin_register_vcpu_insn_exec_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_insn_exec_cb"); + qemu_plugin_register_vcpu_insn_exec_inline = info->dlsym(info->context, "qemu_plugin_register_vcpu_insn_exec_inline"); + qemu_plugin_tb_n_insns = info->dlsym(info->context, "qemu_plugin_tb_n_insns"); + qemu_plugin_tb_vaddr = info->dlsym(info->context, "qemu_plugin_tb_vaddr"); + qemu_plugin_tb_get_insn = info->dlsym(info->context, "qemu_plugin_tb_get_insn"); + qemu_plugin_insn_data = info->dlsym(info->context, "qemu_plugin_insn_data"); + qemu_plugin_insn_size = info->dlsym(info->context, "qemu_plugin_insn_size"); + qemu_plugin_insn_vaddr = info->dlsym(info->context, "qemu_plugin_insn_vaddr"); + qemu_plugin_insn_haddr = info->dlsym(info->context, "qemu_plugin_insn_haddr"); + qemu_plugin_mem_size_shift = info->dlsym(info->context, "qemu_plugin_mem_size_shift"); + qemu_plugin_mem_is_sign_extended = info->dlsym(info->context, "qemu_plugin_mem_is_sign_extended"); + qemu_plugin_mem_is_big_endian = info->dlsym(info->context, "qemu_plugin_mem_is_big_endian"); + qemu_plugin_mem_is_store = info->dlsym(info->context, "qemu_plugin_mem_is_store"); + qemu_plugin_get_hwaddr = info->dlsym(info->context, "qemu_plugin_get_hwaddr"); + qemu_plugin_hwaddr_is_io = info->dlsym(info->context, "qemu_plugin_hwaddr_is_io"); + qemu_plugin_hwaddr_device_offset = info->dlsym(info->context, "qemu_plugin_hwaddr_device_offset"); + qemu_plugin_register_vcpu_mem_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_mem_cb"); + qemu_plugin_register_vcpu_mem_inline = info->dlsym(info->context, "qemu_plugin_register_vcpu_mem_inline"); + qemu_plugin_register_vcpu_syscall_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_syscall_cb"); + qemu_plugin_register_vcpu_syscall_ret_cb = info->dlsym(info->context, "qemu_plugin_register_vcpu_syscall_ret_cb"); + qemu_plugin_insn_disas = info->dlsym(info->context, "qemu_plugin_insn_disas"); + qemu_plugin_vcpu_for_each = info->dlsym(info->context, "qemu_plugin_vcpu_for_each"); + qemu_plugin_register_flush_cb = info->dlsym(info->context, "qemu_plugin_register_flush_cb"); + qemu_plugin_register_atexit_cb = info->dlsym(info->context, "qemu_plugin_register_atexit_cb"); + qemu_plugin_n_vcpus = info->dlsym(info->context, "qemu_plugin_n_vcpus"); + qemu_plugin_n_max_vcpus = info->dlsym(info->context, "qemu_plugin_n_max_vcpus"); + qemu_plugin_outs = info->dlsym(info->context, "qemu_plugin_outs"); + return 0; +} + +#endif /* QEMU_PLUGIN_API_IMPLEMENTATION */ + #endif /* QEMU_PLUGIN_API_H */ diff --git a/meson.build b/meson.build index d515ece664..95a532bd29 100644 --- a/meson.build +++ b/meson.build @@ -331,7 +331,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..96e3345a3f 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,17 @@ #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 +71,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,14 +92,14 @@ 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, +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_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) @@ -104,7 +108,7 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, cb, flags, udata); } -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, +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) { @@ -114,7 +118,7 @@ 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_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, @@ -124,7 +128,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, cb, flags, rw, udata); } -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, +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) @@ -133,19 +137,19 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, 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 +172,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 +198,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 +229,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,7 +257,7 @@ 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, +QEMU_PLUGIN_EXPORT struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, uint64_t vaddr) { #ifdef CONFIG_SOFTMMU @@ -273,7 +277,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 +286,7 @@ 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 +317,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 +326,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 +338,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..53fb1671ee 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 6 12:08:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 303609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0D42C4363D for ; Tue, 6 Oct 2020 12:13:22 +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 70C3120663 for ; Tue, 6 Oct 2020 12:13:22 +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="uA+Ho/Bw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70C3120663 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPlqL-0007yi-HV for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPlnI-0003T6-Uk for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:12 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:45416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPlnG-0004F9-QA for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:12 -0400 Received: by mail-pf1-x442.google.com with SMTP id x22so8878944pfo.12 for ; Tue, 06 Oct 2020 05:10:10 -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=9m4Jg/id830Dx9xQTw5eTIEmforQvRp5qt9BLy+DBJw=; b=uA+Ho/Bw3c2GJAwhDybA8txAxBF3NUkr5kKYRqCnUucrYzO0P6xby++NgV3plG70wP FrAPCYRX01XoyDYb2QIsgKnhm9rGgF3nYWHqnsz2hjnk78LQz3CYNfEhCEGQidscTAOL 2ABe6Lea2TyY7KhC+qS1d3m/hYXMJOlRV12hGJUIE/fJGxyKBNtv+tDy7hP/Ds4DAtk+ e/+n9NA+bS8Uku1iIESoC1B/a+GVORuIHOwFUcC0WFdw98KspCO4H4+JzBWefcWJfr9p 6TiSY+HMWCp+l09LHu4BxBlgbZnkfPmTQZM+/cosadgdTMUd6TVyWJQRlHLsbTj4Qobi 43Xg== 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=9m4Jg/id830Dx9xQTw5eTIEmforQvRp5qt9BLy+DBJw=; b=nXiVcNkkcgwHg30MrHjXT7BH5f51Dym8RPWXnyAgpROdFpXwHY4ddF9gutfIqg4Uzj +F0KfvJS1ZEzq/pMqjo6CcDTxPvhJF+ZRTBPUfq85EHw2Nc11k+zRW+/Ypf+jbDfYTvu MN2XzGIJWHNAzECY6qlxQgv/9ZVhsapc9H1zph9mfnPVYk5Kx9Rifnc6BIlBTDwQHx4P 3hZV0UbENo0sjcK8B1lEVHvfIBa3qNEmFgXsezGc1hHXx+4h/inHGO4k2gfdpf9cdD/R 1K239gylbsswZaRMWNyLbC9VzQEqFFXL6MZbHhPTHmU1sRqEsjUt/Pc8FBJLEctOWouV q3xQ== X-Gm-Message-State: AOAM532vxt+x+KeWBmEat4+cN9B0+cUSvmeoNpfD33rv5xtciELnReCz jmW2jAIMTUwKh7p2iCY/BRpZh1QOjdO32g== X-Google-Smtp-Source: ABdhPJwnfgykWezLDGYrqxnjUJ7pSTS2U1lyXiWyfeMcdpl4XMiXqq5lbSMhar8jgcrRNVRKncsqvg== X-Received: by 2002:a63:d841:: with SMTP id k1mr3816492pgj.59.1601986209027; Tue, 06 Oct 2020 05:10:09 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:10:08 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 6/7] plugin: Getting qemu-plugin.h can be included in multiple source file Date: Tue, 6 Oct 2020 20:08:59 +0800 Message-Id: <20201006120900.1579-7-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-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+qemu-devel=archiver.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 | 8 ++++++++ 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, 17 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 8c725d429c..8d08f52f7f 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -424,7 +424,11 @@ typedef int (*qemu_plugin_n_max_vcpus_t)(void); typedef void (*qemu_plugin_outs_t)(const char *string); #if !defined(QEMU_PLUGIN_API_IMPLEMENTATION) +#if defined(QEMU_PLUGIN_IMPLEMENTATION) #define QEMU_PLUGIN_EXTERN +#else +#define QEMU_PLUGIN_EXTERN extern +#endif QEMU_PLUGIN_EXTERN qemu_plugin_uninstall_t qemu_plugin_uninstall; QEMU_PLUGIN_EXTERN qemu_plugin_reset_t qemu_plugin_reset; @@ -463,6 +467,8 @@ QEMU_PLUGIN_EXTERN qemu_plugin_n_vcpus_t qemu_plugin_n_vcpus; QEMU_PLUGIN_EXTERN qemu_plugin_n_max_vcpus_t qemu_plugin_n_max_vcpus; QEMU_PLUGIN_EXTERN qemu_plugin_outs_t qemu_plugin_outs; +#if defined(QEMU_PLUGIN_IMPLEMENTATION) + QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info) { qemu_plugin_uninstall = info->dlsym(info->context, "qemu_plugin_uninstall"); @@ -504,6 +510,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_initialize(const qemu_info_t *info) return 0; } +#endif + #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 6 12:09:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= X-Patchwork-Id: 271969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8939EC4363D for ; Tue, 6 Oct 2020 12:13:45 +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 E5D7920663 for ; Tue, 6 Oct 2020 12:13:44 +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="urNh0aSP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5D7920663 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPlqg-00088G-Mu for qemu-devel@archiver.kernel.org; Tue, 06 Oct 2020 08:13:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPlnM-0003UU-97 for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:16 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:36836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPlnK-0004FM-JF for qemu-devel@nongnu.org; Tue, 06 Oct 2020 08:10:15 -0400 Received: by mail-pg1-x52e.google.com with SMTP id x16so7890923pgj.3 for ; Tue, 06 Oct 2020 05:10:12 -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=9ZjByY0MppOyobXen+0uddzbK8uVuelULUAbb8n9Gk0=; b=urNh0aSPHimYCDbh5F40nns7wONq/7IYIack8l1bO+X1G5FlSsXi1/ywEpubiS0bbp nXGOnzYrkbX6ybuHKOLkhjSaU8kfq1vuPpJGGpZTAHK3DgKea0+4xYo86FdhdFQT/exX aaVrcV4t9g6WeLrIix7vGfI5RXPC7JWUsJ/QAOpi/2igpbJOocAuPp816VLd4AwJ7AgO W9vbUWO9iwxVY1tgTSk48DdYOedK1wjZyA08qXzPCPKBuMDFEpKxZTb1h81v51Xs+1nD Tg8oNwvwK6R6kHCCo/Re9H97e8x+VEkqiBpWtjVRQc55p5pbzU8uJyRq+224C2rePbJA HgiA== 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=9ZjByY0MppOyobXen+0uddzbK8uVuelULUAbb8n9Gk0=; b=sd2ulPTFLezsvycHIDb6GLuRNe2G6IaWMJOt7WXG2XGDeC0UM7MVuJfi9sx/ItWtJg djtvKeGoROfyIOW3aDPOXOLFXAEbZ8+D6kkgt3EH+RNhVUq8e/dpx0OiT+uWSlrayPtq pgaqz3iSEQ7C0PRTjnsEphparLfZLxnJm9O8Ai/c79eRtGp4J0m6fOQ9AfH6053Fsw3w 61hvULVwztRkffsV5wWakGOiJJgrjGVEa2E0itGg5eeBsrwJrHcfMDZ7dJ6Rbco22Uxn mVPjc6ch47U9yjt7vYp8Af7uj9WAUVURDA/1m6PC6XBJi0W8TG7vePB9E8Ds3jDyxnY2 Vn3A== X-Gm-Message-State: AOAM533+eNxpgHjyiMl3UEgdimwZVO6YsNKSYmZwSYHR3cKRVdno1QVr v0BI3SGiqNAnb5nYAtMhKaF9xgWKXNdYIA== X-Google-Smtp-Source: ABdhPJz+zAsFQLJjeVAvi8mKrGy3hNxXDZLy1GKjzQn9OunR1Ye4PN9/CDQMH68EKemOPOANVS1BLg== X-Received: by 2002:a63:fe03:: with SMTP id p3mr3773610pgh.100.1601986211368; Tue, 06 Oct 2020 05:10:11 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id f4sm2965681pgk.19.2020.10.06.05.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 05:10:10 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5 7/7] cirrus: Enable plugin in cirrus for windows Date: Tue, 6 Oct 2020 20:09:00 +0800 Message-Id: <20201006120900.1579-8-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201006120900.1579-1-luoyonggang@gmail.com> References: <20201006120900.1579-1-luoyonggang@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=luoyonggang@gmail.com; helo=mail-pg1-x52e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Yonggang Luo --- .cirrus.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 86ea33926a..5363142373 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -104,7 +104,8 @@ windows_msys2_task: - C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build" - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure --python=python3 --ninja=ninja - --target-list-exclude=i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu" + --target-list-exclude=i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu + --enable-plugins" - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j$NUMBER_OF_PROCESSORS" test_script: - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"