examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager
PATCH 1/1 examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager
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.
--- examples/vm_power_manager/channel_manager.c | 27 ++++++++++++++++++++- examples/vm_power_manager/channel_manager.h | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-)
examples/vm_power_manager/channel_manager.c +26 -1
@@ -420,8 +420,33 @@ add_all_channels(const char *vm_name)if (d ==NULL ) {RTE_LOG (ERR ,CHANNEL_MANAGER ,"Error opening directory '%s': %s\n" ,CHANNEL_MGR_SOCKET_PATH ,strerror (errno)); -return -1 ; + +const char *run_dpdk ="/run/dpdk" ; +struct stat path_stat; +int ret; + +if (stat (run_dpdk, &path_stat) !=0 ) { + ret =mkdir (run_dpdk,0700 ); +if (ret <0 && errno !=EEXIST ) { +RTE_LOG (ERR ,CHANNEL_MANAGER ,"Error creating '%s': %s" , + run_dpdk,strerror (errno)); +return -1 ; + } + } + +/* Make sure /run/dpdk is a directory */ +if (!S_ISDIR (path_stat.st_mode)) { +return -1 ; + } + + ret =mkdir (CHANNEL_MGR_SOCKET_PATH ,0700 ); +if (ret <0 && errno !=EEXIST ) { +RTE_LOG (ERR ,CHANNEL_MANAGER ,"Error creating '%s': %s" , +CHANNEL_MGR_SOCKET_PATH ,strerror (errno)); +return -1 ; + } } +while ((dir =readdir (d)) !=NULL ) {if (!strncmp (dir->d_name,"." ,1 ) || !strncmp (dir->d_name,".." ,2 ))
examples/vm_power_manager/channel_manager.h +1 -1
@@ -22,7 +22,7 @@ extern "C" {#define CHANNEL_MGR_DEFAULT_HV_PATH "qemu:///system"/* File socket directory */ -#define CHANNEL_MGR_SOCKET_PATH "/tmp/powermonitor/" +#define CHANNEL_MGR_SOCKET_PATH "/run/dpdk/powermonitor/"/* FIFO file name template */ #define CHANNEL_MGR_FIFO_PATTERN_NAME "fifo"
Signature · 1 line
2.43.0
Quoted 10 lines · On Thu, 28 May 2026 19:04:48 +0000 Sudheendra Sampath <[email protected]>…
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually a directory before creating subdirectory, powermanager.All directory permissions are 0700.
Signed-off-by Sudheendra Sampath <[email protected]>---
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
Quoted 6 lines · Sudheendra Sampath
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually a directory before creating subdirectory, powermanager.
I would suggest using $XDG_RUNTIME_DIR for the directory path, rather than hardcoding it by default. If XDG_RUNTIME_DIR is not set, then maybe consider using /run/dpdk. However, rather than /run/dpdk, I'd suggest using the normal runtime dir path on most distros as the default:
/run/user/<uid>.
/Bruce
Quoted 7 lines · On Fri, 29 May 2026 09:01:34 +0100 Bruce Richardson…
Quoted 6 lines · Sudheendra Sampath
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually a directory before creating subdirectory, powermanager.
Quoted 7 lines
I would suggest using $XDG_RUNTIME_DIR for the directory path, rather than hardcoding it by default. If
XDG_RUNTIME_DIRis not set, then maybe consider using/run/dpdk. However, rather than/run/dpdk, I'd suggest using the normal runtime dir path on most distros as the default:
/run/user/<uid>./Bruce
The login in EAL is a little more detailed.
The choice is from systemd conventions which follows filesystem hierarchy.
int eal_create_runtime_dir(void)
{
const char *directory;
char run_dir[PATH_MAX];
char tmp[PATH_MAX];
int ret;
/* from RuntimeDirectory= see systemd.exec */
directory = getenv("RUNTIME_DIRECTORY");
if (directory == NULL) {
/*
* Used standard convention defined in
* XDG Base Directory Specification and
* Filesystem Hierarchy Standard.
*/
if (getuid() == 0)
directory = "/var/run";
else
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)) {
EAL_LOG(ERR, "Error creating DPDK runtime path name");
return -1;
}
/* create prefix-specific subdirectory under DPDK runtime dir */
ret = snprintf(run_dir, sizeof(run_dir), "%s/%s",
tmp, eal_get_hugefile_prefix());
if (ret < 0 || ret == sizeof(run_dir)) {
EAL_LOG(ERR, "Error creating prefix-specific runtime path name");
return -1;
}
/* create the path if it doesn't exist. no "mkdir -p" here, so do it
* step by step.
*/
ret = mkdir(tmp, 0700);
if (ret < 0 && errno != EEXIST) {
EAL_LOG(ERR, "Error creating '%s': %s",
tmp, strerror(errno));
return -1;
}
ret = mkdir(run_dir, 0700);
if (ret < 0 && errno != EEXIST) {
EAL_LOG(ERR, "Error creating '%s': %s",
run_dir, strerror(errno));
return -1;
}Quoted 66 lines · Stephen Hemminger
Quoted 7 lines · On Fri, 29 May 2026 09:01:34 +0100 Bruce Richardson…
Quoted 6 lines · Sudheendra Sampath
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually a directory before creating subdirectory, powermanager.Quoted 7 lines
I would suggest using $XDG_RUNTIME_DIR for the directory path, rather than hardcoding it by default. If
XDG_RUNTIME_DIRis not set, then maybe consider using/run/dpdk. However, rather than/run/dpdk, I'd suggest using the normal runtime dir path on most distros as the default:
/run/user/<uid>./Bruce
The login in EAL is a little more detailed.
The choice is from systemd conventions which follows filesystem hierarchy.int
eal_create_runtime_dir(void){ const char *directory; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; /* from RuntimeDirectory= see systemd.exec */ directory = getenv("RUNTIME_DIRECTORY"); if (directory == NULL) { /* * Used standard convention defined in * XDG Base Directory Specification and * Filesystem Hierarchy Standard. */ if (getuid() == 0) directory = "/var/run"; else 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)) { EAL_LOG(ERR, "Error creating DPDK runtime path name"); return -1; } /* create prefix-specific subdirectory under DPDK runtime dir */ ret = snprintf(run_dir, sizeof(run_dir), "%s/%s", tmp, eal_get_hugefile_prefix()); if (ret < 0 || ret == sizeof(run_dir)) { EAL_LOG(ERR, "Error creating prefix-specific runtime path name"); return -1; } /* create the path if it doesn't exist. no "mkdir -p" here, so do it * step by step. */ ret = mkdir(tmp, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", tmp, strerror(errno)); return -1;
Quoted 8 lines
}
ret = mkdir(run_dir, 0700);
if (ret < 0 && errno != EEXIST) {
EAL_LOG(ERR, "Error creating '%s': %s",
run_dir, strerror(errno));
return -1;
}Yes. Can the power manager call the rte_eal_get_runtime_dir() API and use that as a basis for its working directory? Save duplicating all this logic.
/Bruce
Re: [PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermonitor
*Note: Changed subject line from /run/dpdk/powermanager -> /run/dpdk/powermonitor*
Hi All,
Apologies for the delay.
So, I am following the above thread and below are what I understand are the changes that are needed :
1. I see that rte_eal_get_runtime_dir() is RTE_EXPORTED_SYMBOL. I will verify that channel_manager has access to this symbol.
2. Upon successful creation of /run/dpdk, I can mkdir CHANNEL_MGR_SOCKET_PATH (/var/run/dpdk/powermonitor) and opendir() that for subsequent processing.
3. Fixup the documentation to reflect correct powermonitor path
Please let me know if I am missing anything or if I misinterpreting any part of the email exchange.
Thanks for all your help and support.
-Sudheendra G Sampath
Quoted 87 lines · Bruce Richardson
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 29 May 2026 09:01:34 +0100 Bruce Richardson…
Quoted 4 lines · Sudheendra Sampath
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually adirectory
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
before creating subdirectory, powermanager.
I would suggest using $XDG_RUNTIME_DIR for the directory path, rather
than
Quoted 2 lines
Quoted 2 lines
hardcoding it by default. If
XDG_RUNTIME_DIRis not set, then maybe consider using/run/dpdk. However, rather than/run/dpdk, I'd suggestusing
Quoted 7 lines
Quoted 4 lines
the normal runtime dir path on most distros as the default:
/run/user/<uid>./Bruce
The login in EAL is a little more detailed.
The choice is from systemd conventions which follows filesystemhierarchy.
Quoted 27 lines
int
eal_create_runtime_dir(void){ const char *directory; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; /* from RuntimeDirectory= see systemd.exec */ directory = getenv("RUNTIME_DIRECTORY"); if (directory == NULL) { /* * Used standard convention defined in * XDG Base Directory Specification and * Filesystem Hierarchy Standard. */ if (getuid() == 0) directory = "/var/run"; else 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)) { EAL_LOG(ERR, "Error creating DPDK runtime path name");Quoted 8 lines
return -1; } /* create prefix-specific subdirectory under DPDK runtime dir */ ret = snprintf(run_dir, sizeof(run_dir), "%s/%s", tmp, eal_get_hugefile_prefix()); if (ret < 0 || ret == sizeof(run_dir)) { EAL_LOG(ERR, "Error creating prefix-specific runtime pathname");
Quoted 4 lines
return -1; } /* create the path if it doesn't exist. no "mkdir -p" here, so doit
Quoted 7 lines
* step by step. */ ret = mkdir(tmp, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", tmp, strerror(errno)); return -1;Quoted 8 lines
} ret = mkdir(run_dir, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", run_dir, strerror(errno)); return -1; }Yes. Can the power manager call the
rte_eal_get_runtime_dir()API and use that as a basis for its working directory? Save duplicating all this logic./Bruce
Re: [PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermonitor
Hi Stephen,
I appreciate any feedback so that I can make changes and send out the patch.
Thanks
Quoted 117 lines · Sudheendra S
*Note: Changed subject line from
/run/dpdk/powermanager->/run/dpdk/powermonitor*Hi All,
Apologies for the delay.
So, I am following the above thread and below are what I understand are the changes that are needed :
1. I see that
rte_eal_get_runtime_dir()isRTE_EXPORTED_SYMBOL. I will verify thatchannel_managerhas access to this symbol.
2. Upon successful creation of/run/dpdk, I can mkdirCHANNEL_MGR_SOCKET_PATH(/var/run/dpdk/powermonitor) andopendir()that for subsequent processing.
3. Fixup the documentation to reflect correct powermonitor pathPlease let me know if I am missing anything or if I misinterpreting any part of the email exchange.
Thanks for all your help and support.
-Sudheendra G Sampath
Quoted 88 lines · Bruce Richardson
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 29 May 2026 09:01:34 +0100 Bruce Richardson…
Quoted 4 lines · Sudheendra Sampath
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually adirectory
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
before creating subdirectory, powermanager.
I would suggest using $XDG_RUNTIME_DIR for the directory path, rather
than
Quoted 2 lines
Quoted 2 lines
hardcoding it by default. If
XDG_RUNTIME_DIRis not set, then maybe consider using/run/dpdk. However, rather than/run/dpdk, I'd suggestusing
Quoted 7 lines
Quoted 4 lines
the normal runtime dir path on most distros as the default:
/run/user/<uid>./Bruce
The login in EAL is a little more detailed.
The choice is from systemd conventions which follows filesystemhierarchy.
Quoted 27 lines
int
eal_create_runtime_dir(void){ const char *directory; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; /* from RuntimeDirectory= see systemd.exec */ directory = getenv("RUNTIME_DIRECTORY"); if (directory == NULL) { /* * Used standard convention defined in * XDG Base Directory Specification and * Filesystem Hierarchy Standard. */ if (getuid() == 0) directory = "/var/run"; else 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)) { EAL_LOG(ERR, "Error creating DPDK runtime path name");Quoted 8 lines
return -1; } /* create prefix-specific subdirectory under DPDK runtime dir */ ret = snprintf(run_dir, sizeof(run_dir), "%s/%s", tmp, eal_get_hugefile_prefix()); if (ret < 0 || ret == sizeof(run_dir)) { EAL_LOG(ERR, "Error creating prefix-specific runtime pathname");
Quoted 4 lines
return -1; } /* create the path if it doesn't exist. no "mkdir -p" here, so doit
Quoted 7 lines
* step by step. */ ret = mkdir(tmp, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", tmp, strerror(errno)); return -1;Quoted 8 lines
} ret = mkdir(run_dir, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", run_dir, strerror(errno)); return -1; }Yes. Can the power manager call the
rte_eal_get_runtime_dir()API and use that as a basis for its working directory? Save duplicating all this logic./Bruce
Hi Stephen,
I totally understand that you and the team are very busy. I hope to get some direction since this is first time ever to be submitting a patch to DPDK.
From what I understand from the above email exchange changes needed are :
1. I see that rte_eal_get_runtime_dir() is RTE_EXPORTED_SYMBOL. I will verify that channel_manager has access to this symbol.
2. Upon successful creation of /run/dpdk, I can mkdir CHANNEL_MGR_SOCKET_PATH (/var/run/dpdk/powermonitor) and opendir() that for subsequent processing.
3. Fixup the documentation to reflect correct powermonitor path
Please let me know if I am missing anything or if I misinterpreting any part of the email exchange.
Appreciate your timely help and support.
Quoted 87 lines · Bruce Richardson
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 29 May 2026 09:01:34 +0100 Bruce Richardson…
Quoted 4 lines · Sudheendra Sampath
This patch for bug 1832 will do the following:
1. If/run/dpdkis not present, it will create it first with and then create powermanager directory underneath it.
2. If/run/dpdkis present, it will verify it is actually adirectory
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
before creating subdirectory, powermanager.
I would suggest using $XDG_RUNTIME_DIR for the directory path, rather
than
Quoted 2 lines
Quoted 2 lines
hardcoding it by default. If
XDG_RUNTIME_DIRis not set, then maybe consider using/run/dpdk. However, rather than/run/dpdk, I'd suggestusing
Quoted 7 lines
Quoted 4 lines
the normal runtime dir path on most distros as the default:
/run/user/<uid>./Bruce
The login in EAL is a little more detailed.
The choice is from systemd conventions which follows filesystemhierarchy.
Quoted 27 lines
int
eal_create_runtime_dir(void){ const char *directory; char run_dir[PATH_MAX]; char tmp[PATH_MAX]; int ret; /* from RuntimeDirectory= see systemd.exec */ directory = getenv("RUNTIME_DIRECTORY"); if (directory == NULL) { /* * Used standard convention defined in * XDG Base Directory Specification and * Filesystem Hierarchy Standard. */ if (getuid() == 0) directory = "/var/run"; else 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)) { EAL_LOG(ERR, "Error creating DPDK runtime path name");Quoted 8 lines
return -1; } /* create prefix-specific subdirectory under DPDK runtime dir */ ret = snprintf(run_dir, sizeof(run_dir), "%s/%s", tmp, eal_get_hugefile_prefix()); if (ret < 0 || ret == sizeof(run_dir)) { EAL_LOG(ERR, "Error creating prefix-specific runtime pathname");
Quoted 4 lines
return -1; } /* create the path if it doesn't exist. no "mkdir -p" here, so doit
Quoted 7 lines
* step by step. */ ret = mkdir(tmp, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", tmp, strerror(errno)); return -1;Quoted 8 lines
} ret = mkdir(run_dir, 0700); if (ret < 0 && errno != EEXIST) { EAL_LOG(ERR, "Error creating '%s': %s", run_dir, strerror(errno)); return -1; }Yes. Can the power manager call the
rte_eal_get_runtime_dir()API and use that as a basis for its working directory? Save duplicating all this logic./Bruce