]> git.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
19 months agodoc: Regenerate all docs for v1.4 v1.4
Daniel Wagner [Fri, 31 Mar 2023 14:05:19 +0000 (16:05 +0200)]
doc: Regenerate all docs for v1.4

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agobuild: Update version to v1.4
Daniel Wagner [Fri, 31 Mar 2023 14:04:49 +0000 (16:04 +0200)]
build: Update version to v1.4

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agofabrics: Filter out invalid UUIDs from DMI
Daniel Wagner [Thu, 30 Mar 2023 14:14:19 +0000 (16:14 +0200)]
fabrics: Filter out invalid UUIDs from DMI

Qemu might not initialize the system DMI correctly and nvme-cli would
generate an invalid hostid.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agofabrics: Add define for DMI sysinfo
Daniel Wagner [Thu, 30 Mar 2023 13:55:24 +0000 (15:55 +0200)]
fabrics: Add define for DMI sysinfo

19 months agodoc: Do not hardcode default location for config files
Daniel Wagner [Wed, 29 Mar 2023 15:14:05 +0000 (17:14 +0200)]
doc: Do not hardcode default location for config files

The location of the config files is depending of the configuration.
Because we ship pre-compiled documentation the SYSCONFDIR might not be
correct.

Avoid confusion and just point out they live under SYSCONFDIR.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agodoc: Update build script to use correct meson verbs
Daniel Wagner [Wed, 29 Mar 2023 15:13:00 +0000 (17:13 +0200)]
doc: Update build script to use correct meson verbs

Use setup and compile as meson verbs.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agoPrint out correct TREQ strings for discovery
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.

Signed-off-by: Hannes Reinecke <hare@suse.de>
19 months agotree: fix generic device open failure
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>
19 months agofabrics: add configuration option 'tls_key'
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.

Signed-off-by: Hannes Reinecke <hare@suse.de>
19 months agofabrics: add configuration option 'keyring'
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.

Signed-off-by: Hannes Reinecke <hare@suse.de>
19 months agolinux: add key helper functions
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>
19 months agonvme: add 'nvme_insert_tls_key()' function
Hannes Reinecke [Wed, 22 Mar 2023 14:44:31 +0000 (15:44 +0100)]
nvme: add 'nvme_insert_tls_key()' function

Add a function to derive a TLS key and insert it into the given
keyring.

Signed-off-by: Hannes Reinecke <hare@suse.de>
[dwagner: updated doc to mention errno set if failure]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agolinux: add nvme_lookup_keyring()
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>
19 months agopython: Change python option from combo to feature
Martin Belanger [Fri, 24 Mar 2023 15:18:20 +0000 (11:18 -0400)]
python: Change python option from combo to feature

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
19 months agobuild: Update OpenSSL wrap
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agobuild: Update json-c wrap
Daniel Wagner [Fri, 24 Mar 2023 15:50:20 +0000 (16:50 +0100)]
build: Update json-c wrap

Update to json-c 0.16

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agobuild: Add build action back
Daniel Wagner [Fri, 24 Mar 2023 13:35:19 +0000 (14:35 +0100)]
build: Add build action back

The test meson target builds only the necessary files for passing the
test target. To build the complete library use the build target.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agotypes: add opcode field to error log page (TP4113)
Minwoo Im [Wed, 8 Mar 2023 23:48:46 +0000 (08:48 +0900)]
types: add opcode field to error log page (TP4113)

Add support for opcode field in error information log page based on TP
4113. It is easy to identify which command is associated with the error.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
19 months agopython: Add setter property for controller DHCHAP Key
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>
19 months agopython: Remove redundant host.set_key() method
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>
19 months agobuild, meson: Print option summary
Martin Belanger [Wed, 15 Mar 2023 19:49:43 +0000 (15:49 -0400)]
build, meson: Print option summary

At the end of the meson setup command, display the options so that
we can quickly determine that we're configured the project properly

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
19 months agoPython: Add support for setting/getting Host DHCHAP key
Martin Belanger [Wed, 15 Mar 2023 20:05:53 +0000 (16:05 -0400)]
Python: Add support for setting/getting Host DHCHAP key

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
19 months agoPython: Add hostnqn_from_file() and hostid_from_file()
Martin Belanger [Wed, 15 Mar 2023 19:56:55 +0000 (15:56 -0400)]
Python: Add hostnqn_from_file() and hostid_from_file()

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
19 months agotypes: Update position of elbatm in struct nvme_copy_range{_f1}
zerone [Wed, 1 Mar 2023 10:58:26 +0000 (18:58 +0800)]
types: Update position of elbatm in struct nvme_copy_range{_f1}

Update the Expected Logical Block Application Tag and Reference Tag in
struct nvme_copy_range and struct nvme_copy_range_f1.

 1. The elbatm is behind elbat fields, which are defined in section
    3.2.2 Copy command

 2. Storage and Reference Space is declared as an big-endian order,
    the elbt[10] fields need to reassigned

[dwagner: squashed changes and updated commit message]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agobuild: Upload all log files on failure
Daniel Wagner [Tue, 14 Mar 2023 14:00:53 +0000 (15:00 +0100)]
build: Upload all log files on failure

Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agobuild: Initialize sysconfdir
Daniel Wagner [Tue, 14 Mar 2023 13:18:40 +0000 (14:18 +0100)]
build: Initialize sysconfdir

The default sysconfdir needs to be initialize so that Meson and muon
expand to the same final result using join_paths().

Fixes: f6100dd16b49 ("build: Use prefixdir directly on sysconfdir")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
19 months agodoc: fix kernel-doc-check warning
Steven Seungcheol Lee [Mon, 6 Mar 2023 06:37:10 +0000 (15:37 +0900)]
doc: fix kernel-doc-check warning

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>
20 months agopython, meson: Assert that deps are present for -Dpython=true
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>
20 months agopython: Reformat SWIG input file
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>
20 months agopython test: Check there is no SIGSEGV during garbage collection
Martin Belanger [Tue, 28 Feb 2023 17:17:08 +0000 (12:17 -0500)]
python test: Check there is no SIGSEGV during garbage collection

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
20 months agopython: Return PyObject* from __str__() instead of a static char[]
Martin Belanger [Tue, 28 Feb 2023 17:15:30 +0000 (12:15 -0500)]
python: Return PyObject* from __str__() instead of a static char[]

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
20 months agopython: Fix segmentation fault during garbage collection
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>
20 months agobuild: Enable test in muon minimal build
Daniel Wagner [Fri, 17 Feb 2023 07:57:26 +0000 (08:57 +0100)]
build: Enable test in muon minimal build

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agobuild: Streamline workflows with nvme-cli
Daniel Wagner [Thu, 16 Feb 2023 15:22:55 +0000 (16:22 +0100)]
build: Streamline workflows with nvme-cli

Make the build workflow similiar to the one we have in nvme-cli.

- Explicitly configure release/debug build
- Explicitly set wrap mode
- Explicitly enable/disable --werror (disable it for fallbacks)
- Cleanup install depedencies
- Merge muon.yml into build.yml
- Move coverage into coverage.yml

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agomi: Add nvme_mi_admin_get_log_page
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agoioctl: Set file descriptor in nvme_get_log_page()
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agofix endians
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>
20 months agoMerge pull request #577 from igaw/build-updates
Daniel Wagner [Fri, 10 Feb 2023 14:50:09 +0000 (15:50 +0100)]
Merge pull request #577 from igaw/build-updates

Update build settings and add additional CI targets

20 months agobuild: Add muon build
Daniel Wagner [Fri, 10 Feb 2023 14:18:24 +0000 (15:18 +0100)]
build: Add muon build

Build project using muon instead of meson.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agobuild: Rename meson.yml to build.yml
Daniel Wagner [Fri, 10 Feb 2023 13:58:49 +0000 (14:58 +0100)]
build: Rename meson.yml to build.yml

As we only have Meson as build framework, we just can call this file build.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agobuild: Set defaults for libdbus to disabled
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agoMerge pull request #574 from igaw/make-json-c-optional
Daniel Wagner [Fri, 10 Feb 2023 13:47:38 +0000 (14:47 +0100)]
Merge pull request #574 from igaw/make-json-c-optional

build: Make json-c dependency optional again

20 months agoMerge pull request #573 from igaw/fix-muon-build
Daniel Wagner [Tue, 7 Feb 2023 08:42:28 +0000 (09:42 +0100)]
Merge pull request #573 from igaw/fix-muon-build

build: Use prefixdir directly on sysconfdir

20 months agoMerge pull request #576 from igaw/fix-strchomp-callers
Daniel Wagner [Tue, 7 Feb 2023 08:41:47 +0000 (09:41 +0100)]
Merge pull request #576 from igaw/fix-strchomp-callers

fabrics: Do not ignore one char whitespace when string sanitizing

20 months agofabrics: Do not ignore one char whitespace when string sanitizing
Daniel Wagner [Tue, 7 Feb 2023 08:30:42 +0000 (09:30 +0100)]
fabrics: Do not ignore one char whitespace when string sanitizing

strchomp() is handling the max length of a string correctly.

Reported-by: calebsander
Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agoMerge pull request #575 from igaw/update-dbus-wrap
Daniel Wagner [Tue, 7 Feb 2023 08:25:08 +0000 (09:25 +0100)]
Merge pull request #575 from igaw/update-dbus-wrap

build: Update dbus.wrap

20 months agobuild: Update dbus.wrap
Daniel Wagner [Tue, 7 Feb 2023 06:56:32 +0000 (07:56 +0100)]
build: Update dbus.wrap

The 'use list for dbus_static_flags' fix has been merged which adds
support older version Meson.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agobuild: Make json-c dependency optional again
Daniel Wagner [Mon, 6 Feb 2023 14:04:46 +0000 (15:04 +0100)]
build: Make json-c dependency optional again

Make support for JSON related functionality optional again. Some
embedded configuration do not want to have a lot of dependencies.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
20 months agobuild: Use prefixdir directly on sysconfdir
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #570 from tbzatek/nss
Daniel Wagner [Wed, 1 Feb 2023 07:29:58 +0000 (08:29 +0100)]
Merge pull request #570 from tbzatek/nss

build: Fix nss code snippet includes

21 months agobuild: Fix nss code snippet includes
Tomas Bzatek [Tue, 31 Jan 2023 22:27:53 +0000 (23:27 +0100)]
build: Fix nss code snippet includes

With hardened distribution CFLAGS the meson code snippet wouldn't compile:

Compiler stderr:
  .build/meson-private/tmpy2z1t5q4/testfile.c: In function 'main':
  .build/meson-private/tmpy2z1t5q4/testfile.c:2:30: error: storage size of 'hints' isn't known
      2 |              struct addrinfo hints, *result;
        |                              ^~~~~
  .build/meson-private/tmpy2z1t5q4/testfile.c:3:21: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
      3 |              return getaddrinfo(argv[1], argv[2], &hints, &result);
        |                     ^~~~~~~~~~~

21 months agodoc: Regenerate all docs for v1.3 v1.3
Daniel Wagner [Mon, 30 Jan 2023 13:09:52 +0000 (14:09 +0100)]
doc: Regenerate all docs for v1.3

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Update version to v1.3
Daniel Wagner [Mon, 30 Jan 2023 13:09:26 +0000 (14:09 +0100)]
build: Update version to v1.3

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #569 from ikegami-t/dst
Daniel Wagner [Sun, 29 Jan 2023 19:06:59 +0000 (20:06 +0100)]
Merge pull request #569 from ikegami-t/dst

types: Add abort self-test code value definition

21 months agotypes: Add abort self-test code value definition
Tokunori Ikegami [Fri, 27 Jan 2023 15:42:12 +0000 (00:42 +0900)]
types: Add abort self-test code value definition

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
21 months agoMerge pull request #567 from igaw/fix-strchomp
Daniel Wagner [Fri, 27 Jan 2023 09:42:51 +0000 (10:42 +0100)]
Merge pull request #567 from igaw/fix-strchomp

fabrics: Avoid buffer overrun in strchomp

21 months agofabrics: Avoid buffer overrun in strchomp
Daniel Wagner [Fri, 27 Jan 2023 09:28:49 +0000 (10:28 +0100)]
fabrics: Avoid buffer overrun in strchomp

strchomp() has an off-by-one error and starts stripping spaces at the
byte AFTER the end of the buffer.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #566 from birkelund/fix-event-timestamp
Daniel Wagner [Thu, 26 Jan 2023 08:32:42 +0000 (09:32 +0100)]
Merge pull request #566 from birkelund/fix-event-timestamp

types: use nvme_timestamp for fdp events

21 months agoMerge pull request #565 from CodeConstruct/pr/563
Daniel Wagner [Thu, 26 Jan 2023 08:28:31 +0000 (09:28 +0100)]
Merge pull request #565 from CodeConstruct/pr/563

test: mi: ensure we're providing full initialised buffers to the libnvme-mi API

21 months agotypes: use nvme_timestamp for fdp events
Klaus Jensen [Thu, 26 Jan 2023 08:18:06 +0000 (09:18 +0100)]
types: use nvme_timestamp for fdp events

The timestamp member of nvme_fdp_event is a proper NVMe Timestamp, so
use the actual data structure for it.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
21 months agotest: mi: Provide a full request buffer for invalid admin req tests
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>
21 months agotest: mi: Explicitly zero args for test API invocations
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>
21 months agoMerge pull request #562 from igaw/sanitize-disc-log
Daniel Wagner [Wed, 25 Jan 2023 11:18:43 +0000 (12:18 +0100)]
Merge pull request #562 from igaw/sanitize-disc-log

fabrics: Always sanitize discovery log entries

21 months agoMerge pull request #564 from igaw/make-pdc-optional
Daniel Wagner [Wed, 25 Jan 2023 11:18:06 +0000 (12:18 +0100)]
Merge pull request #564 from igaw/make-pdc-optional

tree: Add persistent_discovery_ctrl config flag

21 months agotree: Add persistent_discovery_ctrl config flag
Daniel Wagner [Wed, 25 Jan 2023 09:37:13 +0000 (10:37 +0100)]
tree: Add persistent_discovery_ctrl config flag

Allow to overwrite the system default Persistent Discovery Controller
behavior via the config.json file.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agofabrics: Always sanitize discovery log entries
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agogitignore: Ignore clang build artifacts
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).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #560 from igaw/fix-non-trivial-designeded-initializers
Daniel Wagner [Fri, 20 Jan 2023 08:45:56 +0000 (09:45 +0100)]
Merge pull request #560 from igaw/fix-non-trivial-designeded-initializers

ioctl: Initialize non-trivial designated initializers

21 months agoioctl: Initialize non-trivial designated initializers
Daniel Wagner [Fri, 20 Jan 2023 08:42:31 +0000 (09:42 +0100)]
ioctl: Initialize non-trivial designated initializers

Older compilers are not able to do this on their one.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #556 from igaw/add-unique-disc-ctrl
Daniel Wagner [Fri, 20 Jan 2023 07:43:39 +0000 (08:43 +0100)]
Merge pull request #556 from igaw/add-unique-disc-ctrl

Add setter and getter to track unique discovery controller

21 months agotree: Add unique discovery controller flag
Daniel Wagner [Tue, 17 Jan 2023 08:12:38 +0000 (09:12 +0100)]
tree: Add unique discovery controller flag

Introduce a setter an getter to track if a discovery controller is
unique (unique NQN as defined in TP8013).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #557 from igaw/misc-fabric-fixes
Daniel Wagner [Fri, 20 Jan 2023 07:35:55 +0000 (08:35 +0100)]
Merge pull request #557 from igaw/misc-fabric-fixes

Miscellaneous fabric fixes/improvements

21 months agofabrics: Add nqn to connect/disconnect log entry
Daniel Wagner [Wed, 18 Jan 2023 17:14:44 +0000 (18:14 +0100)]
fabrics: Add nqn to connect/disconnect log entry

This helps to figure out which nqn we are connecting to:

  nvme0: nqn.2014-08.org.nvmexpress.discovery connected
  nvme0: nqn.2014-08.org.nvmexpress.discovery disconnected
  nvme0: nqn.discovery connected
  nvme0: nqn.discovery disconnected

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agofabrics: Change string for NVMF_DISC_EFLAGS_NONE
Daniel Wagner [Wed, 18 Jan 2023 08:38:52 +0000 (09:38 +0100)]
fabrics: Change string for NVMF_DISC_EFLAGS_NONE

'nvme discovery' returns for NFMF_DISC_EFLAGS_NONE 'not specified' which
seems to be a copy past error.

Fixes: 43aa825464e5 ("fabrics: Change string for NVMF_DISC_EFLAGS_NONE")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoutil: Add ECONNECTREFUSED to enum nvme_connect_err
Daniel Wagner [Mon, 16 Jan 2023 13:55:17 +0000 (14:55 +0100)]
util: Add ECONNECTREFUSED to enum nvme_connect_err

The kernel might return ECONNECTREFUSED when opening of a socket fails.
Add this missing errno to enum nvme_connect_err.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoioctl: Initialize all members in nvme_fdp_reclaim_unit-handle_status
Daniel Wagner [Tue, 17 Jan 2023 16:49:41 +0000 (17:49 +0100)]
ioctl: Initialize all members in nvme_fdp_reclaim_unit-handle_status

Some compiler complain about the initializers:

 "sorry, unimplemented: non-trivial designated initializers
  not supported"

Address by initializing explicitly all members.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Set projects default to debug and prefix /usr/local
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #558 from birkelund/tp4146
Daniel Wagner [Thu, 19 Jan 2023 15:26:46 +0000 (16:26 +0100)]
Merge pull request #558 from birkelund/tp4146

TP4146 updates

21 months agotypes: nsid is unused in reclaim unit handle usage
Klaus Jensen [Thu, 19 Jan 2023 12:35:08 +0000 (13:35 +0100)]
types: nsid is unused in reclaim unit handle usage

The Reclaim Unit Handle Usage command does not use a namespace
identifier.

Remove the function parameter.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
21 months agoMerge pull request #555 from igaw/build-libdbus-wrap
Daniel Wagner [Fri, 13 Jan 2023 14:43:26 +0000 (15:43 +0100)]
Merge pull request #555 from igaw/build-libdbus-wrap

build: Add support to build libdbus as fallback

21 months agobuild: Add libdbus to build default build environment
Daniel Wagner [Fri, 13 Jan 2023 14:22:32 +0000 (15:22 +0100)]
build: Add libdbus to build default build environment

In order to build all the libnvme-mi we need a libdbus-dev
installed.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Add D-Bus fallback
Daniel Wagner [Wed, 23 Nov 2022 13:01:53 +0000 (14:01 +0100)]
build: Add D-Bus fallback

Add a wrap for D-Bus so we can use it as fallback for static builds.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Remove unused uuid.wrap
Daniel Wagner [Wed, 23 Nov 2022 09:36:35 +0000 (10:36 +0100)]
build: Remove unused uuid.wrap

The depenency on libuuid has been removed but we forgot to remove the
uuid.wrap file. Remove it now.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agoMerge pull request #554 from drakedog2008/pr/timeout
Daniel Wagner [Wed, 11 Jan 2023 09:33:37 +0000 (10:33 +0100)]
Merge pull request #554 from drakedog2008/pr/timeout

mi: add timeout functions to .map

21 months agomi: add timeout functions to .map
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>
21 months agoMerge pull request #552 from birkelund/tp4146
Daniel Wagner [Thu, 5 Jan 2023 14:23:46 +0000 (15:23 +0100)]
Merge pull request #552 from birkelund/tp4146

types: add fdp data structures and helpers

21 months agotypes: add fdp data structures and helpers
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>
22 months agoMerge pull request #551 from jinliangw/spsp_fix
Daniel Wagner [Thu, 22 Dec 2022 08:55:37 +0000 (09:55 +0100)]
Merge pull request #551 from jinliangw/spsp_fix

mi: fix location of spsp1 and spsp0

22 months agomi: fix location of spsp1 and spsp0
Jinliang Wang [Mon, 19 Dec 2022 22:06:03 +0000 (14:06 -0800)]
mi: fix location of spsp1 and spsp0

Command Dword 10 [23:16] : SPSP1
Command Dword 10 [15:08] : SPSP0

Signed-off-by: Jinliang Wang <jinliangw@google.com>
23 months agoMerge pull request #547 from jinliangw/in_band_get_log_fix
Daniel Wagner [Fri, 2 Dec 2022 09:08:21 +0000 (10:08 +0100)]
Merge pull request #547 from jinliangw/in_band_get_log_fix

ioctl: fix log page offset

23 months agoioctl: fix log page offset
Jinliang Wang [Tue, 29 Nov 2022 23:15:28 +0000 (15:15 -0800)]
ioctl: fix log page offset

The original `lpo` info is lost in `nvme_get_log_page`.
Save it into a local variable and append `offset` after it.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
23 months agoMerge pull request #539 from jinliangw/master
Daniel Wagner [Fri, 2 Dec 2022 08:56:06 +0000 (09:56 +0100)]
Merge pull request #539 from jinliangw/master

mi: use correct log page offset

23 months agomi: use lpo and numd to chunk big get log page command
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>
23 months agoMerge pull request #548 from tbzatek/valgrind-fixes-2
Daniel Wagner [Wed, 30 Nov 2022 18:15:38 +0000 (19:15 +0100)]
Merge pull request #548 from tbzatek/valgrind-fixes-2

tree: Fix leaking struct nvme_ns.generic_name

23 months agotree: Fix leaking struct nvme_ns.generic_name
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)

23 months agoMerge pull request #545 from jinliangw/rename_tmp
Daniel Wagner [Mon, 28 Nov 2022 08:52:56 +0000 (09:52 +0100)]
Merge pull request #545 from jinliangw/rename_tmp

mi: rename tmp variable inside nvme_mi_admin_get_log

23 months agoMerge pull request #546 from tbzatek/valgrind-fixes-1
Daniel Wagner [Mon, 28 Nov 2022 08:52:16 +0000 (09:52 +0100)]
Merge pull request #546 from tbzatek/valgrind-fixes-1

fabrics: Fix uuid_from_dmi_entries() read buffer initialization

23 months agofabrics: Fix uuid_from_dmi_entries() read buffer initialization
Tomas Bzatek [Fri, 25 Nov 2022 15:37:32 +0000 (16:37 +0100)]
fabrics: Fix uuid_from_dmi_entries() read buffer initialization

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)

23 months agomi: rename tmp variable inside nvme_mi_admin_get_log
Jinliang Wang [Fri, 25 Nov 2022 07:44:19 +0000 (23:44 -0800)]
mi: rename tmp variable inside nvme_mi_admin_get_log

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>
23 months agoMerge pull request #542 from CodeConstruct/dev/mi-libdbus
Daniel Wagner [Wed, 23 Nov 2022 08:31:54 +0000 (09:31 +0100)]
Merge pull request #542 from CodeConstruct/dev/mi-libdbus

MI: switch from libsdbus to libdbus