Bug Summary

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

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -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 pic -pic-level 2 -pic-is-pie -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/lib/llvm-19/lib/clang/19 -include /__w/nvme-cli/nvme-cli/.build-ci/nvme-config.h -I nvme.p -I . -I .. -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/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=gnu99 -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 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /__w/nvme-cli/nvme-cli/.build-ci/scan-results/2026-06-24-175442-590-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 <assert.h>
9#include <dirent.h>
10#include <errno(*__errno_location ()).h>
11#include <fcntl.h>
12#include <inttypes.h>
13#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
16#include <time.h>
17#include <unistd.h>
18
19#include <asm/byteorder.h>
20#include <linux1/fs.h>
21
22#include <sys/mman.h>
23#include <sys/shm.h>
24#include <sys/stat.h>
25#include <sys/sysinfo.h>
26#include <sys/types.h>
27
28#include <libnvme.h>
29
30#include "common.h"
31#include "nvme-cmds.h"
32#include "nvme-print.h"
33#include "nvme.h"
34#include "plugin.h"
35#include "util/cleanup.h"
36
37#define CREATE_CMD
38#include "lm-nvme.h"
39
40#include "lm-print.h"
41
42static inline const char * arg_str(const char * const *strings, size_t array_size, size_t idx)
43{
44 if (idx < array_size && strings[idx])
45 return strings[idx];
46 return "unrecognized";
47}
48
49#define ARRAY_SIZE(arr)(sizeof(arr) / sizeof((arr)[0])) (sizeof(arr) / sizeof((arr)[0]))
50#define ARGSTR(s, i)arg_str(s, (sizeof(s) / sizeof((s)[0])), i) arg_str(s, ARRAY_SIZE(s)(sizeof(s) / sizeof((s)[0])), i)
51
52static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
53{
54 const char *desc = "Create Controller Data Queue for controller of specific type and size";
55 const char *sz = "CDQ Size (in dwords)";
56 const char *cntlid = "Controller ID";
57 const char *qt = "Queue Type (default: 0 = User Data Migration Queue)";
58 const char *consent = "I consent this will not work and understand a CDQ cannot be mapped "
59 "to user space. If I proceed with the creation of a CDQ, the device "
60 "will write to invalid memory, inevitably leading to MMU faults or "
61 "worse.";
62
63 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
64 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
65 struct lba_migration_queue_entry_type_0 *queue = NULL((void*)0);
66 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
67 struct libnvme_passthru_cmd cmd;
68 int err = -1;
69
70 struct config {
71 __u32 sz;
72 __u16 cntlid;
73 __u8 qt;
74 bool_Bool consent;
75 char *file;
76 };
77
78 struct config cfg = {
79 .sz = 0,
80 .cntlid = 0,
81 .qt = 0,
82 .consent = false0,
83 .file = NULL((void*)0),
84 };
85
86 NVME_ARGS(opts,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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
87 OPT_UINT("size", 's', &cfg.sz, sz),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
88 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
89 OPT_BYTE("queue-type", 'q', &cfg.qt, qt),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
90 OPT_FLAG("consent", 0, &cfg.consent, consent))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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
;
91
92 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
93 if (err)
94 return err;
95
96 if (!consent) {
97 nvme_show_error("ERROR: consent required")nvme_show_message(1, "ERROR: consent required");
98 return -EINVAL22;
99 }
100
101 // Not that it really matters, but we setup memory as if the CDQ can be held
102 // in user space regardless.
103 queue = libnvme_alloc_huge(cfg.sz << 2, &mh);
104 if (!queue) {
105 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 ()))
)
106 libnvme_strerror(errno))nvme_show_message(1, "ERROR: libnvme_alloc of size %dB failed %s"
, cfg.sz << 2, libnvme_strerror((*__errno_location ()))
)
;
107 return -ENOMEM12;
108 }
109
110 nvme_init_lm_cdq_create(&cmd, NVME_SET(cfg.qt, LM_QT)(((__u32)(cfg.qt) & NVME_LM_QT_MASK) << NVME_LM_QT_SHIFT
)
,
111 cfg.cntlid, cfg.sz, queue);
112 err = libnvme_exec_admin_passthru(hdl, &cmd);
113 if (err < 0)
114 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 ())))
;
115 else if (err)
116 nvme_show_status(err);
117 else
118 printf("Create CDQ Successful: CDQID=0x%04x\n",
119 NVME_GET((__u32)cmd.result, LM_CREATE_CDQ_CDQID)((((__u32)cmd.result) >> NVME_LM_CREATE_CDQ_CDQID_SHIFT
) & NVME_LM_CREATE_CDQ_CDQID_MASK)
);
120
121 return err;
122}
123
124static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
125{
126 const char *desc = "Delete Controller Data Queue";
127 const char *cdqid = "Controller Data Queue ID";
128
129 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
130 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
131 struct libnvme_passthru_cmd cmd;
132 int err = -1;
133
134 struct config {
135 __u16 cdqid;
136 };
137
138 struct config cfg = {
139 .cdqid = 0
140 };
141
142 NVME_ARGS(opts,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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
143 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid))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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
;
144
145 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
146 if (err)
147 return err;
148
149 nvme_init_lm_cdq_delete(&cmd, 0, cfg.cdqid);
150 err = libnvme_exec_admin_passthru(hdl, &cmd);
151 if (err < 0)
152 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 ())))
;
153 else if (err > 0)
154 nvme_show_status(err);
155 else
156 printf("Delete CDQ Successful: CDQID=0x%04x\n", cfg.cdqid);
157
158 return err;
159}
160
161static const char * const lm_track_send_select_argstr[] = {
162 [NVME_LM_SEL_LOG_USER_DATA_CHANGES] = "Log User Data Changes",
163 [NVME_LM_SEL_TRACK_MEMORY_CHANGES] = "Track Memory Changes"
164};
165
166static int lm_track_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
167{
168 const char *desc = "Track Send command used to manage the tracking of information by a "
169 "controller";
170 const char *sel = "Type of management operation to perform\n"
171 " 0h = Log User Data Changes\n"
172 " 1h = Track Memory Changes";
173 const char *mos = "Management operation specific";
174 const char *cdqid = "Controller Data Queue ID";
175 const char *start = "Equivalent to start tracking with defaults";
176 const char *stop = "Equivalent to stop tracking with defaults";
177
178
179 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
180 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
181 struct libnvme_passthru_cmd cmd;
182 int err = -1;
183
184 struct config {
185 __s8 sel;
186 __u8 mos;
187 __u16 cdqid;
188 bool_Bool start;
189 bool_Bool stop;
190 };
191
192 struct config cfg = {
193 .sel = -1,
194 .mos = 0,
195 .cdqid = 0,
196 .start = false0,
197 .stop = false0,
198 };
199
200 NVME_ARGS(opts,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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
201 OPT_BYTE("sel", 's', &cfg.sel, sel),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
202 OPT_BYTE("mos", 'm', &cfg.mos, mos),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
203 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
204 OPT_FLAG("start", 0, &cfg.start, start),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
205 OPT_FLAG("stop", 0, &cfg.stop, stop))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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
;
206
207 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
208 if (err)
209 return err;
210
211 if (cfg.sel == -1) {
212 nvme_show_error("Select field required")nvme_show_message(1, "Select field required");
213 return -EINVAL22;
214 }
215
216 if (cfg.sel != NVME_LM_SEL_LOG_USER_DATA_CHANGES) {
217 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])), cfg.sel))
218 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])), cfg.sel))
;
219 return -EINVAL22;
220 }
221
222 if (cfg.start && cfg.stop) {
223 nvme_show_error("Must select one of start & stop, not both")nvme_show_message(1, "Must select one of start & stop, not both"
)
;
224 return -EINVAL22;
225 } else if (cfg.sel == NVME_LM_SEL_LOG_USER_DATA_CHANGES) {
226 if (cfg.start)
227 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)
;
228 else if (cfg.stop)
229 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)
;
230 }
231
232 nvme_init_lm_track_send(&cmd, cfg.sel, cfg.mos, cfg.cdqid);
233 err = libnvme_exec_admin_passthru(hdl, &cmd);
234 if (err < 0)
235 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 ())))
;
236 else if (err)
237 nvme_show_status(err);
238 else
239 printf("Track Send (%s) Successful\n",
240 ARGSTR(lm_track_send_select_argstr, cfg.sel)arg_str(lm_track_send_select_argstr, (sizeof(lm_track_send_select_argstr
) / sizeof((lm_track_send_select_argstr)[0])), cfg.sel)
);
241
242 return err;
243}
244
245static const char * const lm_migration_send_select_argstr[] = {
246 [NVME_LM_SEL_SUSPEND] = "Suspend",
247 [NVME_LM_SEL_RESUME] = "Resume",
248 [NVME_LM_SEL_SET_CONTROLLER_STATE] = "Set Controller State"
249};
250
251static int lm_migration_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
252{
253 const char *desc = "Migration Send command is used to manage the migration of a controller";
254 const char *sel = "Select (SEL) the type of management operation to perform "
255 "(CDW10[07:00])\n"
256 " 0h = Suspend\n"
257 " 1h = Resume\n"
258 " 2h = Set Controller State";
259 const char *cntlid = "Controller Identifier (CDW11[15:00])";
260 const char *stype = "Type of suspend (STYPE) (CDW11[23:16]\n"
261 " 0h = Suspend Notification\n"
262 " 1h = Suspend";
263 const char *dudmq = "Delete user data migration queue (DUDMQ) as part of suspend operation "
264 "(CDW11[31])";
265 const char *seqind = "Sequence Indicator (CDW10[17:16])\n"
266 " 0h = Not first not last\n"
267 " 1h = First in two or more\n"
268 " 2h = Last in two or more\n"
269 " 3h = Entire state info";
270 const char *csuuidi = "Controller State UUID Index (CSUUIDI) (CDW11[31:24])";
271 const char *csvi = "Controller State Version Index (CSVI) (CDW11[23:16])";
272 const char *uidx = "UUID Index (UIDX) (CDW14[16:00])";
273 const char *offset = "Controller State Offset";
274 const char *numd = "Number of Dwords (NUMD)";
275 const char *input = "Controller State Data input file";
276
277 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
278 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
279 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
280 __cleanup_file__attribute__((cleanup(cleanup_file))) FILE *file = NULL((void*)0);
281 struct libnvme_passthru_cmd cmd;
282 void *data = NULL((void*)0);
283 int err = -1;
284
285 struct config {
286 __s8 sel;
287 __u16 cntlid;
288 __u8 stype;
289 __u8 seqind;
290 __u8 csuuidi;
291 __u8 csvi;
292 __u8 uidx;
293 __u64 offset;
294 __u32 numd;
295 char *input;
296 bool_Bool dudmq;
297 };
298
299 struct config cfg = {
300 .sel = -1,
301 .cntlid = 0,
302 .stype = 0,
303 .seqind = 0,
304 .csuuidi = 0,
305 .csvi = 0,
306 .uidx = 0,
307 .offset = 0,
308 .numd = 0,
309 .input = NULL((void*)0),
310 .dudmq = false0
311 };
312
313 NVME_ARGS(opts,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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
314 OPT_BYTE("sel", 's', &cfg.sel, sel),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
315 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
316 OPT_BYTE("stype", 't', &cfg.stype, stype),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
317 OPT_FLAG("dudmq", 'd', &cfg.dudmq, dudmq),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
318 OPT_BYTE("seq-ind", 'S', &cfg.seqind, seqind),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
319 OPT_BYTE("csuuidi", 'U', &cfg.csuuidi, csuuidi),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
320 OPT_BYTE("csvi", 'V', &cfg.csvi, csvi),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
321 OPT_BYTE("uidx", 'u', &cfg.uidx, uidx),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
322 OPT_LONG("offset", 'O', &cfg.offset, offset),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
323 OPT_UINT("numd", 'n', &cfg.numd, numd),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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
324 OPT_FILE("input-file", 'f', &cfg.input, input))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, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
;
325
326 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
327 if (err)
328 return err;
329
330 if (cfg.sel == -1) {
331 nvme_show_error("Select field required")nvme_show_message(1, "Select field required");
332 return -EINVAL22;
333 }
334
335 // Sanity check input parameters
336 if (cfg.sel == NVME_LM_SEL_SUSPEND || cfg.sel == NVME_LM_SEL_RESUME) {
337 if (cfg.csuuidi != 0 || cfg.csvi != 0) {
338 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])), cfg.sel))
339 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])), cfg.sel))
;
340 return -EINVAL22;
341 }
342 } else if (cfg.sel == NVME_LM_SEL_SET_CONTROLLER_STATE) {
343 if (cfg.dudmq || cfg.stype != 0) {
344 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])), cfg.sel))
345 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])), cfg.sel))
;
346 return -EINVAL22;
347 } else if (!strlen(cfg.input)) {
348 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])), cfg.sel))
349 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])), cfg.sel))
;
350 return -EINVAL22;
351 }
352 }
353
354 if (cfg.input && strlen(cfg.input)) {
355 file = fopen(cfg.input, "r");
356 if (file == NULL((void*)0)) {
357 nvme_show_perror(cfg.input);
358 return -EINVAL22;
359 }
360
361 data = libnvme_alloc_huge(cfg.numd << 2, &mh);
362 if (!data)
363 return -ENOMEM12;
364
365 size_t n_data = fread(data, 1, cfg.numd << 2, file);
366
367 fclose(file);
368
369 if (n_data != (size_t)(cfg.numd << 2)) {
370 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 ())))
;
371 return -errno(*__errno_location ());
372 }
373 }
374
375 nvme_init_lm_migration_send(&cmd, cfg.sel,
376 NVME_SET(cfg.seqind, LM_SEQIND)(((__u32)(cfg.seqind) & NVME_LM_SEQIND_MASK) << NVME_LM_SEQIND_SHIFT
)
, cfg.cntlid,
377 cfg.stype, cfg.dudmq, cfg.csvi, cfg.csuuidi,
378 cfg.offset, cfg.uidx, data,
379 (cfg.numd << 2));
380 err = libnvme_exec_admin_passthru(hdl, &cmd);
381 if (err < 0)
382 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 ())))
;
383 else if (err > 0)
384 nvme_show_status(err);
385 else
386 printf("Migration Send (%s) Successful\n",
387 ARGSTR(lm_migration_send_select_argstr, cfg.sel)arg_str(lm_migration_send_select_argstr, (sizeof(lm_migration_send_select_argstr
) / sizeof((lm_migration_send_select_argstr)[0])), cfg.sel)
);
388
389
390 return err;
391}
392
393static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct plugin *plugin)
394{
395 const char *desc = "Migration Receive command is used to obtain information used to manage "
396 " a migratable controller";
397 const char *sel = "Select (SEL) the type of management operation to perform "
398 "(CDW10[07:00])\n"
399 " 0h = Get Controller State";
400 const char *cntlid = "Controller Identifier (CDW10[31:16])";
401 const char *csuuidi = "Controller State UUID Index (CSUUIDI) (CDW11[23:16])";
402 const char *csvi = "Controller State Version Index (CSVI) (CDW11[7:0])";
403 const char *uidx = "UUID Index (UIDX) (CDW14[16:00])";
404 const char *offset = "Controller State Offset";
405 const char *numd = "Number of Dwords (NUMD)";
406 const char *output = "Controller State Data output file";
407 const char *human_readable_info = "show info in readable format";
408
409 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
410 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
411 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
412 __cleanup_file__attribute__((cleanup(cleanup_file))) FILE *fd = NULL((void*)0);
413 struct libnvme_passthru_cmd cmd;
414 nvme_print_flags_t flags;
415 void *data = NULL((void*)0);
416 int err = -1;
417 __u16 mos;
418
419 struct config {
420 __u8 sel;
421 __u16 cntlid;
422 __u8 csuuidi;
423 __u8 csvi;
424 __u8 uidx;
425 __u64 offset;
426 __u32 numd;
427 char *output;
428 bool_Bool human_readable;
429 };
430
431 struct config cfg = {
432 .sel = -1,
433 .cntlid = 0,
434 .csuuidi = 0,
435 .csvi = 0,
436 .uidx = 0,
437 .offset = 0,
438 .numd = 0,
439 .output = NULL((void*)0),
440 .human_readable = false0
441 };
442
443 NVME_ARGS(opts,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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
444 OPT_BYTE("sel", 's', &cfg.sel, sel),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
445 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
446 OPT_BYTE("csuuidi", 'U', &cfg.csuuidi, csuuidi),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
447 OPT_BYTE("csvi", 'V', &cfg.csvi, csvi),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
448 OPT_BYTE("uidx", 'u', &cfg.uidx, uidx),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
449 OPT_LONG("offset", 'O', &cfg.offset, offset),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
450 OPT_UINT("numd", 'n', &cfg.numd, numd),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
451 OPT_FILE("output-file", 'f', &cfg.output, output),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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
452 OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_info))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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
;
453
454 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
455 if (err)
1
Assuming 'err' is 0
2
Taking false branch
456 return err;
457
458 err = validate_output_format(nvme_args.output_format, &flags);
459 if (err < 0) {
3
Assuming 'err' is >= 0
460 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
461 return err;
462 }
463
464 if (nvme_args.output_format && cfg.offset != 0 && !(flags & BINARY)) {
4
Assuming field 'output_format' is null
465 nvme_show_error("cannot parse non-zero offset")nvme_show_message(1, "cannot parse non-zero offset");
466 return -EINVAL22;
467 }
468
469 if (cfg.human_readable)
5
Assuming field 'human_readable' is false
470 flags |= VERBOSE;
471
472 if (cfg.output && strlen(cfg.output)) {
6
Assuming field 'output' is non-null
7
Assuming the condition is true
8
Taking true branch
473 fd = fopen(cfg.output, "w");
9
Stream opened here
10
Assuming that 'fopen' is successful
474 if (fd
10.1
'fd' is >= null
< 0) {
11
Taking false branch
475 nvme_show_perror(cfg.output);
476 return -errno(*__errno_location ());
477 }
478 }
479
480 data = libnvme_alloc_huge((cfg.numd + 1) << 2, &mh);
481 if (!data)
12
Assuming 'data' is null
13
Taking true branch
482 return -ENOMEM12;
14
Opened stream never closed. Potential resource leak
483
484 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)
;
485 nvme_init_lm_migration_recv(&cmd, cfg.offset, mos, cfg.cntlid,
486 cfg.csuuidi, cfg.sel, cfg.uidx, 0, data,
487 (cfg.numd + 1) << 2);
488 err = libnvme_exec_admin_passthru(hdl, &cmd);
489 if (err < 0)
490 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 ())))
;
491 else if (err)
492 nvme_show_status(err);
493 else if (cfg.sel == NVME_LM_SEL_GET_CONTROLLER_STATE) {
494 if (flags == NORMAL)
495 printf("CDW0: 0x%"PRIu64"l" "u"": Controller %sSuspended\n",
496 (uint64_t)cmd.result,
497 (cmd.result & NVME_LM_GET_CONTROLLER_STATE_CSUP) ?
498 "" : "NOT ");
499
500 if (cfg.output && strlen(cfg.output)) {
501 if (fwrite(data, 1, cfg.numd << 2, fd) != (cfg.numd << 2)) {
502 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 ())))
503 libnvme_strerror(errno))nvme_show_message(1, "ERROR: %s: failed to write buffer to output file"
, libnvme_strerror((*__errno_location ())))
;
504 err = -errno(*__errno_location ());
505 }
506 } else {
507 lm_show_controller_state_data((struct nvme_lm_controller_state_data *)data,
508 (cfg.numd + 1) << 2, cfg.offset, flags);
509 }
510 }
511
512 return 0;
513}
514
515enum lm_controller_data_queue_feature_id {
516 lm_cdq_feature_id = 0x21
517};
518
519static int lm_set_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
520{
521 const char *desc = "This Feature allows a host to update the status of the head pointer "
522 "of a CDQ and specify the configuration of a CDQ Tail event.";
523 const char *cdqid = "Controller Data Queue ID";
524 const char *hp = "The slot of the head pointer for the specified CDQ";
525 const char *tpt = "If specified, the slot that causes the controller "
526 " to issue a CDQ Tail Pointer event";
527
528 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
529 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
530 int err = -1;
531
532 struct config {
533 __u16 cdqid;
534 __u32 hp;
535 __s32 tpt;
536 };
537
538 struct config cfg = {
539 .cdqid = 0,
540 .hp = 0,
541 .tpt = -1,
542 };
543
544 NVME_ARGS(opts,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, }, {"output-format"
, 'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
545 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid),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, }, {"output-format"
, 'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
546 OPT_UINT("hp", 'H', &cfg.hp, hp),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, }, {"output-format"
, 'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
547 OPT_UINT("tpt", 'T', &cfg.tpt, tpt))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, }, {"output-format"
, 'o', "FMT", CFG_STRING, &nvme_args.output_format, 1, "Output format: normal|json|binary|tabular"
, 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}, { ((void*)0) } }
;
548
549 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
550 if (err)
551 return err;
552
553 err = nvme_set_features(hdl, 0, lm_cdq_feature_id, 0, cfg.cdqid |
554 ((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),
555 cfg.hp, cfg.tpt, 0, 0, NULL((void*)0), 0, NULL((void*)0));
556 if (err < 0)
557 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 ())))
;
558 else if (err)
559 nvme_show_status(err);
560 else
561 printf("Success. Head Pointer: %d\n", cfg.hp);
562
563 return err;
564}
565
566static int lm_get_cdq(int argc, char **argv, struct command *acmd, struct plugin *plugin)
567{
568 const char *desc = "This Feature allows a host to retrieve the status of the head pointer "
569 "of a CDQ and specify the configuration of a CDQ Tail event.";
570 const char *cdqid = "Controller Data Queue ID";
571
572 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
573 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
574 nvme_print_flags_t flags;
575 int err = -1;
576
577 struct config {
578 __u16 cdqid;
579 };
580
581 struct config cfg = {
582 .cdqid = 0,
583 };
584
585 NVME_ARGS(opts,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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
586 OPT_SHRT("cdqid", 'C', &cfg.cdqid, cdqid))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, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary|tabular", 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}, { ((void*)0) } }
;
587
588 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
589 if (err)
590 return err;
591
592 err = validate_output_format(nvme_args.output_format, &flags);
593 if (err < 0) {
594 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
595 return err;
596 }
597
598 struct nvme_lm_ctrl_data_queue_fid_data data;
599
600 err = nvme_get_features(hdl, 0, lm_cdq_feature_id, 0, cfg.cdqid, 0,
601 &data, sizeof(data), NULL((void*)0));
602 if (err < 0)
603 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 ())))
;
604 else if (err)
605 nvme_show_status(err);
606 else
607 lm_show_controller_data_queue(&data, flags);
608
609 return err;
610}