All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sudheendra Sampath <giveback4fun@gmail.com>
To: dev@dpdk.org
Cc: Sudheendra Sampath <giveback4fun@gmail.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>,
	Sivaprasad Tummala <sivaprasad.tummala@amd.com>
Subject: [PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager
Date: Thu, 28 May 2026 19:04:48 +0000	[thread overview]
Message-ID: <20260528190449.66254-1-giveback4fun@gmail.com> (raw)

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


             reply	other threads:[~2026-05-28 19:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 19:04 Sudheendra Sampath [this message]
2026-05-28 21:10 ` [PATCH] examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager Stephen Hemminger
2026-05-29  8:01 ` Bruce Richardson
2026-05-29 15:23   ` Stephen Hemminger
2026-05-29 16:01     ` Bruce Richardson

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=20260528190449.66254-1-giveback4fun@gmail.com \
    --to=giveback4fun@gmail.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=sivaprasad.tummala@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.