From f240e2bf48445a4618fe3afea8df7fcc3739f378 Mon Sep 17 00:00:00 2001 From: Liang Yan Date: Thu, 16 May 2019 19:56:07 +0800 Subject: [PATCH] perf/nvmf: add config file path handling codes Change-Id: I27c8c4a03237c75761c75cce824a65fe3e4776db Signed-off-by: Liang Yan Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454760 Reviewed-by: John Kariuki Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Darek Stojaczyk Reviewed-by: Karol Latecki Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins --- scripts/perf/nvmf/README.md | 3 +++ scripts/perf/nvmf/run_nvmf.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/perf/nvmf/README.md b/scripts/perf/nvmf/README.md index 7cbce0819..035dd47f3 100644 --- a/scripts/perf/nvmf/README.md +++ b/scripts/perf/nvmf/README.md @@ -69,6 +69,9 @@ Run the script on the NVMe-oF target system: cd spdk sudo PYTHONPATH=$PYTHONPATH:$PWD/scripts scripts/perf/nvmf/run_nvmf.py +The script uses the config.json configuration file in the scripts/perf/nvmf directory by default. You can +specify a different configuration file at runtime as shown below: +sudo PYTHONPATH=$PYTHONPATH:$PWD/scripts scripts/perf/nvmf/run_nvmf.py /path/to/config file/json config file The script uses another spdk script (scripts/rpc.py) so we pass the path to rpc.py by setting the Python path as a runtime environment parameter. diff --git a/scripts/perf/nvmf/run_nvmf.py b/scripts/perf/nvmf/run_nvmf.py index 953181899..6c7418ca3 100755 --- a/scripts/perf/nvmf/run_nvmf.py +++ b/scripts/perf/nvmf/run_nvmf.py @@ -653,7 +653,14 @@ if __name__ == "__main__": spdk_zip_path = "/tmp/spdk.zip" target_results_dir = "/tmp/results" - with open("./scripts/perf/nvmf/config.json", "r") as config: + if (len(sys.argv) > 1): + config_file_path = sys.argv[1] + else: + script_full_dir = os.path.dirname(os.path.realpath(__file__)) + config_file_path = os.path.join(script_full_dir, "config.json") + + print("Using config file: %s" % config_file_path) + with open(config_file_path, "r") as config: data = json.load(config) initiators = []