From nobody Tue Feb 10 04:08:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1599228046; cv=none; d=zohomail.com; s=zohoarc; b=ME7OxTLkZfvp7A8FXHf7Rl2O1bbUk7JIR3JAee6ITnJEApf4a/3DL6/3SG5+DToeaoM3nPqxmtp1u+xB13GXkOd/d3TI+EGuLNr91PcnLMAFIOzRW9Nfd+qz5Qav9SxjLhgPNzcS7jpXPvoCd16DHpiMNf+9zvg9+ZHMla0oU3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599228046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5tQ4ZXGvdfdBTzlqZAhvWucrTP7Qmtc8hcYRkk0NrFQ=; b=X26eYsqvj0N/jVQ0L5scod/i8oMeKavCnbGfIaJCLGpH5KzS1xwpUCFlJRk40Zdr9C06Di0igNlFwPdZkKtzrlU5mMS1AkqhIiW6lQEXZwC/073deh3zOYxO9rwWSbR2RJqN5hMhFhmfWkM+x3mIowfs6hs3sbjmQq2T9YD8I4s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599228046111512.1442067518766; Fri, 4 Sep 2020 07:00:46 -0700 (PDT) Received: from localhost ([::1]:34174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEC1a-0003v8-At for importer@patchew.org; Fri, 04 Sep 2020 09:45:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEBwu-0004zS-NP for qemu-devel@nongnu.org; Fri, 04 Sep 2020 09:40:16 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:39641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kEBws-0005gh-47 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 09:40:16 -0400 Received: by mail-wr1-x429.google.com with SMTP id a17so6780730wrn.6 for ; Fri, 04 Sep 2020 06:40:13 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l126sm10845098wmf.39.2020.09.04.06.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 06:40:08 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EF9E71FF8C; Fri, 4 Sep 2020 14:40:07 +0100 (BST) 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=5tQ4ZXGvdfdBTzlqZAhvWucrTP7Qmtc8hcYRkk0NrFQ=; b=n8Z9ul2wtO97Pg9kJ6tfUwtMZiWCH7NTHwxRPx2z2FLGkdYBhbYXXuIaGeu+GCmZSY bSgLX/ehJlL8KqaEx3+RUC39J3ZVZnIBRk28DbMyKHPCrKHweavj1YPX43RnS1EdQd2j wsUASGtqFsic+CvSPImFeywCPXYewdJG/z+q87pTxQsjcD/y73/joPMEduzDSV8mRVTW at1HVmRWtTcSzeXyv7rAclVbOrrkmqxLeBeyTTOaPKs+aUI0MnGic9odqjGim0XZ3JrG n/qYJFNDnNne2GeZ5M6OFd84qmb6aIdJVHcYAAyquM6EUU5UJ/5aGOOIp1OwzlGXq9PA w1MA== 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=5tQ4ZXGvdfdBTzlqZAhvWucrTP7Qmtc8hcYRkk0NrFQ=; b=miUWWdzFbGK3BhHXBxiskMvnGmY4kO5vCtLCrnp967dM5HuTXsGy8jWq6TJLqTuTU7 Z7+q3CysFwSNChrlK9hsvjGLaorcQoM8EHzgiaBcpV3RUidtAZ0aes83M9Q8hCXP8Sjs thCea7xHxdDPXeIJqi6H29PBGQyjXbu1y/hTz5lUBus7OOKbCgViMxqN116PDU0HjPO5 I2RPEowo9a1VmSo3dZyvIkyip3Y+k/GDyVrN7FlIABJHQMATjEsViqyIFsAxcg04k5ar xYAMl4+bne5a/kNilHlCdPRYkoA5kDN56uTzJz+6mJfY+KwRbTNEEoLmsEvJGOLt+ZV4 WbPw== X-Gm-Message-State: AOAM532fMBV9r4QLaWRFBndU1olPBoOuXWB/m0dDo13YzRs9veY5VZ25 vQi2kBjMRYmeCQaYMVq28072dQ== X-Google-Smtp-Source: ABdhPJz9PYghRMSgIa4EODs7pyrusNg+TdqSpivUsE/C2zggQs+ZEPkn5Hl5qxUe3ZAEYYL3JrQnNQ== X-Received: by 2002:adf:ff83:: with SMTP id j3mr7973000wrr.135.1599226812600; Fri, 04 Sep 2020 06:40:12 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 2/4] plugins: add API to return a name for a IO device Date: Fri, 4 Sep 2020 14:40:05 +0100 Message-Id: <20200904134007.4175-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200904134007.4175-1-alex.bennee@linaro.org> References: <20200904134007.4175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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_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: robert.foley@linaro.org, Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, Clement Deschamps , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This may well end up being anonymous but it should always be unique. Signed-off-by: Alex Benn=C3=A9e [r-b provisional given change to g_intern_string] Reviewed-by: Clement Deschamps Reviewed-by: Emilio G. Cota Reviewed-by: Richard Henderson Message-Id: <20200713200415.26214-11-alex.bennee@linaro.org> --- include/qemu/qemu-plugin.h | 6 ++++++ plugins/api.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index bab8b0d4b3a..c98c18d6b05 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -335,6 +335,12 @@ 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); =20 +/* + * Returns a string representing the device. The string is valid for + * the lifetime of the plugin. + */ +const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr= *h); + 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..4304e63f0cf 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -303,6 +303,26 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct= qemu_plugin_hwaddr *haddr return 0; } =20 +const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr= *h) +{ +#ifdef CONFIG_SOFTMMU + if (h && h->is_io) { + MemoryRegionSection *mrs =3D h->v.io.section; + if (!mrs->mr->name) { + unsigned long maddr =3D 0xffffffff & (uintptr_t) mrs->mr; + g_autofree char *temp =3D g_strdup_printf("anon%08lx", maddr); + return g_intern_string(temp); + } else { + return g_intern_string(mrs->mr->name); + } + } else { + return g_intern_string("RAM"); + } +#else + return g_intern_string("Invalid"); +#endif +} + /* * Queries to the number and potential maximum number of vCPUs there * will be. This helps the plugin dimension per-vcpu arrays. --=20 2.20.1