Skip to content

Commit b7320dc

Browse files
authored
Merge pull request #579 from RevanthRajashekar/self_test_log
nvme-cli: Add namespace-id option to self-test-log
2 parents 9bb5eb6 + a6ae8b8 commit b7320dc

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

nvme-ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,9 @@ int nvme_ana_log(int fd, void *ana_log, size_t ana_log_len, int rgo)
523523
true, ana_log_len, ana_log);
524524
}
525525

526-
int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log)
526+
int nvme_self_test_log(int fd, __u32 nsid, struct nvme_self_test_log *self_test_log)
527527
{
528-
return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_DEVICE_SELF_TEST, false,
528+
return nvme_get_log(fd, nsid, NVME_LOG_DEVICE_SELF_TEST, false,
529529
sizeof(*self_test_log), self_test_log);
530530
}
531531

nvme-ioctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,6 @@ int nvme_get_property(int fd, int offset, uint64_t *value);
153153
int nvme_sanitize(int fd, __u8 sanact, __u8 ause, __u8 owpass, __u8 oipbp,
154154
__u8 no_dealloc, __u32 ovrpat);
155155
int nvme_self_test_start(int fd, __u32 nsid, __u32 cdw10);
156-
int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log);
156+
int nvme_self_test_log(int fd, __u32 nsid, struct nvme_self_test_log *self_test_log);
157157
int nvme_virtual_mgmt(int fd, __u32 cdw10, __u32 cdw11, __u32 *result);
158158
#endif /* _NVME_LIB_H */

nvme.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2152,17 +2152,22 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug
21522152
const char *desc = "Retrieve the self-test log for the given device and given test "\
21532153
"(or optionally a namespace) in either decoded format "\
21542154
"(default) or binary.";
2155+
const char *namespace_id = "Indicate the namespace from which the self-test "\
2156+
"log has to be obtained";
21552157
int err, fmt, fd;
21562158

21572159
struct config {
2160+
__u32 namespace_id;
21582161
char *output_format;
21592162
};
21602163

21612164
struct config cfg = {
2165+
.namespace_id = NVME_NSID_ALL,
21622166
.output_format = "normal",
21632167
};
21642168

21652169
OPT_ARGS(opts) = {
2170+
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),
21662171
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
21672172
OPT_END()
21682173
};
@@ -2179,7 +2184,7 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug
21792184
goto close_fd;
21802185
}
21812186

2182-
err = nvme_self_test_log(fd, &self_test_log);
2187+
err = nvme_self_test_log(fd, cfg.namespace_id, &self_test_log);
21832188
if (!err) {
21842189
if (self_test_log.crnt_dev_selftest_oprn == 0) {
21852190
if (fmt == BINARY)

0 commit comments

Comments
 (0)