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

Stephen Hemminger stephen at networkplumber.org
Fri May 29 17:23:24 CEST 2026


On Fri, 29 May 2026 09:01:34 +0100
Bruce Richardson <bruce.richardson at intel.com> wrote:

> On Thu, May 28, 2026 at 07:04:48PM +0000, Sudheendra Sampath 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.
> >   
> 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

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;
	}


More information about the dev mailing list