}
}
-static void nvme_show_subsystem(nvme_root_t r)
+static void nvme_show_subsystem(nvme_root_t r, unsigned int nsid)
{
nvme_host_t h;
printf("\\\n");
nvme_subsystem_for_each_ctrl(s, c) {
- printf(" +- %s %s %s %s\n",
+ const char *ana_state =
+ nvme_ctrl_get_ana_state(c, nsid);
+ printf(" +- %s %s %s %s %s\n",
nvme_ctrl_get_name(c),
nvme_ctrl_get_transport(c),
nvme_ctrl_get_address(c),
- nvme_ctrl_get_state(c));
+ nvme_ctrl_get_state(c),
+ ana_state ? : "");
}
}
}
}
-static void json_print_nvme_subsystem_list(nvme_root_t r)
+static void json_print_nvme_subsystem_list(nvme_root_t r, unsigned int nsid)
{
struct json_object *host_attrs, *subsystem_attrs, *path_attrs;
struct json_object *subsystems, *paths;
nvme_ctrl_get_address(c));
json_object_add_value_string(path_attrs, "State",
nvme_ctrl_get_state(c));
+ if (nsid != NVME_NSID_ALL) {
+ const char *ana_state =
+ nvme_ctrl_get_ana_state(c, nsid);
+ if (ana_state)
+ json_object_add_value_string(path_attrs,
+ "ANAState", ana_state);
+ }
json_array_add_value_object(paths, path_attrs);
}
json_object_add_value_array(subsystem_attrs, "Paths",
json_free_object(root);
}
-void nvme_show_subsystem_list(nvme_root_t r, enum nvme_print_flags flags)
+void nvme_show_subsystem_list(nvme_root_t r, unsigned int nsid,
+ enum nvme_print_flags flags)
{
if (flags & JSON)
- return json_print_nvme_subsystem_list(r);
- nvme_show_subsystem(r);
+ return json_print_nvme_subsystem_list(r, nsid);
+ nvme_show_subsystem(r, nsid);
}
static void nvme_show_registers_cap(struct nvme_bar_cap *cap)
void nvme_show_lba_status(struct nvme_lba_status *list, unsigned long len,
enum nvme_print_flags flags);
void nvme_show_list_items(nvme_root_t t, enum nvme_print_flags flags);
-void nvme_show_subsystem_list(nvme_root_t t, enum nvme_print_flags flags);
+void nvme_show_subsystem_list(nvme_root_t t, unsigned int nsid,
+ enum nvme_print_flags flags);
void nvme_show_id_nvmset(struct nvme_id_nvmset_list *nvmset, unsigned nvmset_id,
enum nvme_print_flags flags);
void nvme_show_primary_ctrl_cap(const struct nvme_primary_ctrl_cap *cap,
return err;
}
-static bool nvme_match_device_filter(nvme_subsystem_t s)
-{
- nvme_ctrl_t c;
- nvme_ns_t n;
-
- if (!devicename || !strlen(devicename))
- return true;
-
- nvme_subsystem_for_each_ctrl(s, c)
- if (!strcmp(devicename, nvme_ctrl_get_name(c)))
- return true;
-
- nvme_subsystem_for_each_ns(s, n)
- if (!strcmp(devicename, nvme_ns_get_name(n)))
- return true;
-
- return false;
-}
-
static int list_subsys(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{
enum nvme_print_flags flags;
const char *desc = "Retrieve information for subsystems";
const char *verbose = "Increase output verbosity";
- nvme_scan_filter_t filter = NULL;
+ __u32 nsid = NVME_NSID_ALL;
int err;
struct config {
goto ret;
}
- if (devicename)
- filter = nvme_match_device_filter;
+ if (devicename) {
+ char *n, *eptr = NULL;
- err = nvme_scan_topology(r, filter);
+ n = strrchr(devicename, 'n');
+ if (!n) {
+ fprintf(stderr, "Invalid device name %s\n", devicename);
+ err = -EINVAL;
+ goto ret;
+ }
+ nsid = strtoul(n + 1, &eptr, 10);
+ if (eptr == n + 1) {
+ fprintf(stderr, "Invalid device nsid %s\n", devicename);
+ err = -EINVAL;
+ goto ret;
+ }
+ }
+
+ err = nvme_scan_topology(r, NULL);
if (err) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
goto ret;
}
- nvme_show_subsystem_list(r, flags);
+ nvme_show_subsystem_list(r, nsid, flags);
nvme_free_tree(r);
ret: