summaryrefslogtreecommitdiffstats
path: root/plugins/nbft/nbft-plugin.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:11:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:11:05 +0000
commit81d6a5ded50a26338e1b36462b3e0a6e45beb9a6 (patch)
tree364371981040c3dc6e97bb289bda0d33933ebfac /plugins/nbft/nbft-plugin.c
parentAdding upstream version 2.8. (diff)
downloadnvme-cli-upstream/2.9.1.tar.xz
nvme-cli-upstream/2.9.1.zip
Adding upstream version 2.9.1.upstream/2.9.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/nbft/nbft-plugin.c')
-rw-r--r--plugins/nbft/nbft-plugin.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c
index 2193ffb..1bb60be 100644
--- a/plugins/nbft/nbft-plugin.c
+++ b/plugins/nbft/nbft-plugin.c
@@ -4,11 +4,12 @@
#include <stdio.h>
#include <fnmatch.h>
+#include <libnvme.h>
#include "nvme-print.h"
#include "nvme.h"
#include "nbft.h"
-#include "libnvme.h"
#include "fabrics.h"
+#include "util/logging.h"
#define CREATE_CMD
#include "nbft-plugin.h"
@@ -168,7 +169,11 @@ static json_object *ssns_to_json(struct nbft_info_subsystem_ns *ss)
|| json_object_add_value_int(ss_json, "pdu_header_digest_required",
ss->pdu_header_digest_required)
|| json_object_add_value_int(ss_json, "data_digest_required",
- ss->data_digest_required))
+ ss->data_digest_required)
+ || json_object_add_value_int(ss_json, "discovered",
+ ss->discovered)
+ || json_object_add_value_int(ss_json, "unavailable",
+ ss->unavailable))
goto fail;
return ss_json;
@@ -319,7 +324,7 @@ static int json_show_nbfts(struct list_head *nbft_list, bool show_subsys,
bool show_hfi, bool show_discovery)
{
struct json_object *nbft_json_array, *nbft_json;
- struct nbft_file_entry *entry;
+ struct nbft_file_entry *entry = NULL;
nbft_json_array = json_create_array();
if (!nbft_json_array)
@@ -510,7 +515,7 @@ static void normal_show_nbfts(struct list_head *nbft_list, bool show_subsys,
bool show_hfi, bool show_discovery)
{
bool not_first = false;
- struct nbft_file_entry *entry;
+ struct nbft_file_entry *entry = NULL;
list_for_each(nbft_list, entry, node) {
if (not_first)
@@ -529,6 +534,8 @@ int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin)
enum nvme_print_flags flags;
int ret;
bool show_subsys = false, show_hfi = false, show_discovery = false;
+ unsigned int verbose = 0;
+ nvme_root_t r;
OPT_ARGS(opts) = {
OPT_FMT("output-format", 'o', &format, "Output format: normal|json"),
@@ -536,6 +543,7 @@ int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin)
OPT_FLAG("hfi", 'H', &show_hfi, "show NBFT HFIs"),
OPT_FLAG("discovery", 'd', &show_discovery, "show NBFT discovery controllers"),
OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"),
+ OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"),
OPT_END()
};
@@ -543,10 +551,15 @@ int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin)
if (ret)
return ret;
+ log_level = map_log_level(verbose, false /* quiet */);
+
ret = validate_output_format(format, &flags);
if (ret < 0)
return ret;
+ /* initialize libnvme logging */
+ r = nvme_create_root(stderr, log_level);
+
if (!(show_subsys || show_hfi || show_discovery))
show_subsys = show_hfi = show_discovery = true;
@@ -559,5 +572,6 @@ int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin)
ret = json_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery);
free_nbfts(&nbft_list);
}
+ nvme_free_tree(r);
return ret;
}