From 52b80432817285f570003667cb941084ed337da6 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sat, 14 Feb 2026 22:36:30 +0900 Subject: [PATCH 1/2] libnvme: replace fprintf to nvme_msg Since the struct nvme_global_ctx is available. Signed-off-by: Tokunori Ikegami --- libnvme/src/nvme/fabrics.c | 26 ++++++++++++++------------ libnvme/src/nvme/linux.c | 3 ++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 40b15bb141..06a094d49a 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -2376,8 +2376,9 @@ static int nvmf_create_discovery_ctrl(struct nvme_global_ctx *ctx, /* Find out the name of discovery controller */ ret = nvme_ctrl_identify(c, id); if (ret) { - fprintf(stderr, "failed to identify controller, error %s\n", - nvme_strerror(-ret)); + nvme_msg(ctx, LOG_ERR, + "failed to identify controller, error %s\n", + nvme_strerror(-ret)); nvme_disconnect_ctrl(c); nvme_free_ctrl(c); return ret; @@ -2431,7 +2432,7 @@ int _discovery_config_json(struct nvme_global_ctx *ctx, /* ignore if no host_traddr for fc */ if (!strcmp(transport, "fc")) { if (!host_traddr) { - fprintf(stderr, "host_traddr required for fc\n"); + nvme_msg(ctx, LOG_ERR, "host_traddr required for fc\n"); return 0; } } @@ -2439,8 +2440,8 @@ int _discovery_config_json(struct nvme_global_ctx *ctx, /* ignore if host_iface set for any transport other than tcp */ if (!strcmp(transport, "rdma") || !strcmp(transport, "fc")) { if (host_iface) { - fprintf(stderr, - "host_iface not permitted for rdma or fc\n"); + nvme_msg(ctx, LOG_ERR, + "host_iface not permitted for rdma or fc\n"); return 0; } } @@ -2580,11 +2581,11 @@ int nvmf_connect_config_json(struct nvme_global_ctx *ctx, if (err == -ENVME_CONNECT_ALREADY) continue; - fprintf(stderr, - "failed to connect to hostnqn=%s,nqn=%s,%s\n", - nvme_host_get_hostnqn(h), - nvme_subsystem_get_name(s), - nvme_ctrl_get_address(c)); + nvme_msg(ctx, LOG_ERR, + "failed to connect to hostnqn=%s,nqn=%s,%s\n", + nvme_host_get_hostnqn(h), + nvme_subsystem_get_name(s), + nvme_ctrl_get_address(c)); if (!ret) ret = err; @@ -3233,8 +3234,9 @@ static int nvmf_create_discover_ctrl(struct nvme_global_ctx *ctx, /* Find out the name of discovery controller */ ret = nvme_ctrl_identify(c, id); if (ret) { - fprintf(stderr, "failed to identify controller, error %s\n", - nvme_strerror(-ret)); + nvme_msg(ctx, LOG_ERR, + "failed to identify controller, error %s\n", + nvme_strerror(-ret)); nvme_disconnect_ctrl(c); nvme_free_ctrl(c); return ret; diff --git a/libnvme/src/nvme/linux.c b/libnvme/src/nvme/linux.c index 45af12c31b..b33811f8bc 100644 --- a/libnvme/src/nvme/linux.c +++ b/libnvme/src/nvme/linux.c @@ -326,7 +326,8 @@ int nvme_get_uuid_list(struct nvme_transport_handle *hdl, struct nvme_id_uuid_li nvme_init_identify_ctrl(&cmd, &ctrl); err = nvme_submit_admin_passthru(hdl, &cmd); if (err) { - fprintf(stderr, "ERROR: nvme_identify_ctrl() failed 0x%x\n", err); + nvme_msg(hdl->ctx, LOG_ERR, + "ERROR: nvme_identify_ctrl() failed 0x%x\n", err); return err; } From 2ff98b319963606b325d384d4063d101bf677a24 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sat, 14 Feb 2026 22:49:46 +0900 Subject: [PATCH 2/2] libnvme/fabrics: fix inet_pton_with_scope function header description Fix to describe the parameter ctx correctly instead of r. Signed-off-by: Tokunori Ikegami --- libnvme/src/nvme/fabrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 06a094d49a..6db178b396 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -627,7 +627,7 @@ static int inet6_pton(struct nvme_global_ctx *ctx, const char *src, uint16_t por /** * inet_pton_with_scope - convert an IPv4/IPv6 to socket address - * @r: nvme_root_t object + * @ctx: Global context * @af: address family, AF_INET, AF_INET6 or AF_UNSPEC for either * @src: the start of the address string * @trsvcid: transport service identifier