From aaaa51dc3e4ffc0b4970f445d95b2e98f11e2468 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sun, 7 Nov 2021 11:59:33 +0000 Subject: [PATCH] nvme_gw_server: allow to change rpc socket address Previously it was supposed that you could change the address by using spdk_server_addr and spdk_port configuration parameters. But the parameters were used only by rcp client, while the spdk target was always started with the default socket address. This commit fixes it. Additionally, there is no sense to provide the port configuration option because the target is always listening on a unix socket only. So the two parameters spdk_server_addr and spdk_port are replaced with one rpc_socket. There is not much sense to add "spdk_" prefix to the option name, because it is in [spdk] section. And while here remove unused "all" argument in nvme_tgt command, which seemed to be unintentionally committed after testing with "-L all". Signed-off-by: Mykola Golub --- nvme_gw.config | 3 +-- nvme_gw_server.py | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/nvme_gw.config b/nvme_gw.config index c7f5f489..a73e5a77 100644 --- a/nvme_gw.config +++ b/nvme_gw.config @@ -25,8 +25,7 @@ client_cert = ./client.crt [spdk] -spdk_server_addr = /var/tmp/spdk.sock -spdk_port = 5260 +rpc_socket = /var/tmp/spdk.sock timeout = 60.0 log_level = ERROR conn_retries = 3 diff --git a/nvme_gw_server.py b/nvme_gw_server.py index 84abba61..5be2c267 100644 --- a/nvme_gw_server.py +++ b/nvme_gw_server.py @@ -35,8 +35,9 @@ def start_spdk(self): self.spdk_rpc = spdk_rpc spdk_tgt = self.nvme_config.get("config", "spdk_tgt") spdk_cmd = os.path.join(spdk_path, spdk_tgt) + spdk_rpc_socket = self.nvme_config.get("spdk", "rpc_socket") - cmd = [spdk_cmd, "all", "-u"] + cmd = [spdk_cmd, "-u", "-r", spdk_rpc_socket] self.logger.info(f"Starting {' '.join(cmd)}") try: @@ -48,20 +49,18 @@ def start_spdk(self): self.logger.error(f"Unable to start SPDK: \n {ex}") raise - spdk_server_addr = self.nvme_config.get("spdk", "spdk_server_addr") - spdk_port = self.nvme_config.get("spdk", "spdk_port") timeout = self.nvme_config.getfloat("spdk", "timeout") log_level = self.nvme_config.get("spdk", "log_level") conn_retries = self.nvme_config.getint("spdk", "conn_retries") self.logger.info( - f"Attempting to initialize SPDK: server_addr: {spdk_server_addr}, port: {spdk_port}, conn_retries: {conn_retries}, timeout: {timeout}" + f"Attempting to initialize SPDK: rpc_socket: {spdk_rpc_socket}, conn_retries: {conn_retries}, timeout: {timeout}" ) try: self.client = self.spdk_rpc.client.JSONRPCClient( - spdk_server_addr, - spdk_port, + spdk_rpc_socket, + None, timeout, log_level=log_level, conn_retries=conn_retries,