Hannes Reinecke [Tue, 28 Mar 2023 10:28:21 +0000 (12:28 +0200)]
Print out correct TREQ strings for discovery
The TREQ field in the discover log page is actually a bit field,
so we need to update the string mapping to print out all possible
combinations correctly.
Minwoo Im [Wed, 22 Mar 2023 22:59:03 +0000 (07:59 +0900)]
tree: fix generic device open failure
If scan_namespace is called with a generic device (e.g., /dev/ng0n1)
given, it fails to scan a namespace based on the generic device because
there's no entry point in /sys/block/ for the generic device.
This patch provides two helpers to change the given generic device name
to a block device name based on the instances:
ng0n1 -> nvme0n1
This patch fixes command failure:
root@vm:~/work/nvme-cli.git# nvme show-regs /dev/ng0n1
Unable to find ng0n1
get-property: Invalid argument
Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
[dwagner: also catch blkdev allocation failures] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Hannes Reinecke [Thu, 23 Mar 2023 09:44:02 +0000 (10:44 +0100)]
fabrics: add configuration option 'tls_key'
Add a fabrics configuration option to specify the TLS PSK for a
connection. The PSK is referenced by its serial number, but stored
with its description in the JSON configuration file.
Hannes Reinecke [Thu, 23 Mar 2023 09:14:03 +0000 (10:14 +0100)]
fabrics: add configuration option 'keyring'
Add a fabrics configuation option 'keyring' to set the keyring
for storing and looking up keys.
As the keyring serial number is ephemeral we cannot store it
in the JSON configuration file, so store the keyring description
instead.
Hannes Reinecke [Thu, 23 Mar 2023 13:46:13 +0000 (14:46 +0100)]
linux: add key helper functions
Add helper functions for key handling.
Signed-off-by: Hannes Reinecke <hare@suse.de>
[dwagner:
- set errno on failure and updated documentation accordingly
- fix return check of nvme_lookup_key in nvme_insert_tls_key] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Hannes Reinecke [Thu, 23 Mar 2023 13:18:44 +0000 (14:18 +0100)]
linux: add nvme_lookup_keyring()
Add a function to lookup a keyring by its description.
Signed-off-by: Hannes Reinecke <hare@suse.de>
[dwagner:
- pass in command line option to dependency requirement argument
- drop log message, find_key_by_type_and_desc sets errno] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Fri, 24 Mar 2023 15:50:48 +0000 (16:50 +0100)]
build: Update OpenSSL wrap
Update to OpenSSL 3.0.7.
When the fallback was using v1 we never went into the v3 testing. With
updating to v3 we are going to figure out if we have LibreSSL spin of
the API. But cc.has_header_symbol() and cc.has_header() only work on
external library and not on fallbacks.
Thus if we use the fallback (internal) we just know it is API version 3
and don't do any crazy testing.
Martin Belanger [Fri, 17 Mar 2023 15:56:26 +0000 (11:56 -0400)]
python: Add setter property for controller DHCHAP Key
Similar to the way we allow setting/getting the Host DHCHAP key,
we need to allow setting/getting the Controller DHCHAP Key.
There was already a "getter" property, but the "setter" property
was missing.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Martin Belanger [Fri, 17 Mar 2023 12:12:07 +0000 (08:12 -0400)]
python: Remove redundant host.set_key() method
I just found out that the DHCHAP Key can be set as a property
(e.g. host.dhchap_key = "THE-KEY"). So, we can remove the set_key()
method that was added a few days ago.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
src/nvme/api-types.h:815: warning: Function parameter or member 'mos' not described in 'nvme_io_mgmt_recv_args'
src/nvme/api-types.h:815: warning: Function parameter or member 'mo' not described in 'nvme_io_mgmt_recv_args'
src/nvme/api-types.h:837: warning: Function parameter or member 'mos' not described in 'nvme_io_mgmt_send_args'
src/nvme/api-types.h:837: warning: Function parameter or member 'mo' not described in 'nvme_io_mgmt_send_args'
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Martin Belanger [Wed, 1 Mar 2023 19:21:03 +0000 (14:21 -0500)]
python, meson: Assert that deps are present for -Dpython=true
The -Dpython option takes 3 values: auto, true, or false. For
"auto", the Python bindings will be built if all the dependencies
are met and will be skipped in not. For "true", the Python bindings
MUST be built and therefore missing dependencies need to be treated
as an error. For "false", the Python bindings won't be built whether
the dependencies are met or not.
Currently, with -Dpython=true, if a dependency required to build the
Python bindings is missing, meson silently skips it (i.e. it behaves
like "-Dpython=auto").
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Martin Belanger [Tue, 28 Feb 2023 18:56:36 +0000 (13:56 -0500)]
python: Reformat SWIG input file
The SWIG file contains a lot of C code that was not following the
standard formatting (e.g. indent with tabs). I ran a code
beautifier to bring this code in compliance and make it easier to
read.
P.S. I verified that the code generated has not changed and tested
that eveyrhing still works as usual.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Martin Belanger [Mon, 27 Feb 2023 18:37:20 +0000 (13:37 -0500)]
python: Fix segmentation fault during garbage collection
With SWIG we create proxy classes to wrap the C structures (struct).
These classes are used to create Python objects matching the C
structures such as:
`nvme.root` is used to wrap `struct nvme_root`
`nvme.host` is used to wrap `struct nvme_host`
`nvme.ctrl` is used to wrap `struct nvme_ctrl`
etc...
One thing that SWIG cannot do is figure out the dependencies
between the different objects. For example, it cannot tell that
when deleting a host object that all the subsystems, controllers,
namespaces under that host need to be deleted as well. That's an
implicit property of the libnvme driver and users need to know to
stop using objects after their parent has been deleted.
Unfotunately, with Python the Gargage Collector (GC) decides which
objects to delete and it can delete obects in any order it sees fit.
This can result in objects being deleted in the wrong order. For
example, the GC may delete a host object (`nvme_free_host`) before
deleting any of the controller objects under that host. And when the
GC finally deletes a controller by calling `nvme_free_ctrl()`, the
memory for that controller has already been freed and a segmentation
fault will result.
To enforce that objects get deleted in the right order, we need to
set dependencies between objects at the Python level. This can be
achived by having children objects maintain a reference to their
parents. This way a parent cannot be deleted before all its children
have been deleted.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Daniel Wagner [Wed, 15 Feb 2023 11:18:07 +0000 (12:18 +0100)]
mi: Add nvme_mi_admin_get_log_page
The non MI API has an nvme_get_log_page() function which accepts the
transfer length. In order to be able to use the nvme_get_log_page()
function ins nvme-cli, the MI API needs to provide the same API so that
the transport abstraction wrappers work.
Daniel Wagner [Wed, 15 Feb 2023 11:16:03 +0000 (12:16 +0100)]
ioctl: Set file descriptor in nvme_get_log_page()
We explicitly ask for a file descriptor in the API so use it. The caller
might not have set it in args.
For example, in nvme-cli when the libnvme wrappers are used to hide the
transport details from the nvme-cli core, the macros only pass the file
descriptor via the function arguments but don't set it in the arg
structs.
Keith Busch [Thu, 9 Feb 2023 18:47:19 +0000 (10:47 -0800)]
fix endians
All the nvme defined payloads are in little endian. All the known users
are alrady using the appropriate le*_to_cpu() accessors, so just fix the
type annotations.
Cc: Klaus Jensen <its@irrelevant.dk> Signed-off-by: Keith Busch <kbusch@kernel.org>
Daniel Wagner [Fri, 10 Feb 2023 13:56:20 +0000 (14:56 +0100)]
build: Set defaults for libdbus to disabled
People are unhappy with the defaults of libdbus being auto. It pulls in
the extra dependency for little gain. So let's set it to disabled which
is for most developers the right choice anyway.
Daniel Wagner [Mon, 6 Feb 2023 13:48:43 +0000 (14:48 +0100)]
build: Use prefixdir directly on sysconfdir
The sysconfdir is an explicit path '/etc' and the muon implementation of
join_paths is dropping the prefixdir, thus we need to string concanate
the syscondfir path instead of using the join_paths function.
Jeremy Kerr [Thu, 26 Jan 2023 02:28:49 +0000 (10:28 +0800)]
test: mi: Provide a full request buffer for invalid admin req tests
We're issuing an admin command with up to four bytes of data in the
request. Although these will all fail due to invalid args, we still want
to provide enough data to simulate the full request.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Thu, 26 Jan 2023 02:24:54 +0000 (10:24 +0800)]
test: mi: Explicitly zero args for test API invocations
We have a few places where we're passing an uninitialised pointer
argument to the libnvme API in the MI tests. Add an explicit zero init
for these.
Fixes: https://github.com/linux-nvme/libnvme/issues/563 Reported-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Daniel Wagner [Tue, 24 Jan 2023 10:50:01 +0000 (11:50 +0100)]
fabrics: Always sanitize discovery log entries
Do not just sanitize the traddr and trsvcid when unsing the auto
discovery/connect path, instead also do it for all users of
nvmf_get_discovery_log{_args}() per default.
Daniel Wagner [Fri, 20 Jan 2023 09:39:19 +0000 (10:39 +0100)]
gitignore: Ignore clang build artifacts
When using language server support from clang, the .cache directory is
added. Also for getting lsp working properly the compile_commands.json
file has to present (which is just a link to Meson generared json file).
Daniel Wagner [Mon, 16 Jan 2023 13:54:34 +0000 (14:54 +0100)]
build: Set projects default to debug and prefix /usr/local
Do not install to /usr per default and accidently overwrite the
distributions version of the package. And also debugging symbols per
default to make development setup as we don't install it anyway to /usr
anyway.
Hao Jiang [Tue, 10 Jan 2023 19:04:41 +0000 (11:04 -0800)]
mi: add timeout functions to .map
Need to export nvme_mi_ep_set_timeout and nvme_mi_ep_get_timeout. These
two functions were defined but left over in .map file.
Signed-off-by: Hao Jiang <jianghao@google.com>
[dwagner: moved the function to the LIBNVME_MI_1_3 section] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Klaus Jensen [Thu, 15 Sep 2022 20:54:37 +0000 (22:54 +0200)]
types: add fdp data structures and helpers
Add required data structures and helper functions for TP4146 ("Flexible
Data Placement").
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
[dwagner: - drop packed attribute
- reorder struct args members
- move new functions to next version linker section] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Jinliang Wang [Thu, 1 Dec 2022 07:25:05 +0000 (23:25 -0800)]
mi: use lpo and numd to chunk big get log page command
1) Change log page offset inside `__nvme_mi_admin_get_log`
We use LPO and NUMD to chunk get log page request whose length
is greater than 4KB. This method works better for some of current
devices.
2) Update `test_admin_get_log_split_cb`.
Signed-off-by: Jinliang Wang <jinliangw@google.com>
Tomas Bzatek [Wed, 30 Nov 2022 13:51:09 +0000 (14:51 +0100)]
tree: Fix leaking struct nvme_ns.generic_name
==306445== 96 bytes in 16 blocks are definitely lost in loss record 3,171 of 3,553
==306445== at 0x484386F: malloc (vg_replace_malloc.c:393)
==306445== by 0x4FA2F6D: strdup (strdup.c:42)
==306445== by 0x7B9C477: nvme_ns_set_generic_name (tree.c:1802)
==306445== by 0x7B9C51B: nvme_ns_open (tree.c:1820)
==306445== by 0x7B9C606: __nvme_scan_namespace (tree.c:1853)
==306445== by 0x7B9CA0C: nvme_subsystem_scan_namespace (tree.c:1931)
==306445== by 0x7B98C81: nvme_subsystem_scan_namespaces (tree.c:496)
==306445== by 0x7B991BC: nvme_scan_subsystem (tree.c:597)
==306445== by 0x7B97DA1: nvme_scan_topology (tree.c:118)
==306445== by 0x7B97FA9: nvme_scan (tree.c:177)
Valgrind complaining about accessing uninitialized memory:
==159962== Conditional jump or move depends on uninitialised value(s)
==159962== at 0x484BCF6: rawmemchr (vg_replace_strmem.c:1564)
==159962== by 0x4F52B15: _IO_str_init_static_internal (strops.c:41)
==159962== by 0x4F1DAB1: UnknownInlinedFun (strfile.h:95)
==159962== by 0x4F1DAB1: __isoc99_sscanf (isoc99_sscanf.c:28)
==159962== by 0x7B77C97: uuid_from_dmi_entries (fabrics.c:969)
==159962== by 0x7B84192: UnknownInlinedFun (fabrics.c:1059)
==159962== by 0x7B84192: nvmf_hostnqn_generate (fabrics.c:1070)
rename the `tmp` variable into `xfered_size`.
It is hard to figure out a name which can imply that this variable
is used as both input and output parameter, so I choose `xfered_size`
to emphasize the output functionality.
Signed-off-by: Jinliang Wang <jinliangw@google.com>