DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager
@ 2026-05-28 19:04 Sudheendra Sampath
  2026-05-28 21:10 ` Stephen Hemminger
  2026-05-29  8:01 ` Bruce Richardson
  0 siblings, 2 replies; 5+ messages in thread
From: Sudheendra Sampath @ 2026-05-28 19:04 UTC (permalink / raw)
  To: dev; +Cc: Sudheendra Sampath, Anatoly Burakov, Sivaprasad Tummala

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@gmail.com>
---
 examples/vm_power_manager/channel_manager.c | 27 ++++++++++++++++++++-
 examples/vm_power_manager/channel_manager.h |  2 +-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
index b69449c61d..60d767ea98 100644
--- a/examples/vm_power_manager/channel_manager.c
+++ b/examples/vm_power_manager/channel_manager.c
@@ -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))
diff --git a/examples/vm_power_manager/channel_manager.h b/examples/vm_power_manager/channel_manager.h
index 6f70539815..5fc93ae0be 100644
--- a/examples/vm_power_manager/channel_manager.h
+++ b/examples/vm_power_manager/channel_manager.h
@@ -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"
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-29 16:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28 19:04 [PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager Sudheendra Sampath
2026-05-28 21:10 ` Stephen Hemminger
2026-05-29  8:01 ` Bruce Richardson
2026-05-29 15:23   ` Stephen Hemminger
2026-05-29 16:01     ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox