From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C7BE0A00C2; Thu, 3 Feb 2022 12:37:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FBB540143; Thu, 3 Feb 2022 12:37:17 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 3716940140 for ; Thu, 3 Feb 2022 12:37:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643888235; x=1675424235; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=DRpO8qiUindHH/N61yVAIrDTJJ/7oi7XwQMAUHnGP+0=; b=TUfii6+1t1kuiFsTIlnZqF/jZQ4RUyzbfAQiQC1tGMG/uZqcuoFIydup tWKpKJ6aNPC/OI+UfGa707xQxyNd3NP0bviBVHTvCQr+fkZHa71iJpjuN YSAY6w16JXct3+yOkOv96nou2sXmQcC90KCZ+LUZ+WMipKLwoQV7Zt7FK CvANdWSD4Za81pjsj+m3JDZIgH4WTMjYNeeSbsYZFxlVMRqcORldSRHtL vb+7vxvy32epor7374px0Myj6MwXBrDmAhSI5TuT4VuBaI1XnmG2/CGZK wEp3KSCpO+LKXA1ZpVbz1fdhfvSUqcE3TojaFenHqbGqOgGhGWhPbLAiK w==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="228093216" X-IronPort-AV: E=Sophos;i="5.88,339,1635231600"; d="scan'208";a="228093216" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 03:37:14 -0800 X-IronPort-AV: E=Sophos;i="5.88,339,1635231600"; d="scan'208";a="538710284" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.19.95]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 03 Feb 2022 03:37:13 -0800 Date: Thu, 3 Feb 2022 11:37:09 +0000 From: Bruce Richardson To: Stephen Hemminger Cc: dev@dpdk.org, Morten =?iso-8859-1?Q?Br=F8rup?= Subject: Re: [PATCH 2/2] eal: support systemd service convention for runtime directory Message-ID: References: <20211223233907.181033-1-stephen@networkplumber.org> <20220203060025.881552-1-stephen@networkplumber.org> <20220203060025.881552-3-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220203060025.881552-3-stephen@networkplumber.org> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Feb 02, 2022 at 10:00:25PM -0800, Stephen Hemminger wrote: > Systemd.exec supports configuring the runtime directory of a service > via RuntimeDirectory=. This creates the directory with the necessary > permissions which actual service may not have if running in container. > > The change to DPDK is to look for the environment RUNTIME_DIRECTORY > first and use that in preference to the fallback alternatives. > > Signed-off-by: Stephen Hemminger > Acked-by: Bruce Richardson > Reviewed-by: Morten Brørup > --- > lib/eal/linux/eal.c | 23 +++++++++++++---------- > usertools/dpdk-telemetry.py | 9 +++++++-- > 2 files changed, 20 insertions(+), 12 deletions(-) > > diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c > index f2551c64b10c..8a5723f3b3a7 100644 > --- a/lib/eal/linux/eal.c > +++ b/lib/eal/linux/eal.c > @@ -86,25 +86,28 @@ struct lcore_config lcore_config[RTE_MAX_LCORE]; > /* used by rte_rdtsc() */ > int rte_cycles_vmware_tsc_map; > > -static const char *default_runtime_dir = "/var/run"; > - > int > eal_create_runtime_dir(void) > { > - const char *directory = default_runtime_dir; > - const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); > - const char *fallback = "/tmp"; > + const char *directory; > char run_dir[PATH_MAX]; > char tmp[PATH_MAX]; > int ret; > > - if (getuid() != 0) { > - /* try XDG path first, fall back to /tmp */ > - if (xdg_runtime_dir != NULL) > - directory = xdg_runtime_dir; > + /* from RuntimeDirectory= see systemd.exec */ > + directory = getenv("RUNTIME_DIRECTORY"); > + if (directory == NULL) { > + /* > + * Used standard convention defined in > + * XDG Base Directory Specification and > + * Filesystem Hierachy Standard. > + */ > + if (getuid() == 0) > + directory = "/var/run"; > else > - directory = fallback; > + directory = getenv("XDG_RUNTIME_DIR") ? : "/tmp"; > } > + > /* create DPDK subdirectory under runtime dir */ > ret = snprintf(tmp, sizeof(tmp), "%s/dpdk", directory); > if (ret < 0 || ret == sizeof(tmp)) { > diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py > index 5b3bf83356c3..a49f0e76d07b 100755 > --- a/usertools/dpdk-telemetry.py > +++ b/usertools/dpdk-telemetry.py > @@ -75,9 +75,14 @@ def print_socket_options(prefix, paths): > def get_dpdk_runtime_dir(fp): > """ Using the same logic as in DPDK's EAL, get the DPDK runtime directory > based on the file-prefix and user """ > + run_dir = os.environ.get('RUNTIME_DIRECTORY') > + if run_dir: > + return run_dir This bit doesn't seem to match the EAL changes above, since in the EAL code you are still appending the "dpdk" suffixes to the value returned from RUNTIME_DIRECTORY. > if (os.getuid() == 0): > - return os.path.join('/var/run/dpdk', fp) > - return os.path.join(os.environ.get('XDG_RUNTIME_DIR', '/tmp'), 'dpdk', fp) > + run_dir = '/var/run' > + else: > + run_dir = os.environ.get('XDG_RUNTIME_DIR', '/tmp')) > + return os.path.join(run_dir, 'dpdk', fp) > > > def list_fp(): > -- > 2.34.1 >