spdk_top: allow connecting with TCP port

JSON-RPC server (spdk_rpc_listen) only listens on
a UNIX domain socket.  If users wish to issue
JSON-RPC calls over a TCP socket for debugging
purposes, they can forward calls using socat, i.e.

socat TCP4-LISTEN:8989,reuseaddr,fork,bind=127.0.0.1 \
      UNIX-CLIENT:/var/tmp/spdk.sock

This could allow running spdk_top to debug or
monitor an SPDK application remotely.  But currently
spdk_top -r option assumes AF_UNIX.  Look at the
first character in the -r option (if provided) - if
it's '/' use AF_UNIX, otherwise AF_INET.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ie9c33bb0fb66dff895359f6f6608862df42b542c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11567
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Jim Harris 2022-02-10 17:48:35 +00:00
parent 5a308ec575
commit e0ca35c4f6

View File

@ -3134,7 +3134,7 @@ int main(int argc, char **argv)
}
}
g_rpc_client = spdk_jsonrpc_client_connect(socket, AF_UNIX);
g_rpc_client = spdk_jsonrpc_client_connect(socket, socket[0] == '/' ? AF_UNIX : AF_INET);
if (!g_rpc_client) {
fprintf(stderr, "spdk_jsonrpc_client_connect() failed: %d\n", errno);
return 1;