Commit 036d9239 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

env/dpdk: do not clean up DPDK 18.05 shared files



eal_get_runtime_dir() that we used so far is not
available in DPDK shared libraries, so we remove
its usages in SPDK together with the functionality
of removing files left over by DPDK. Luckily for
us, this only affects DPDK 18.05, as for DPDK 18.08+
the --no-shconf option that we use prevents all
those files from being created whatsoever.

Change-Id: I078fb7686d2445a6acb067b0c3762a9c99f9a429
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/426218


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarLance Hartmann <lance.hartmann@oracle.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e42bb743
Loading
Loading
Loading
Loading
+5 −27
Original line number Diff line number Diff line
@@ -100,42 +100,20 @@ _sprintf_alloc(const char *format, ...)
	return NULL;
}

#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0)
const char *eal_get_runtime_dir(void);
#endif

static void
spdk_env_unlink_shared_files(void)
{
	/* Starting with DPDK 18.05, there are more files with unpredictable paths
	 * and filenames. The --no-shconf option prevents from creating them, but
	 * only for DPDK 18.08+. For DPDK 18.05 we just leave them be.
	 */
#if RTE_VERSION < RTE_VERSION_NUM(18, 05, 0, 0)
	char buffer[PATH_MAX];

#if RTE_VERSION < RTE_VERSION_NUM(18, 05, 0, 0)
	snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_hugepage_info", getpid());
	if (unlink(buffer)) {
		fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno);
	}
#else
	DIR *dir;
	struct dirent *d;

	dir = opendir(eal_get_runtime_dir());
	if (!dir) {
		fprintf(stderr, "Failed to open DPDK runtime dir: %s (%d)\n", eal_get_runtime_dir(), errno);
		return;
	}

	while ((d = readdir(dir)) != NULL) {
		if (d->d_type != DT_REG) {
			continue;
		}

		snprintf(buffer, PATH_MAX, "%s/%s", eal_get_runtime_dir(), d->d_name);
		if (unlink(buffer)) {
			fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno);
		}
	}

	closedir(dir);
#endif
}