From patchwork Tue Jun 2 15:46:22 2020 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: 187374 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp4091052ilb; Tue, 2 Jun 2020 08:50:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXp8qKrdgzpfegrpMrgFfRTs+5Ay/d7T+HtUXxcCsszeHupS7d8O+gYVEsBnx75sU4Lrf/ X-Received: by 2002:a25:69c3:: with SMTP id e186mr18563448ybc.445.1591113033865; Tue, 02 Jun 2020 08:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591113033; cv=none; d=google.com; s=arc-20160816; b=n8LGaMb+weWH28nfIe7cuZN2NBn+6+UgYoFmt2tIoxb9oNVdWwdI6KdCBrO8TLcMo7 3lQ03HrrMqgun20JCs+apPtwHQNXS0o21axegLYtHnAwL/Mie1hEWKQN+VkBlQ9SPkfZ q8vSArjeX8ap2hD9Gr7p9LVAEhdzg8C8Zq/GIZ8DwXiuHYo77SDbNX2d4lhYZZbBEBW8 /L2DO9bMRkXJaCsMNJd9kYE+jZEEQ2QdYd26WZryBWu2CALNISK1+tqNW43HaPHEfe6D wzYT8HL3QXt5Ph+gWm6h1VfHlz0E6Xc+7Ze8Lm2QK7sqwy38xKgqZepXQABZMDwZitwJ HJVQ== 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=D98gPKyXYpHfK2vdgoTLIOCcijD4DQVmE2DVfMIiR4I=; b=CUIBkfbxxGalYGAVapD1ixR7UwOtVhFrlIKEhUlQw5u3Pog4yOOACcVRLYPDvztmd5 DOzQVdMCGtZFous4pO8D2tXAN6Ey3oU3H/G6BwFXhu8BuJNmrDxOTifVMyjRkzcDmae1 eRaZ8SBl9yz0v7Jh02uG/2yzZW3Nipgs7s6JCfqgnmVa8x3bMkBfYSdE9jwJijGEBxR0 KsloZ83vw8HNAlkKYB2d68yOy234a1DVaF/fj2G72Gn50gMOtUSc6SNnShOM1+f+DS7C hwcxEtEa9BUFE0onsYrFywnPJYgCbWe0+ln4G7EwgeF9KVXezGa3Vf7bbHZzpQZGGpkg XDSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ul2p1678; 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 a3si2447897ybp.308.2020.06.02.08.50.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jun 2020 08:50:33 -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=Ul2p1678; 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]:39830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg9BR-0000EZ-BH for patch@linaro.org; Tue, 02 Jun 2020 11:50:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg97f-0003jI-4q for qemu-devel@nongnu.org; Tue, 02 Jun 2020 11:46:39 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jg97e-0007da-0N for qemu-devel@nongnu.org; Tue, 02 Jun 2020 11:46:38 -0400 Received: by mail-wr1-x441.google.com with SMTP id x13so3922638wrv.4 for ; Tue, 02 Jun 2020 08:46:37 -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=D98gPKyXYpHfK2vdgoTLIOCcijD4DQVmE2DVfMIiR4I=; b=Ul2p16782znMcbsKpUw0Xm/g/AeHDL2ZSBciVmljZk8//OPHCBdPCJk8dnfLFihx06 XODtINTxB+ww5N3Dtuh/8jUv4RxmvrXbstAVsUpELiIGNfjDYIFW9AQSOkteAEw10Y1c dA3YpTnWkBxU99/HzeQlDImeyyGJG8OVaPOR0orp2UqLxt5YuJvBy4kO2VgYUWkyXDTD VC4HANX9Uy5euDTNSBVdaSXJcR/0MZm+AAdNyEPdKDtZO74FG1CUChHAPLq2wI3wuNrc Jq+1IITF1y1vW4m90iDZt4Hp+8lksjqrnrPRstKfug1T+Ozwip98K4crr0vxr+B4mHTS 4eYQ== 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=D98gPKyXYpHfK2vdgoTLIOCcijD4DQVmE2DVfMIiR4I=; b=Hm2D5bMNFVfKI54TmKszaFBe9fr/JKHSC79X11rUzsRJmKTQMlrQ15KFT1imomxn57 2/69NMOoDIpYHsdwy7SVCp34ZSXxP632zpcNNezFF5vSRHlwyQYHMXxWsDO6736Rylj8 vBxTvJl6V5yOAt4w2N3D+7Ij9pKnJDgA/TrB3axmyfn5d7EdRgjZl5w/J+zWPs6UBRqo IJFC1QDLoHrG571ik0Rn1HaDRjrYMfGlj4s7aeEYseeB9lTQRvTev/Su1lCLTfG9SBtE 73vRzdEBAz1wqzgmcH5Ks0fOn9WcrbaDz83NNFK+yQIauv8+wa79wahud9tFYQ2lpOzO DuTQ== X-Gm-Message-State: AOAM530spmD5C4eoWXg8JibMuWZEEW1W4pqEVYP4kZh4+q58LFpp2auK /4PpD6l9OVSK9mg+wjfvYn8J+w== X-Received: by 2002:adf:a50e:: with SMTP id i14mr15141142wrb.21.1591112796558; Tue, 02 Jun 2020 08:46:36 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l17sm186818wmi.16.2020.06.02.08.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 08:46:32 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D7B241FF93; Tue, 2 Jun 2020 16:46:24 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 7/9] plugins: add API to return a name for a IO device Date: Tue, 2 Jun 2020 16:46:22 +0100 Message-Id: <20200602154624.4460-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200602154624.4460-1-alex.bennee@linaro.org> References: <20200602154624.4460-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x441.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: robert.foley@linaro.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This may well end up being anonymous but it should always be unique. Signed-off-by: Alex Bennée --- include/qemu/qemu-plugin.h | 5 +++++ plugins/api.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) -- 2.20.1 Reviewed-by: Clement Deschamps Reviewed-by: Emilio G. Cota diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index bab8b0d4b3a..43c6a9e857f 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -335,6 +335,11 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, 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); +/* + * Returns a string representing the device. Plugin must free() it + */ +char * qemu_plugin_hwaddr_device_name(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, diff --git a/plugins/api.c b/plugins/api.c index bbdc5a4eb46..3c73de8c1c2 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -303,6 +303,24 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr return 0; } +char * qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *haddr) +{ +#ifdef CONFIG_SOFTMMU + if (haddr && haddr->is_io) { + MemoryRegionSection *mrs = haddr->v.io.section; + if (!mrs->mr->name) { + return g_strdup_printf("anon%08lx", 0xffffffff & (uintptr_t) mrs->mr); + } else { + return g_strdup(mrs->mr->name); + } + } else { + return g_strdup("RAM"); + } +#else + return g_strdup("Invalid"); +#endif +} + /* * Queries to the number and potential maximum number of vCPUs there * will be. This helps the plugin dimension per-vcpu arrays.