[PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager

Stephen Hemminger stephen at networkplumber.org
Thu May 28 23:10:16 CEST 2026


On Thu, 28 May 2026 19:04:48 +0000
Sudheendra Sampath <giveback4fun at gmail.com> wrote:

> This patch for bug 1832 will do the following:
> 1.  If /run/dpdk is not present, it will create it first with and
>     then create powermanager directory underneath it.
> 2.  If /run/dpdk is present, it will verify it is actually a directory
>     before creating subdirectory, powermanager.
> 
> All directory permissions are 0700.
> 
> Signed-off-by: Sudheendra Sampath <giveback4fun at gmail.com>
> ---

Lots of issues with hardcoding the path here.
Longer explanation from AI review.


Thanks for the patch. A few issues to address before this can be merged:

Two correctness bugs in the new recovery block:

- After creating the directories, d is still NULL but the code falls through to readdir(d). The recovery path must call opendir() again (and return -1 if that also fails) before the readdir loop.

- path_stat is only populated when stat() succeeds. The S_ISDIR(path_stat.st_mode) check runs on uninitialised memory when stat() returned an error and mkdir() was used. Restructure as if (stat(...) == 0) { check S_ISDIR } else { mkdir }.

Other items:

- doc/guides/sample_app_ug/vm_power_management.rst still references /tmp/powermonitor/ in several places; code and docs need to change together.

- Hardcoding /run/dpdk does not follow the DPDK runtime-dir convention and breaks non-root usage. 
  Please consider using rte_eal_get_runtime_dir() (or at least the same getuid() / RUNTIME_DIRECTORY logic as eal_create_runtime_dir()) instead.

- Subject says "powermanager" but the path is "powermonitor".

- The two new RTE_LOG messages are missing trailing "\n".

- Please add a proper Fixes: tag (12-char hash) for the commit that introduced /tmp/powermonitor.

Stephen


More information about the dev mailing list