DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Robin Jarry <rjarry@redhat.com>,
	Chengwen Feng <fengchengwen@huawei.com>
Subject: [PATCH] usertools/telemetry: load aliases from config directory
Date: Fri, 17 Jul 2026 11:16:03 +0200	[thread overview]
Message-ID: <20260717091603.1492650-1-thomas@monjalon.net> (raw)

The default path of the telemetry alias file
was at the top level of the home directory.

Load aliases from the DPDK configuration directory instead,
using $XDG_CONFIG_HOME/dpdk/telemetry_aliases
or $HOME/.config/dpdk/telemetry_aliases.

Keep --alias-file for users who want to provide an explicit path.

Fixes: 410d498412e4 ("usertools/telemetry: support aliases for long commands")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 doc/guides/howto/telemetry.rst |  6 ++++--
 usertools/dpdk-telemetry.py    | 23 +++++++++++++++++------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/doc/guides/howto/telemetry.rst b/doc/guides/howto/telemetry.rst
index b3f25c1113..fdaede1987 100644
--- a/doc/guides/howto/telemetry.rst
+++ b/doc/guides/howto/telemetry.rst
@@ -154,9 +154,11 @@ and query information using the telemetry client python script.
 
      The telemetry script can load aliases at startup from::
 
-        $HOME/.dpdk_telemetry_aliases
+        $XDG_CONFIG_HOME/dpdk/telemetry_aliases
+
+     If ``XDG_CONFIG_HOME`` is not set, ``$HOME/.config/dpdk/telemetry_aliases`` is used.
+     A custom path can also be provided via the ``--alias-file`` script flag.
 
-     or from a custom path provided via the ``--alias-file`` script flag.
      Each alias entry must be in ``alias=command`` format.
      Empty lines and lines starting with ``#`` are ignored.
 
diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py
index 20627b596b..e575f269cb 100755
--- a/usertools/dpdk-telemetry.py
+++ b/usertools/dpdk-telemetry.py
@@ -22,7 +22,7 @@
 DEFAULT_PREFIX = "rte"
 CMDS = []
 ALIASES = {}
-ALIAS_FILE = ".dpdk_telemetry_aliases"
+ALIAS_FILE = "telemetry_aliases"
 MAX_ALIAS_EXPANSIONS = 32
 
 BASIC_HELP_TEXT = """Basic usage:
@@ -46,19 +46,30 @@
 """
 
 
+def get_default_alias_path():
+    config_home = os.environ.get("XDG_CONFIG_HOME")
+    if config_home:
+        return os.path.join(config_home, "dpdk", ALIAS_FILE)
+
+    home = os.environ.get("HOME")
+    if not home:
+        return None
+
+    return os.path.join(home, ".config", "dpdk", ALIAS_FILE)
+
+
 def load_aliases(alias_path=None):
-    """Load aliases from $HOME/.dpdk_telemetry_aliases or a custom path if provided"""
+    """Load aliases from the config directory or a custom path if provided"""
     aliases = {}
     if alias_path and not os.path.isfile(alias_path):
         print("Warning: alias file {} not found, skipping".format(alias_path), file=sys.stderr)
         return aliases
 
     if not alias_path:
-        home = os.environ.get("HOME")
-        if not home:
+        alias_path = get_default_alias_path()
+        if not alias_path:
             return aliases
 
-        alias_path = os.path.join(home, ALIAS_FILE)
         if not os.path.isfile(alias_path):
             return aliases
 
@@ -434,7 +445,7 @@ def readline_complete(text, state):
 )
 parser.add_argument(
     "--alias-file",
-    help=f"Provide a custom alias file instead of $HOME/{ALIAS_FILE}",
+    help="Provide a custom alias file instead of the default config path",
 )
 parser.add_argument(
     "-i", "--instance", default="0", type=int, help="Provide instance number for DPDK application"
-- 
2.54.0


             reply	other threads:[~2026-07-17  9:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  9:16 Thomas Monjalon [this message]
2026-07-17  9:37 ` [PATCH] usertools/telemetry: load aliases from config directory Bruce Richardson
2026-07-17 13:36   ` Thomas Monjalon
2026-07-17  9:38 ` Robin Jarry
2026-07-17  9:40 ` fengchengwen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260717091603.1492650-1-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=rjarry@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox