Bug Summary

File:.build-ci/../plugins/lm/lm-nvme.c
Warning:line 475, column 11
Opened stream never closed. Potential resource leak

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -O3 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name lm-nvme.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/__w/nvme-cli/nvme-cli/.build-ci -fcoverage-compilation-dir=/__w/nvme-cli/nvme-cli/.build-ci -resource-dir /usr/bin/../lib/clang/22 -include /__w/nvme-cli/nvme-cli/.build-ci/nvme-config.h -I nvme.p -I . -I .. -I src -I ../src -I ccan -I ../ccan -I libnvme/src -I ../libnvme/src -I /usr/include/json-c -D _FILE_OFFSET_BITS=64 -D _GNU_SOURCE -U NDEBUG -internal-isystem /usr/bin/../lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=gnu11 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-opt-analyze-headers -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /__w/nvme-cli/nvme-cli/.build-ci/scan-results/2026-09-23-073103-589-1 -x c ../plugins/lm/lm-nvme.c
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2024 Samsung Electronics Co., LTD.
4 *
5 * Authors: Nate Thornton <n.thornton@samsung.com>
6 */
7
8#include <asm/byteorder.h>
9#include <assert.h>
10#include <dirent.h>
11#include <errno(*__errno_location ()).h>
12#include <fcntl.h>
13#include <inttypes.h>
14#include <linux1/fs.h>
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18#include <sys/mman.h>
19#include <sys/shm.h>
20#include <sys/stat.h>
21#include <sys/sysinfo.h>
22#include <sys/types.h>
23#include <time.h>
24#include <unistd.h>
25
26#include <libnvme.h>
27
28#include <ccan/array_size/array_size.h>
29#include <shared/compiler-attributes-util.h>
30
31#include "global-ctx.h"
32#include "lm-print.h"
33#include "nvme-cmds.h"
34#include "nvme-print.h"
35#include "plugin.h"
36#include "src/cleanup.h"
37
38static inline const char * arg_str(const char * const *strings, size_t array_size, size_t idx)
39{
40 if (idx < array_size && strings[idx])
41 return strings[idx];
42 return "unrecognized";
43}
44
45#define ARGSTR(s, i)arg_str(s, (sizeof(s) / sizeof((s)[0]) + 0), i) arg_str(s, ARRAY_SIZE(s)(sizeof(s) / sizeof((s)[0]) + 0), i)
46
47static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
48{
49 const char *desc = "Create Controller Data Queue for controller of specific type and size";
50 const char *sz = "CDQ Size (in dwords)";
51 const char *cntlid = "Controller ID";
52 const char *qt = "Queue Type (default: 0 = User Data Migration Queue)";
53 const char *consent = "I consent this will not work and understand a CDQ cannot be mapped "
54 "to user space. If I proceed with the creation of a CDQ, the device "
55 "will write to invalid memory, inevitably leading to MMU faults or "
56 "worse.";
57
58 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
59 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
60 struct lba_migration_queue_entry_type_0 *queue = NULL((void*)0);
61 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
62 struct libnvme_passthru_cmd cmd;
63 int err = -1;
64
65 struct config {
66 __u32 sz;
67 __u16 cntlid;
68 __u8 qt;
69 bool_Bool consent;
70 char *file;
71 };
72
73 struct config cfg = {
74 .sz = 0,
75 .cntlid = 0,
76 .qt = 0,
77 .consent = false0,
78 .file = NULL((void*)0),
79 };
80
81 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"size", 's', "NUM", CFG_POSITIVE, &cfg.sz, 1, sz,
0, }, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"queue-type", 'q', "NUM", CFG_BYTE, &cfg.qt, 1, qt
, 0, }, {"consent", 0, ((void*)0), CFG_FLAG, &cfg.consent
, 0, consent, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
82 OPT_UINT("size", 's', &cfg.sz, sz),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"size", 's', "NUM", CFG_POSITIVE, &cfg.sz, 1, sz,
0, }, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"queue-type", 'q', "NUM", CFG_BYTE, &cfg.qt, 1, qt
, 0, }, {"consent", 0, ((void*)0), CFG_FLAG, &cfg.consent
, 0, consent, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
83 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"size", 's', "NUM", CFG_POSITIVE, &cfg.sz, 1, sz,
0, }, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"queue-type", 'q', "NUM", CFG_BYTE, &cfg.qt, 1, qt
, 0, }, {"consent", 0, ((void*)0), CFG_FLAG, &cfg.consent
, 0, consent, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
84 OPT_BYTE("queue-type", 'q', &cfg.qt, qt),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"size", 's', "NUM", CFG_POSITIVE, &cfg.sz, 1, sz,
0, }, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"queue-type", 'q', "NUM", CFG_BYTE, &cfg.qt, 1, qt
, 0, }, {"consent", 0, ((void*)0), CFG_FLAG, &cfg.consent
, 0, consent, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
85 OPT_FLAG("consent", 0, &cfg.consent, consent))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"size", 's', "NUM", CFG_POSITIVE, &cfg.sz, 1, sz,
0, }, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"queue-type", 'q', "NUM", CFG_BYTE, &cfg.qt, 1, qt
, 0, }, {"consent", 0, ((void*)0), CFG_FLAG, &cfg.consent
, 0, consent, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
86
87 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
88 if (err)
89 return err;
90
91 if (!consent) {
92 nvme_show_error("ERROR: consent required")nvme_show_message(1, "ERROR: consent required");
93 return -EINVAL22;
94 }
95
96 // Not that it really matters, but we setup memory as if the CDQ can be held
97 // in user space regardless.
98 queue = libnvme_alloc_huge(cfg.sz << 2, &mh);
99 if (!queue) {
100 nvme_show_error("ERROR: libnvme_alloc of size %dB failed %s", cfg.sz << 2,nvme_show_message(1, "ERROR: libnvme_alloc of size %dB failed %s"
, cfg.sz << 2, libnvme_strerror((*__errno_location ()))
)
101 libnvme_strerror(errno))nvme_show_message(1, "ERROR: libnvme_alloc of size %dB failed %s"
, cfg.sz << 2, libnvme_strerror((*__errno_location ()))
)
;
102 return -ENOMEM12;
103 }
104
105 nvme_init_lm_cdq_create(&cmd, NVME_SET(cfg.qt, LM_QT)(((__u32)(cfg.qt) & NVME_LM_QT_MASK) << NVME_LM_QT_SHIFT
)
,
106 cfg.cntlid, cfg.sz, queue);
107 err = libnvme_exec_admin_passthru(hdl, &cmd);
108 if (err < 0)
109 nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror
((*__errno_location ())))
;
110 else if (err)
111 nvme_show_status(err);
112 else
113 nvme_show_verbose_result("Create CDQ Successful: CDQID=0x%04x",nvme_show_verbose_message("Create CDQ Successful: CDQID=0x%04x"
, ((((__u32)cmd.result) >> NVME_LM_CREATE_CDQ_CDQID_SHIFT
) & NVME_LM_CREATE_CDQ_CDQID_MASK))
114 NVME_GET((__u32)cmd.result, LM_CREATE_CDQ_CDQID))nvme_show_verbose_message("Create CDQ Successful: CDQID=0x%04x"
, ((((__u32)cmd.result) >> NVME_LM_CREATE_CDQ_CDQID_SHIFT
) & NVME_LM_CREATE_CDQ_CDQID_MASK))
;
115
116 return err;
117}
118
119static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
120{
121 const char *desc = "Delete Controller Data Queue";
122 const char *cdqid = "Controller Data Queue ID";
123
124 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
125 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
126 struct libnvme_passthru_cmd cmd;
127 int err = -1;
128
129 struct config {
130 __u16 cdqid;
131 };
132
133 struct config cfg = {
134 .cdqid = 0
135 };
136
137 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
138 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
139
140 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
141 if (err)
142 return err;
143
144 nvme_init_lm_cdq_delete(&cmd, 0, cfg.cdqid);
145 err = libnvme_exec_admin_passthru(hdl, &cmd);
146 if (err < 0)
147 nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror
((*__errno_location ())))
;
148 else if (err > 0)
149 nvme_show_status(err);
150 else
151 nvme_show_verbose_result("Delete CDQ Successful: CDQID=0x%04x", cfg.cdqid)nvme_show_verbose_message("Delete CDQ Successful: CDQID=0x%04x"
, cfg.cdqid)
;
152
153 return err;
154}
155
156static const char * const lm_track_send_select_argstr[] = {
157 [NVME_LM_SEL_LOG_USER_DATA_CHANGES] = "Log User Data Changes",
158 [NVME_LM_SEL_TRACK_MEMORY_CHANGES] = "Track Memory Changes"
159};
160
161static int lm_track_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
162{
163 const char *desc = "Track Send command used to manage the tracking of information by a "
164 "controller";
165 const char *sel = "Type of management operation to perform\n"
166 " 0h = Log User Data Changes\n"
167 " 1h = Track Memory Changes";
168 const char *mos = "Management operation specific";
169 const char *cdqid = "Controller Data Queue ID";
170 const char *start = "Equivalent to start tracking with defaults";
171 const char *stop = "Equivalent to stop tracking with defaults";
172
173
174 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
175 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
176 struct libnvme_passthru_cmd cmd;
177 int err = -1;
178
179 struct config {
180 __s8 sel;
181 __u8 mos;
182 __u16 cdqid;
183 bool_Bool start;
184 bool_Bool stop;
185 };
186
187 struct config cfg = {
188 .sel = -1,
189 .mos = 0,
190 .cdqid = 0,
191 .start = false0,
192 .stop = false0,
193 };
194
195 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"mos", 'm', "NUM", CFG_BYTE, &cfg.mos, 1, mos, 0, },
{"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid, 0
, }, {"start", 0, ((void*)0), CFG_FLAG, &cfg.start, 0, start
, 0, }, {"stop", 0, ((void*)0), CFG_FLAG, &cfg.stop, 0, stop
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
196 OPT_BYTE("sel", 's', &cfg.sel, sel),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"mos", 'm', "NUM", CFG_BYTE, &cfg.mos, 1, mos, 0, },
{"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid, 0
, }, {"start", 0, ((void*)0), CFG_FLAG, &cfg.start, 0, start
, 0, }, {"stop", 0, ((void*)0), CFG_FLAG, &cfg.stop, 0, stop
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
197 OPT_BYTE("mos", 'm', &cfg.mos, mos),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"mos", 'm', "NUM", CFG_BYTE, &cfg.mos, 1, mos, 0, },
{"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid, 0
, }, {"start", 0, ((void*)0), CFG_FLAG, &cfg.start, 0, start
, 0, }, {"stop", 0, ((void*)0), CFG_FLAG, &cfg.stop, 0, stop
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
198 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"mos", 'm', "NUM", CFG_BYTE, &cfg.mos, 1, mos, 0, },
{"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid, 0
, }, {"start", 0, ((void*)0), CFG_FLAG, &cfg.start, 0, start
, 0, }, {"stop", 0, ((void*)0), CFG_FLAG, &cfg.stop, 0, stop
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
199 OPT_FLAG("start", 0, &cfg.start, start),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"mos", 'm', "NUM", CFG_BYTE, &cfg.mos, 1, mos, 0, },
{"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid, 0
, }, {"start", 0, ((void*)0), CFG_FLAG, &cfg.start, 0, start
, 0, }, {"stop", 0, ((void*)0), CFG_FLAG, &cfg.stop, 0, stop
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
200 OPT_FLAG("stop", 0, &cfg.stop, stop))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"mos", 'm', "NUM", CFG_BYTE, &cfg.mos, 1, mos, 0, },
{"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid, 0
, }, {"start", 0, ((void*)0), CFG_FLAG, &cfg.start, 0, start
, 0, }, {"stop", 0, ((void*)0), CFG_FLAG, &cfg.stop, 0, stop
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
201
202 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
203 if (err)
204 return err;
205
206 if (cfg.sel == -1) {
207 nvme_show_error("Select field required")nvme_show_message(1, "Select field required");
208 return -EINVAL22;
209 }
210
211 if (cfg.sel != NVME_LM_SEL_LOG_USER_DATA_CHANGES) {
212 nvme_show_error("Unsupported select option %d (%s)", cfg.sel,nvme_show_message(1, "Unsupported select option %d (%s)", cfg
.sel, arg_str(lm_track_send_select_argstr, (sizeof(lm_track_send_select_argstr
) / sizeof((lm_track_send_select_argstr)[0]) + 0), cfg.sel))
213 ARGSTR(lm_track_send_select_argstr, cfg.sel))nvme_show_message(1, "Unsupported select option %d (%s)", cfg
.sel, arg_str(lm_track_send_select_argstr, (sizeof(lm_track_send_select_argstr
) / sizeof((lm_track_send_select_argstr)[0]) + 0), cfg.sel))
;
214 return -EINVAL22;
215 }
216
217 if (cfg.start && cfg.stop) {
218 nvme_show_error("Must select one of start & stop, not both")nvme_show_message(1, "Must select one of start & stop, not both"
)
;
219 return -EINVAL22;
220 } else if (cfg.sel == NVME_LM_SEL_LOG_USER_DATA_CHANGES) {
221 if (cfg.start)
222 cfg.mos = NVME_SET(NVME_LM_LACT_START_LOGGING, LM_LACT)(((__u32)(NVME_LM_LACT_START_LOGGING) & NVME_LM_LACT_MASK
) << NVME_LM_LACT_SHIFT)
;
223 else if (cfg.stop)
224 cfg.mos = NVME_SET(NVME_LM_LACT_STOP_LOGGING, LM_LACT)(((__u32)(NVME_LM_LACT_STOP_LOGGING) & NVME_LM_LACT_MASK)
<< NVME_LM_LACT_SHIFT)
;
225 }
226
227 nvme_init_lm_track_send(&cmd, cfg.sel, cfg.mos, cfg.cdqid, NULL((void*)0), 0);
228 err = libnvme_exec_admin_passthru(hdl, &cmd);
229 if (err < 0)
230 nvme_show_error("ERROR: nvme_lm_track_send() failed %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_lm_track_send() failed %s",
libnvme_strerror((*__errno_location ())))
;
231 else if (err)
232 nvme_show_status(err);
233 else
234 nvme_show_verbose_result("Track Send (%s) Successful",nvme_show_verbose_message("Track Send (%s) Successful", arg_str
(lm_track_send_select_argstr, (sizeof(lm_track_send_select_argstr
) / sizeof((lm_track_send_select_argstr)[0]) + 0), cfg.sel))
235 ARGSTR(lm_track_send_select_argstr, cfg.sel))nvme_show_verbose_message("Track Send (%s) Successful", arg_str
(lm_track_send_select_argstr, (sizeof(lm_track_send_select_argstr
) / sizeof((lm_track_send_select_argstr)[0]) + 0), cfg.sel))
;
236
237 return err;
238}
239
240static const char * const lm_migration_send_select_argstr[] = {
241 [NVME_LM_SEL_SUSPEND] = "Suspend",
242 [NVME_LM_SEL_RESUME] = "Resume",
243 [NVME_LM_SEL_SET_CONTROLLER_STATE] = "Set Controller State"
244};
245
246static int lm_migration_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
247{
248 const char *desc = "Migration Send command is used to manage the migration of a controller";
249 const char *sel = "Select (SEL) the type of management operation to perform "
250 "(CDW10[07:00])\n"
251 " 0h = Suspend\n"
252 " 1h = Resume\n"
253 " 2h = Set Controller State";
254 const char *cntlid = "Controller Identifier (CDW11[15:00])";
255 const char *stype = "Type of suspend (STYPE) (CDW11[23:16]\n"
256 " 0h = Suspend Notification\n"
257 " 1h = Suspend";
258 const char *dudmq = "Delete user data migration queue (DUDMQ) as part of suspend operation "
259 "(CDW11[31])";
260 const char *seqind = "Sequence Indicator (CDW10[17:16])\n"
261 " 0h = Not first not last\n"
262 " 1h = First in two or more\n"
263 " 2h = Last in two or more\n"
264 " 3h = Entire state info";
265 const char *csuuidi = "Controller State UUID Index (CSUUIDI) (CDW11[31:24])";
266 const char *csvi = "Controller State Version Index (CSVI) (CDW11[23:16])";
267 const char *uidx = "UUID Index (UIDX) (CDW14[16:00])";
268 const char *offset = "Controller State Offset";
269 const char *numd = "Number of Dwords (NUMD)";
270 const char *input = "Controller State Data input file";
271
272 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
273 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
274 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
275 __cleanup_file__attribute__((cleanup(shr_cleanup_file))) FILE *file = NULL((void*)0);
276 struct libnvme_passthru_cmd cmd;
277 void *data = NULL((void*)0);
278 int err = -1;
279
280 struct config {
281 __s8 sel;
282 __u16 cntlid;
283 __u8 stype;
284 __u8 seqind;
285 __u8 csuuidi;
286 __u8 csvi;
287 __u8 uidx;
288 __u64 offset;
289 __u32 numd;
290 char *input;
291 bool_Bool dudmq;
292 };
293
294 struct config cfg = {
295 .sel = -1,
296 .cntlid = 0,
297 .stype = 0,
298 .seqind = 0,
299 .csuuidi = 0,
300 .csvi = 0,
301 .uidx = 0,
302 .offset = 0,
303 .numd = 0,
304 .input = NULL((void*)0),
305 .dudmq = false0
306 };
307
308 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
309 OPT_BYTE("sel", 's', &cfg.sel, sel),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
310 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
311 OPT_BYTE("stype", 't', &cfg.stype, stype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
312 OPT_FLAG("dudmq", 'd', &cfg.dudmq, dudmq),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
313 OPT_BYTE("seq-ind", 'S', &cfg.seqind, seqind),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
314 OPT_BYTE("csuuidi", 'U', &cfg.csuuidi, csuuidi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
315 OPT_BYTE("csvi", 'V', &cfg.csvi, csvi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
316 OPT_BYTE("uidx", 'u', &cfg.uidx, uidx),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
317 OPT_LONG("offset", 'O', &cfg.offset, offset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
318 OPT_UINT("numd", 'n', &cfg.numd, numd),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
319 OPT_FILE("input-file", 'f', &cfg.input, input))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"stype", 't', "NUM", CFG_BYTE, &cfg.stype, 1, stype
, 0, }, {"dudmq", 'd', ((void*)0), CFG_FLAG, &cfg.dudmq, 0
, dudmq, 0, }, {"seq-ind", 'S', "NUM", CFG_BYTE, &cfg.seqind
, 1, seqind, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg
.csuuidi, 1, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &
cfg.csvi, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &
cfg.uidx, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &
cfg.offset, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"input-file", 'f', "FILE", CFG_STRING
, &cfg.input, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress informational output", 0, }, {"output-format",
'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
320
321 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
322 if (err)
323 return err;
324
325 if (cfg.sel == -1) {
326 nvme_show_error("Select field required")nvme_show_message(1, "Select field required");
327 return -EINVAL22;
328 }
329
330 // Sanity check input parameters
331 if (cfg.sel == NVME_LM_SEL_SUSPEND || cfg.sel == NVME_LM_SEL_RESUME) {
332 if (cfg.csuuidi != 0 || cfg.csvi != 0) {
333 nvme_show_error("Unexpected fields for %s",nvme_show_message(1, "Unexpected fields for %s", arg_str(lm_migration_send_select_argstr
, (sizeof(lm_migration_send_select_argstr) / sizeof((lm_migration_send_select_argstr
)[0]) + 0), cfg.sel))
334 ARGSTR(lm_migration_send_select_argstr, cfg.sel))nvme_show_message(1, "Unexpected fields for %s", arg_str(lm_migration_send_select_argstr
, (sizeof(lm_migration_send_select_argstr) / sizeof((lm_migration_send_select_argstr
)[0]) + 0), cfg.sel))
;
335 return -EINVAL22;
336 }
337 } else if (cfg.sel == NVME_LM_SEL_SET_CONTROLLER_STATE) {
338 if (cfg.dudmq || cfg.stype != 0) {
339 nvme_show_error("Unexpected fields for %s",nvme_show_message(1, "Unexpected fields for %s", arg_str(lm_migration_send_select_argstr
, (sizeof(lm_migration_send_select_argstr) / sizeof((lm_migration_send_select_argstr
)[0]) + 0), cfg.sel))
340 ARGSTR(lm_migration_send_select_argstr, cfg.sel))nvme_show_message(1, "Unexpected fields for %s", arg_str(lm_migration_send_select_argstr
, (sizeof(lm_migration_send_select_argstr) / sizeof((lm_migration_send_select_argstr
)[0]) + 0), cfg.sel))
;
341 return -EINVAL22;
342 } else if (!strlen(cfg.input)) {
343 nvme_show_error("Expected file for %s",nvme_show_message(1, "Expected file for %s", arg_str(lm_migration_send_select_argstr
, (sizeof(lm_migration_send_select_argstr) / sizeof((lm_migration_send_select_argstr
)[0]) + 0), cfg.sel))
344 ARGSTR(lm_migration_send_select_argstr, cfg.sel))nvme_show_message(1, "Expected file for %s", arg_str(lm_migration_send_select_argstr
, (sizeof(lm_migration_send_select_argstr) / sizeof((lm_migration_send_select_argstr
)[0]) + 0), cfg.sel))
;
345 return -EINVAL22;
346 }
347 }
348
349 if (cfg.input && strlen(cfg.input)) {
350 file = fopen(cfg.input, "r");
351 if (file == NULL((void*)0)) {
352 nvme_show_perror(cfg.input);
353 return -EINVAL22;
354 }
355
356 data = libnvme_alloc_huge(cfg.numd << 2, &mh);
357 if (!data)
358 return -ENOMEM12;
359
360 size_t n_data = fread(data, 1, cfg.numd << 2, file);
361
362 if (n_data != (size_t)(cfg.numd << 2)) {
363 nvme_show_error("failed to read controller state data %s", libnvme_strerror(errno))nvme_show_message(1, "failed to read controller state data %s"
, libnvme_strerror((*__errno_location ())))
;
364 return -errno(*__errno_location ());
365 }
366 }
367
368 nvme_init_lm_migration_send(&cmd, cfg.sel,
369 NVME_SET(cfg.seqind, LM_SEQIND)(((__u32)(cfg.seqind) & NVME_LM_SEQIND_MASK) << NVME_LM_SEQIND_SHIFT
)
, cfg.cntlid,
370 cfg.stype, cfg.dudmq, cfg.csvi, cfg.csuuidi,
371 cfg.offset, cfg.uidx, data,
372 (cfg.numd << 2));
373 err = libnvme_exec_admin_passthru(hdl, &cmd);
374 if (err < 0)
375 nvme_show_error("ERROR: nvme_lm_migration_send() failed %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_lm_migration_send() failed %s"
, libnvme_strerror((*__errno_location ())))
;
376 else if (err > 0)
377 nvme_show_status(err);
378 else
379 nvme_show_verbose_result("Migration Send (%s) Successful",nvme_show_verbose_message("Migration Send (%s) Successful", arg_str
(lm_migration_send_select_argstr, (sizeof(lm_migration_send_select_argstr
) / sizeof((lm_migration_send_select_argstr)[0]) + 0), cfg.sel
))
380 ARGSTR(lm_migration_send_select_argstr, cfg.sel))nvme_show_verbose_message("Migration Send (%s) Successful", arg_str
(lm_migration_send_select_argstr, (sizeof(lm_migration_send_select_argstr
) / sizeof((lm_migration_send_select_argstr)[0]) + 0), cfg.sel
))
;
381
382
383 return err;
384}
385
386static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct plugin *plugin)
387{
388 const char *desc = "Migration Receive command is used to obtain information used to manage "
389 " a migratable controller";
390 const char *sel = "Select (SEL) the type of management operation to perform "
391 "(CDW10[07:00])\n"
392 " 0h = Get Controller State";
393 const char *cntlid = "Controller Identifier (CDW10[31:16])";
394 const char *csuuidi = "Controller State UUID Index (CSUUIDI) (CDW11[23:16])";
395 const char *csvi = "Controller State Version Index (CSVI) (CDW11[7:0])";
396 const char *uidx = "UUID Index (UIDX) (CDW14[16:00])";
397 const char *offset = "Controller State Offset";
398 const char *numd = "Number of Dwords (NUMD)";
399 const char *output = "Controller State Data output file";
400 const char *human_readable_info = "show info in readable format";
401
402 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
403 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
404 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
405 __cleanup_file__attribute__((cleanup(shr_cleanup_file))) FILE *fd = NULL((void*)0);
406 struct libnvme_passthru_cmd cmd;
407 nvme_print_flags_t flags;
408 void *data = NULL((void*)0);
409 int err = -1;
410 __u16 mos;
411
412 struct config {
413 __u8 sel;
414 __u16 cntlid;
415 __u8 csuuidi;
416 __u8 csvi;
417 __u8 uidx;
418 __u64 offset;
419 __u32 numd;
420 char *output;
421 bool_Bool human_readable;
422 };
423
424 struct config cfg = {
425 .sel = -1,
426 .cntlid = 0,
427 .csuuidi = 0,
428 .csvi = 0,
429 .uidx = 0,
430 .offset = 0,
431 .numd = 0,
432 .output = NULL((void*)0),
433 .human_readable = false0
434 };
435
436 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
437 OPT_BYTE("sel", 's', &cfg.sel, sel),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
438 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
439 OPT_BYTE("csuuidi", 'U', &cfg.csuuidi, csuuidi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
440 OPT_BYTE("csvi", 'V', &cfg.csvi, csvi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
441 OPT_BYTE("uidx", 'u', &cfg.uidx, uidx),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
442 OPT_LONG("offset", 'O', &cfg.offset, offset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
443 OPT_UINT("numd", 'n', &cfg.numd, numd),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
444 OPT_FILE("output-file", 'f', &cfg.output, output),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
445 OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_info))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0,
}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"csuuidi", 'U', "NUM", CFG_BYTE, &cfg.csuuidi, 1
, csuuidi, 0, }, {"csvi", 'V', "NUM", CFG_BYTE, &cfg.csvi
, 1, csvi, 0, }, {"uidx", 'u', "NUM", CFG_BYTE, &cfg.uidx
, 1, uidx, 0, }, {"offset", 'O', "NUM", CFG_LONG, &cfg.offset
, 1, offset, 0, }, {"numd", 'n', "NUM", CFG_POSITIVE, &cfg
.numd, 1, numd, 0, }, {"output-file", 'f', "FILE", CFG_STRING
, &cfg.output, 1, output, 0, }, {"human-readable", 'H', (
(void*)0), CFG_FLAG, &cfg.human_readable, 0, human_readable_info
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
446
447 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
448 if (err)
1
Assuming 'err' is 0
2
Taking false branch
449 return err;
450
451 err = validate_output_format(nvme_args.output_format, &flags);
452 if (err < 0) {
3
Assuming 'err' is >= 0
453 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
454 return err;
455 }
456
457 if (nvme_args.output_format && cfg.offset != 0 && !(flags & BINARY)) {
4
Assuming field 'output_format' is null
458 nvme_show_error("cannot parse non-zero offset")nvme_show_message(1, "cannot parse non-zero offset");
459 return -EINVAL22;
460 }
461
462 if (cfg.human_readable)
5
Assuming field 'human_readable' is false
463 flags |= VERBOSE;
464
465 if (cfg.output && strlen(cfg.output)) {
6
Assuming field 'output' is non-null
7
Assuming the condition is true
8
Taking true branch
466 fd = fopen(cfg.output, "w");
9
Stream opened here
10
Assuming that 'fopen' is successful
467 if (!fd
10.1
'fd' is non-null
) {
11
Taking false branch
468 nvme_show_perror(cfg.output);
469 return -errno(*__errno_location ());
470 }
471 }
472
473 data = libnvme_alloc_huge((cfg.numd + 1) << 2, &mh);
474 if (!data)
12
Assuming 'data' is null
13
Taking true branch
475 return -ENOMEM12;
14
Opened stream never closed. Potential resource leak
476
477 mos = NVME_SET(cfg.csvi, LM_GET_CONTROLLER_STATE_CSVI)(((__u32)(cfg.csvi) & NVME_LM_GET_CONTROLLER_STATE_CSVI_MASK
) << NVME_LM_GET_CONTROLLER_STATE_CSVI_SHIFT)
;
478 nvme_init_lm_migration_recv(&cmd, cfg.offset, mos, cfg.cntlid,
479 cfg.csuuidi, cfg.sel, cfg.uidx, 0, data,
480 (cfg.numd + 1) << 2);
481 err = libnvme_exec_admin_passthru(hdl, &cmd);
482 if (err < 0)
483 nvme_show_error("ERROR: nvme_lm_migration_recv() failed %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_lm_migration_recv() failed %s"
, libnvme_strerror((*__errno_location ())))
;
484 else if (err)
485 nvme_show_status(err);
486 else if (cfg.sel == NVME_LM_SEL_GET_CONTROLLER_STATE) {
487 if (flags == NORMAL)
488 printf("CDW0: 0x%"PRIu64"l" "u"": Controller %sSuspended\n",
489 (uint64_t)cmd.result,
490 (cmd.result & NVME_LM_GET_CONTROLLER_STATE_CSUP) ?
491 "" : "NOT ");
492
493 if (cfg.output && strlen(cfg.output)) {
494 if (fwrite(data, 1, cfg.numd << 2, fd) != (cfg.numd << 2)) {
495 nvme_show_error("ERROR: %s: failed to write buffer to output file",nvme_show_message(1, "ERROR: %s: failed to write buffer to output file"
, libnvme_strerror((*__errno_location ())))
496 libnvme_strerror(errno))nvme_show_message(1, "ERROR: %s: failed to write buffer to output file"
, libnvme_strerror((*__errno_location ())))
;
497 err = -errno(*__errno_location ());
498 }
499 } else {
500 lm_show_controller_state_data((struct nvme_lm_controller_state_data *)data,
501 (cfg.numd + 1) << 2, cfg.offset, flags);
502 }
503 }
504
505 return err;
506}
507
508enum lm_controller_data_queue_feature_id {
509 lm_cdq_feature_id = 0x21
510};
511
512static int lm_set_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
513{
514 const char *desc = "This Feature allows a host to update the status of the head pointer "
515 "of a CDQ and specify the configuration of a CDQ Tail event.";
516 const char *cdqid = "Controller Data Queue ID";
517 const char *hp = "The slot of the head pointer for the specified CDQ";
518 const char *tpt = "If specified, the slot that causes the controller "
519 " to issue a CDQ Tail Pointer event";
520
521 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
522 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
523 int err = -1;
524
525 struct config {
526 __u16 cdqid;
527 __u32 hp;
528 __s32 tpt;
529 };
530
531 struct config cfg = {
532 .cdqid = 0,
533 .hp = 0,
534 .tpt = -1,
535 };
536
537 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"hp", 'H', "NUM", CFG_POSITIVE, &cfg.hp, 1, hp, 0
, }, {"tpt", 'T', "NUM", CFG_POSITIVE, &cfg.tpt, 1, tpt, 0
, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress informational output"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
538 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"hp", 'H', "NUM", CFG_POSITIVE, &cfg.hp, 1, hp, 0
, }, {"tpt", 'T', "NUM", CFG_POSITIVE, &cfg.tpt, 1, tpt, 0
, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress informational output"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
539 OPT_UINT("hp", 'H', &cfg.hp, hp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"hp", 'H', "NUM", CFG_POSITIVE, &cfg.hp, 1, hp, 0
, }, {"tpt", 'T', "NUM", CFG_POSITIVE, &cfg.tpt, 1, tpt, 0
, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress informational output"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
540 OPT_UINT("tpt", 'T', &cfg.tpt, tpt))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"hp", 'H', "NUM", CFG_POSITIVE, &cfg.hp, 1, hp, 0
, }, {"tpt", 'T', "NUM", CFG_POSITIVE, &cfg.tpt, 1, tpt, 0
, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress informational output"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
541
542 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
543 if (err)
544 return err;
545
546 err = nvme_set_features(hdl, 0, lm_cdq_feature_id, 0, cfg.cdqid |
547 ((cfg.tpt >= 0) ? NVME_SET(1, LM_CTRL_DATA_QUEUE_ETPT)(((__u32)(1) & NVME_LM_CTRL_DATA_QUEUE_ETPT_MASK) <<
NVME_LM_CTRL_DATA_QUEUE_ETPT_SHIFT)
: 0),
548 cfg.hp, cfg.tpt, 0, 0, NULL((void*)0), 0, NULL((void*)0));
549 if (err < 0)
550 nvme_show_error("ERROR: nvme_set_features() failed %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_set_features() failed %s", libnvme_strerror
((*__errno_location ())))
;
551 else if (err)
552 nvme_show_status(err);
553 else
554 nvme_show_verbose_result("Success. Head Pointer: %d", cfg.hp)nvme_show_verbose_message("Success. Head Pointer: %d", cfg.hp
)
;
555
556 return err;
557}
558
559static int lm_get_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
560{
561 const char *desc = "This Feature allows a host to retrieve the status of the head pointer "
562 "of a CDQ and specify the configuration of a CDQ Tail event.";
563 const char *cdqid = "Controller Data Queue ID";
564
565 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
566 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
567 nvme_print_flags_t flags;
568 int err = -1;
569
570 struct config {
571 __u16 cdqid;
572 };
573
574 struct config cfg = {
575 .cdqid = 0,
576 };
577
578 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
579 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cdqid", 'C', "NUM", CFG_SHORT, &cfg.cdqid, 1, cdqid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress informational output", 0, }, {"output-format", 'o'
, "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary"
, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout
, 1, "timeout value, in milliseconds", 0, }, {"dry-run", 0, (
(void*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
580
581 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
582 if (err)
583 return err;
584
585 err = validate_output_format(nvme_args.output_format, &flags);
586 if (err < 0) {
587 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
588 return err;
589 }
590
591 struct nvme_lm_ctrl_data_queue_fid_data data;
592
593 err = nvme_get_features(hdl, 0, lm_cdq_feature_id, 0, cfg.cdqid, 0,
594 &data, sizeof(data), NULL((void*)0));
595 if (err < 0)
596 nvme_show_error("ERROR: nvme_get_features() failed %s", libnvme_strerror(errno))nvme_show_message(1, "ERROR: nvme_get_features() failed %s", libnvme_strerror
((*__errno_location ())))
;
597 else if (err)
598 nvme_show_status(err);
599 else
600 lm_show_controller_data_queue(&data, flags);
601
602 return err;
603}
604
605static struct command lm_create_cdq_cmd = {
606 .name = "create-cdq",
607 .help = "Create Controller Data Queue",
608 .fn = lm_create_cdq,
609};
610
611static struct command lm_delete_cdq_cmd = {
612 .name = "delete-cdq",
613 .help = "Delete Controller Data Queue",
614 .fn = lm_delete_cdq,
615};
616
617static struct command lm_track_send_cmd = {
618 .name = "track-send",
619 .help = "Track Send Command",
620 .fn = lm_track_send,
621};
622
623static struct command lm_migration_send_cmd = {
624 .name = "migration-send",
625 .help = "Migration Send",
626 .fn = lm_migration_send,
627};
628
629static struct command lm_migration_recv_cmd = {
630 .name = "migration-recv",
631 .help = "Migration Receive",
632 .fn = lm_migration_recv,
633};
634
635static struct command lm_set_cdq_cmd = {
636 .name = "set-cdq",
637 .help = "Set Feature - Controller Data Queue (FID 21h)",
638 .fn = lm_set_cdq,
639};
640
641static struct command lm_get_cdq_cmd = {
642 .name = "get-cdq",
643 .help = "Get Feature - Controller Data Queue (FID 21h)",
644 .fn = lm_get_cdq,
645};
646
647static struct command *commands[] = {
648 &lm_create_cdq_cmd,
649 &lm_delete_cdq_cmd,
650 &lm_track_send_cmd,
651 &lm_migration_send_cmd,
652 &lm_migration_recv_cmd,
653 &lm_set_cdq_cmd,
654 &lm_get_cdq_cmd,
655 NULL((void*)0),
656};
657
658static struct plugin plugin = {
659 .name = "lm",
660 .desc = "Live Migration NVMe extensions",
661 .version = NVME_VERSION"3.1",
662 .core = true1,
663 .group = "Controller Management",
664};
665
666static void __shr_constructor__attribute__((constructor)) register_plugin(void)
667{
668 plugin_add_group(&plugin, NULL((void*)0), commands);
669 register_extension(&plugin);
670}