From patchwork Thu Oct 17 13:16:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176631 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp954367ill; Thu, 17 Oct 2019 06:48:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTwzU8595KUA8fiD78HxWJZfGvxKfE7ClmVb7UYczw5m0JUWRsHc8dR+Z98GKrzqhmPhEu X-Received: by 2002:a5d:43c1:: with SMTP id v1mr3220322wrr.91.1571320139630; Thu, 17 Oct 2019 06:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320139; cv=none; d=google.com; s=arc-20160816; b=v7oN6Q+aDowQeoAB+fVKLFLG64omU5TjhaGSgbQVPacRvulgjJEeHK9iImDJjTNL64 1uKZbQJupfTlxQDdWkLMVQe1vrrzbNrTVrWg55TRdyuu2hsO7NbBMtDjucnMD0s6Sdyx VAyABGF624V/D1kzoN6J6GJt1koxMs4c0xMJ/OG8/4n7HYKlSVyxQgGIfgwwNAX9Nq9N JTAs8ek5694JPmwY/UfIMkHsJ+cqGKaoSQ9pnqHU9RVkHFnsVBkrRdGg310qcupHfLJx QQL+XCdvlr9TdXQEPM5yDbs/RIkyx8NmWj69AYqy5ceeFTmce6Tn1HyTvMATHy4uPVbG p5yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=J5h9LF/cBImRwgBymxo6bpvt6wjjRh3DJds8b7bRsjM=; b=tNOA+opXg4A4h4MQtfvO9iypOYENrceSzqzf11Z1g1pkgr5Td4w3LtNYzGIIaSAeaf KCgITIiur4kbBfdHxkBd63wQsW9kghCBcMRPeenRiVTk2T+O9OtxF3wpIilNog+Kafry iCqTJfYqaRyaX8sqBikPVFQzZu9lssSsDR4ON3oWm/rX0IZUa69rlL0lleyfktonH0d7 S7DPzBSYVplNP82BDywiqypk6N6aEhqUd8PDn/JkRP+49c0JwJm69Y7RBwIlLsiPcoZs R5+XXFLal5e+yaS6bf7fcAtnUxGdTRX/nRO58JRSdgbA0eC6OPzURRaeXaSSKqgVzgXy wV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F0Vb0TwW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x10si2072119wro.30.2019.10.17.06.48.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F0Vb0TwW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL69C-0003cE-44 for patch@linaro.org; Thu, 17 Oct 2019 09:48:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mP-00028b-PS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mO-0001FC-KC for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:25 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:42836) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mO-0001Et-EF for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:24 -0400 Received: by mail-wr1-x436.google.com with SMTP id n14so2339894wrw.9 for ; Thu, 17 Oct 2019 06:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J5h9LF/cBImRwgBymxo6bpvt6wjjRh3DJds8b7bRsjM=; b=F0Vb0TwWW1BUduZbamzC0yB5eWrB/FWr0gz4JEIqQQqbx27l7sDZ3xm+0uNKm/56Ri CAzQMQZAn/QnafbL6Me8wcdtDJx93zD/piEQwvCN+vHbKkIQJQuRo5FxruOL4P9vrCzv p1U6J87gutNnneKMT7t3nsX961zrEwBtaB3I+CblSkDL1AtKUmQ4C6+JsQMIXJO2lwNC cn0lTU/5gUiogWn5tuKRHJMsYIKI4pu6BFNpvUOgo69Kkka6l7d2mabRghZDyrTmpiXd ua/ljXnkT+61npG0+pak6hhuvr3iGgElfPI+tL3KNLxOc/Ivt9oJUqBBIDgdXssbpOBN LqFA== 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=J5h9LF/cBImRwgBymxo6bpvt6wjjRh3DJds8b7bRsjM=; b=XbMg3sVj5Wntqe5qMos0al6bWXGNnjnTQvDcpkC33ZmT23f2xOs+u6rf5M/l3yxHPH ZDSGSV6PNrsOFUIWC/7sMGKw2n53qLmGi0xk1r8cdAJXl4ElbNj5JCm4L5fFuKPcdJNC 7/8AfHjZslO46voPzjk2AJ7IeB+mDddvhMQZMBTlePqCG9flFgFtGjD2U5u+7QjWIomw GrWp7g0tFPMT7JMJspcPbvQv60d7ThSA+9Wb342BOy27y577JPLmUX1G0wn9cWYFueq0 XhJhq6NApU4msSvoeTkF6b2RnJgtX3uja6ccC8hFl7TnTNrSJr9ypwu8d9PIKgcfj0s3 XyNw== X-Gm-Message-State: APjAAAWnOAoUTtqGjoNxeQGc5Faj7FK6UpyhZqsWn+0D9Ua1/7uC1Ppp T2uRO2jsiXP1iO0QhYiy25YKOnrraNs= X-Received: by 2002:a05:6000:1190:: with SMTP id g16mr2997913wrx.133.1571318723103; Thu, 17 Oct 2019 06:25:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x5sm2494190wrt.75.2019.10.17.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 921BF1FFBE; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 39/54] plugin: add qemu_plugin_outs helper Date: Thu, 17 Oct 2019 14:16:00 +0100 Message-Id: <20191017131615.19660-40-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 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: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Having the plugins grab stdout and spew stuff there is a bit ugly and certainly makes the tests look ugly. Provide a hook back into QEMU which can be redirected as needed. Signed-off-by: Alex Bennée --- v6 - split and move to pre example plugins --- include/qemu/log.h | 1 + include/qemu/qemu-plugin.h | 6 ++++++ plugins/api.c | 8 ++++++++ plugins/qemu-plugins.symbols | 1 + util/log.c | 3 +++ 5 files changed, 19 insertions(+) -- 2.20.1 Reviewed-by: Aaron Lindsay diff --git a/include/qemu/log.h b/include/qemu/log.h index b097a6cae1..a91105b2ad 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void) /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ #define CPU_LOG_TB_OP_IND (1 << 16) #define CPU_LOG_TB_FPU (1 << 17) +#define CPU_LOG_PLUGIN (1 << 18) /* Lock output for a series of related logs. Since this is not needed * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index ddf267fbfe..a00a7deb46 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -384,4 +384,10 @@ int qemu_plugin_n_vcpus(void); /* returns -1 in user-mode */ int qemu_plugin_n_max_vcpus(void); +/** + * qemu_plugin_outs() - output string via QEMU's logging system + * @string: a string + */ +void qemu_plugin_outs(const char *string); + #endif /* QEMU_PLUGIN_API_H */ diff --git a/plugins/api.c b/plugins/api.c index 5adc4d25a1..fa1d9f276d 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -331,3 +331,11 @@ int qemu_plugin_n_max_vcpus(void) return get_ms()->smp.max_cpus; #endif } + +/* + * Plugin output + */ +void qemu_plugin_outs(const char *string) +{ + qemu_log_mask(CPU_LOG_PLUGIN, "%s", string); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 267ec381b4..4bdb381f48 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -36,4 +36,5 @@ qemu_plugin_vcpu_for_each; qemu_plugin_n_vcpus; qemu_plugin_n_max_vcpus; + qemu_plugin_outs; }; diff --git a/util/log.c b/util/log.c index 1d1b33f7d9..1ca13059ee 100644 --- a/util/log.c +++ b/util/log.c @@ -273,6 +273,9 @@ const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_NOCHAIN, "nochain", "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" }, +#ifdef CONFIG_PLUGIN + { CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"}, +#endif { 0, NULL, NULL }, };