]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
3 years agobuild: Add fallback dependency for json-c
Daniel Wagner [Tue, 19 Oct 2021 08:15:32 +0000 (10:15 +0200)]
build: Add fallback dependency for json-c

meson supports embedded library build. This is very handy for system
which ship outdated an really outdated json-c library.

The include path for json.h has to be adapted. The json-c upstream
project is not clear which include prefix should be used ('#include
<json-c/json.h>" vs '#include <json.h>'. In order to support embedded
builds, we need to use the second version of the include. The source
code is added to the build, hence we use the include directory path of
the project layout. And json-c has all include files in the root
directory. This is no problem when using a installed version of json-c
as pkg-config adds '-I/usr/inlude/json-c' to the include paths:

  $pkg-config --cflags json-c
  -I/usr/include/json-c

So the simplest thing to support both build cased (external/embedded)
just drop the include prefix.

While at it also fix the 'requires' argument which expects strings not
dependencies objects.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #68 from igaw/set-lib-version
Daniel Wagner [Tue, 19 Oct 2021 08:42:11 +0000 (10:42 +0200)]
Merge pull request #68 from igaw/set-lib-version

build: Split libtool versioning from project versioning

3 years agoMerge pull request #69 from birkelund/meson-fixes
Daniel Wagner [Tue, 19 Oct 2021 08:39:59 +0000 (10:39 +0200)]
Merge pull request #69 from birkelund/meson-fixes

meson fixes

Looks good to me. I'll update my PRs for my meson build fixes ontop of ours.

3 years agomeson: use library() and rely on user settings
Klaus Jensen [Mon, 18 Oct 2021 21:00:10 +0000 (23:00 +0200)]
meson: use library() and rely on user settings

There is no need to have both _static and _shared targets. Just use
library(). Project using libnvme as a subproject can now just set

  default_options: ['default_library=static']

in the subproject statement to choose the library version.

For pkgconfig, simplify and let the module figure out Libs and Requires.
This has the effect of removing Requires and making it a
Requires.private so we don't require libnvme consumers to link with
libuuid and json-c (unless they specifically needs to use it like
test/test.c).

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoupdate libnvme.map
Klaus Jensen [Mon, 18 Oct 2021 20:59:39 +0000 (22:59 +0200)]
update libnvme.map

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoMerge pull request #59 from martin-belanger/reowrk-python-exceptions
Hannes Reinecke [Mon, 18 Oct 2021 13:51:10 +0000 (15:51 +0200)]
Merge pull request #59 from martin-belanger/reowrk-python-exceptions

[Python]: Clean up exception handling

3 years agoMerge pull request #58 from martin-belanger/add-more-to-python
Hannes Reinecke [Mon, 18 Oct 2021 13:49:49 +0000 (15:49 +0200)]
Merge pull request #58 from martin-belanger/add-more-to-python

[Python]: Add set_persistent() and C definitions

3 years agoMerge pull request #67 from igaw/libjson-c-min-version
Daniel Wagner [Mon, 18 Oct 2021 12:26:32 +0000 (14:26 +0200)]
Merge pull request #67 from igaw/libjson-c-min-version

build: Set minimum version for json-c

3 years agobuild: Split libtool versioning from project versioning
Daniel Wagner [Mon, 18 Oct 2021 11:58:53 +0000 (13:58 +0200)]
build: Split libtool versioning from project versioning

As described in GNU autotools manuals, libtool versioning is not the
same as the project versioning.

The project versioning string is defined in project_version. meson
uses this string for all operations such a creating the tarball. I
decided against using something fancy as 'git describe' for it,
because meson is not supporting this kind of dynamic project
versioning.

Instead we just need to increment the version after the release and
before the first commit. With this scheme we basically know by looking
at the version string if it is an official released version. If this
is not good enough we can try to adopt the approach other project are
doing such as systemd which introduced an additional package
versioning which depends on 'git describe'.

There is little point in fighting the tool if it can be done quite
easily by the described approach from above.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #66 from jk-ozlabs/fixes
Daniel Wagner [Mon, 18 Oct 2021 09:39:03 +0000 (11:39 +0200)]
Merge pull request #66 from jk-ozlabs/fixes

log: we use bool, so include stdbool.h

3 years agobuild: Set minimum version for json-c
Daniel Wagner [Mon, 18 Oct 2021 09:24:34 +0000 (11:24 +0200)]
build: Set minimum version for json-c

Set minimum version for json-c to 0.13.

libnvme uses json_util_get_last_err() which got introduced in 0.13,
released in December 2017.

While at it, drop the cc.find_library() lookup logic. First, we don't
do this for libuuid and second, dependency() is using pkg-config to
figure out the dependency, thus we can set the minimum version
number. Instead, cc.find_library() will try to link a test program
with '-libjson-c' and have no way to figure out which version it
actually is. Avoid any confusion and make the meson.build script
simpler.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agolog: we use bool, so include stdbool.h
Jeremy Kerr [Fri, 6 Aug 2021 03:40:47 +0000 (11:40 +0800)]
log: we use bool, so include stdbool.h

The log headers use the bool type, so add an include for stdbool.h,
rather than requiring the includer to do so.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #64 from igaw/meson-subproject
Daniel Wagner [Tue, 12 Oct 2021 15:27:16 +0000 (17:27 +0200)]
Merge pull request #64 from igaw/meson-subproject

build: Allow subproject meson builds

3 years agobuild: Allow subproject meson builds
Daniel Wagner [Tue, 12 Oct 2021 15:18:48 +0000 (17:18 +0200)]
build: Allow subproject meson builds

meson has a very fancy feature called subproject. This allows bundle
third party libraries in a project. In order to be able to use this
for nvme-cli we need to drop all global config settings and declare
all dependencies.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoExpose C enums and #defines in Python module.
Martin Belanger [Mon, 11 Oct 2021 19:50:23 +0000 (15:50 -0400)]
Expose C enums and #defines in Python module.
Add persistent_set() method to the Python nvme_ctrl class.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMerge pull request #63 from igaw/remove-systemd-dep
Hannes Reinecke [Tue, 12 Oct 2021 12:48:13 +0000 (14:48 +0200)]
Merge pull request #63 from igaw/remove-systemd-dep

fabrics: Remove 'UUID derived from machine-id' feature

3 years agofabrics: Remove 'UUID derived from machine-id' feature
Daniel Wagner [Tue, 12 Oct 2021 12:26:57 +0000 (14:26 +0200)]
fabrics: Remove 'UUID derived from machine-id' feature

Commit 3e0520ecad13 ("Read system UUID from DMI and merge hostnqn
generation functions") in nvme-cli introduced the feature to create
the UUID derived from machine-id using the systemd's
sd_id128_get_machine_app_specific function. This adds many library
dependencies to libnvme.

The feature is not really necessary as we have nvme-gen-hostnqn
already in place. So drop the feature entirely.

If the feature needs to be added back, it's probably better to
reimplement this function (e.g. move the hmac_sha256 function from
nvme-cli and use this to derive the UUID from machine-id).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #56 from igaw/meson-ci
Daniel Wagner [Tue, 12 Oct 2021 09:35:30 +0000 (11:35 +0200)]
Merge pull request #56 from igaw/meson-ci

build: Add meson CI workflow

3 years agoMerge pull request #61 from jk-ozlabs/cross
Daniel Wagner [Tue, 12 Oct 2021 09:34:34 +0000 (11:34 +0200)]
Merge pull request #61 from jk-ozlabs/cross

Support for cross-compiling libnvme

3 years agoMerge pull request #55 from igaw/fix-uuid-read-overflow
Hannes Reinecke [Tue, 12 Oct 2021 09:33:09 +0000 (11:33 +0200)]
Merge pull request #55 from igaw/fix-uuid-read-overflow

fabrics: Do not overflow when reading systemd_uuid

3 years agopynvme: Make swig optional & python bindings conditional on swig
Jeremy Kerr [Tue, 12 Oct 2021 07:24:38 +0000 (15:24 +0800)]
pynvme: Make swig optional & python bindings conditional on swig

We may not need have a python environment for some targets; make the
python bindings optional.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoUnify configuration includes, use meson-generated configuration data
Jeremy Kerr [Tue, 12 Oct 2021 06:42:28 +0000 (14:42 +0800)]
Unify configuration includes, use meson-generated configuration data

Currently, we have two separate configuration includes: ccan/config.h
and config-host.h. The first is generated by the ccan configurator, the
second by the configuration step (either ./configure, or meson).

This change unifies these into a top-level config.h include.

For the meson case, we can use the meson configuration file to provide
all data. For the configure case, we still use the ccan configurator,
but include the resulting file from the top-level config.h

This allows us to cross-compile with meson.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomeson.build: Add ccan-required configuration macros
Jeremy Kerr [Tue, 12 Oct 2021 04:10:54 +0000 (12:10 +0800)]
meson.build: Add ccan-required configuration macros

This implements meson-native tests for the conditionals required by
ccan.

Queried via:

  git grep -oh 'HAVE_\w\+' ccan/ccan/ | sort -u

These are all build-time-only tests, so will work fine while
cross-compiling.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoconfigure: simplify config-host.h & config-host.mak generation
Jeremy Kerr [Tue, 12 Oct 2021 06:52:03 +0000 (14:52 +0800)]
configure: simplify config-host.h & config-host.mak generation

Create the configuration files using a here-string, rather than separate
commands.

While we're at it, fix the configure-command-line formatting in the .h
header.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoClean up Python exception handling
Martin Belanger [Mon, 11 Oct 2021 20:09:49 +0000 (16:09 -0400)]
Clean up Python exception handling

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agofabrics: Do not overflow when reading systemd_uuid
Daniel Wagner [Mon, 11 Oct 2021 09:57:09 +0000 (11:57 +0200)]
fabrics: Do not overflow when reading systemd_uuid

gcc complains with:

../src/nvme/fabrics.c:774:15: warning: ‘read’ writing 512 bytes into a region of size 37 overflows the destination [-Wstringop-overflow=]
  774 |         len = read(f, system_uuid, 512);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~
../src/nvme/fabrics.c: In function ‘nvmf_hostnqn_generate’:
../src/nvme/fabrics.c:863:14: note: destination object ‘uuid_str’ of size 37
  863 |         char uuid_str[37]; /* e.g. 1b4e28ba-2fa1-11d2-883f-0016d3cca427 + \0 */
      |              ^~~~~~~~

Let's limit the read to 37 as we know that's the max size for a UUID.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agobuild: Add meson CI workflow
Daniel Wagner [Mon, 11 Oct 2021 10:10:15 +0000 (12:10 +0200)]
build: Add meson CI workflow

Based on https://github.com/marketplace/actions/meson-build

resolves: #54

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #53 from hreinecke/meson-fix
Hannes Reinecke [Sat, 9 Oct 2021 11:21:17 +0000 (13:21 +0200)]
Merge pull request #53 from hreinecke/meson-fix

Fix version number for meson build

3 years agoFix version number for meson build
Hannes Reinecke [Fri, 8 Oct 2021 16:05:21 +0000 (18:05 +0200)]
Fix version number for meson build

The shared library has the version number '1.0.1', not '0.1'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #50 from hreinecke/csi
Daniel Wagner [Fri, 8 Oct 2021 15:47:30 +0000 (17:47 +0200)]
Merge pull request #50 from hreinecke/csi

Add nvme_identify_active_ns_list_csi() and nvme_identify_allocated_ns…

3 years agoMerge pull request #48 from hreinecke/dump-config
Daniel Wagner [Fri, 8 Oct 2021 15:45:01 +0000 (17:45 +0200)]
Merge pull request #48 from hreinecke/dump-config

Add 'nvme_dump_config()' function

3 years agoMerge pull request #47 from hreinecke/cleanup-sym
Daniel Wagner [Fri, 8 Oct 2021 15:43:06 +0000 (17:43 +0200)]
Merge pull request #47 from hreinecke/cleanup-sym

Cleanup exported symbols

3 years agoMerge pull request #52 from igaw/build-meson
Daniel Wagner [Fri, 8 Oct 2021 15:29:45 +0000 (17:29 +0200)]
Merge pull request #52 from igaw/build-meson

build: Add support for meson build system

3 years agobuild: Add support for meson build system
Martin Belanger [Thu, 7 Oct 2021 00:39:55 +0000 (20:39 -0400)]
build: Add support for meson build system

[dwagner: updated README.md]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoAdd nvme_identify_active_ns_list_csi() and nvme_identify_allocated_ns_list_csi()
Hannes Reinecke [Thu, 7 Oct 2021 09:51:36 +0000 (11:51 +0200)]
Add nvme_identify_active_ns_list_csi() and nvme_identify_allocated_ns_list_csi()

Update the command IDs with the values from NVMe base spec v2.0 and
implement the missing nvme_identify_active_ns_list_csi() and
nvme_identify_allocated_ns_list_csi().

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #49 from linux-nvme/hreinecke-workflow
Hannes Reinecke [Fri, 8 Oct 2021 13:01:46 +0000 (15:01 +0200)]
Merge pull request #49 from linux-nvme/hreinecke-workflow

Create github CI workflow

3 years agoCreate make.yml
Hannes Reinecke [Fri, 8 Oct 2021 11:36:42 +0000 (13:36 +0200)]
Create make.yml

3 years agotree: add nvme_dump_config()
Hannes Reinecke [Thu, 30 Sep 2021 09:45:43 +0000 (11:45 +0200)]
tree: add nvme_dump_config()

Add nvme_dump_config() to print out the current tree to stdout.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agojson: allow 'NULL' argument to json_update_config()
Hannes Reinecke [Thu, 30 Sep 2021 09:42:37 +0000 (11:42 +0200)]
json: allow 'NULL' argument to json_update_config()

Allow a 'NULL' argument to json_update_config() to indicate that
the contents should be written to stdout.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: make nvme_init_ctrl() an internal symbol
Hannes Reinecke [Thu, 30 Sep 2021 09:16:39 +0000 (11:16 +0200)]
tree: make nvme_init_ctrl() an internal symbol

nvme_init_ctrl() should not be exported, so move it to private.h
to indicate it's an internal symbol.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agofabrics: make uuid_from_device_tree and uuid_from_dmi static
Hannes Reinecke [Thu, 30 Sep 2021 08:24:09 +0000 (10:24 +0200)]
fabrics: make uuid_from_device_tree and uuid_from_dmi static

The functions are internal to fabrics.c, so mark them as 'static'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: remove nvme_ctrl_get_host{nqn,id}
Hannes Reinecke [Thu, 30 Sep 2021 08:48:28 +0000 (10:48 +0200)]
tree: remove nvme_ctrl_get_host{nqn,id}

No point in trying to fetch the host details from the controller;
if required the caller can walk up the chain directly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #45 from igaw/update-mapfile
Hannes Reinecke [Fri, 8 Oct 2021 11:05:20 +0000 (13:05 +0200)]
Merge pull request #45 from igaw/update-mapfile

libnvme.map: Add nvme_get_attr

3 years agoMerge pull request #46 from martin-belanger/fix-compiler-warning
Hannes Reinecke [Fri, 8 Oct 2021 11:03:59 +0000 (13:03 +0200)]
Merge pull request #46 from martin-belanger/fix-compiler-warning

Fix compiler warning.

3 years agoFix compiler warning.
Martin Belanger [Thu, 7 Oct 2021 16:36:11 +0000 (12:36 -0400)]
Fix compiler warning.

Signed-off-by: Martin Belanger martin_belanger@dell.com
3 years agolibnvme.map: Add nvme_get_attr
Daniel Wagner [Thu, 7 Oct 2021 15:42:50 +0000 (17:42 +0200)]
libnvme.map: Add nvme_get_attr

nvme_get_attr is missing in the export.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #42 from martin-belanger/scoped-ipv6
Hannes Reinecke [Thu, 7 Oct 2021 15:13:47 +0000 (17:13 +0200)]
Merge pull request #42 from martin-belanger/scoped-ipv6

Add support for scoped IPv6 in TRADDR

3 years agoAdd support for scoped IPv6
Martin Belanger [Wed, 6 Oct 2021 18:39:56 +0000 (14:39 -0400)]
Add support for scoped IPv6

3 years agoMerge pull request #33 from hreinecke/scanning
Hannes Reinecke [Wed, 6 Oct 2021 14:36:43 +0000 (16:36 +0200)]
Merge pull request #33 from hreinecke/scanning

Scanning fixes

3 years agoMerge pull request #39 from verschwindibussen/fix-shared-build
Hannes Reinecke [Wed, 6 Oct 2021 14:35:33 +0000 (16:35 +0200)]
Merge pull request #39 from verschwindibussen/fix-shared-build

Fix shared build

3 years agoMerge pull request #41 from birkelund/add-cap-css-csi
Keith Busch [Wed, 6 Oct 2021 11:18:25 +0000 (13:18 +0200)]
Merge pull request #41 from birkelund/add-cap-css-csi

types: add NVME_CAP_CSS_CSI

3 years agoMerge pull request #40 from metaspace/fix_csi_create
Keith Busch [Wed, 6 Oct 2021 11:07:23 +0000 (05:07 -0600)]
Merge pull request #40 from metaspace/fix_csi_create

Fix a bug where CSI was not passed to to nvme_ns_mgmt

3 years agotypes: add NVME_CAP_CSS_CSI
Klaus Jensen [Wed, 29 Sep 2021 12:23:02 +0000 (14:23 +0200)]
types: add NVME_CAP_CSS_CSI

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoFix a bug where CSI was not passed to to nvme_ns_mgmt
Andreas Hindborg [Fri, 17 Sep 2021 14:21:28 +0000 (16:21 +0200)]
Fix a bug where CSI was not passed to to nvme_ns_mgmt

Signed-off-by: Andreas Hindborg <andreas.hindborg@wdc.com>
3 years agofabrics: restore hostname traddr support
Sagi Grimberg [Sun, 26 Sep 2021 18:29:32 +0000 (21:29 +0300)]
fabrics: restore hostname traddr support

We used to support hostname passed in traddr, with the move of nvme-cli
to use libnvme we lost this capability, now lets restore it.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
3 years agoMakefile: Install log.h header file
Daniel Wagner [Mon, 27 Sep 2021 13:36:58 +0000 (15:36 +0200)]
Makefile: Install log.h header file

Add the missing nvme/log.h header file.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agolibnvme.map: Add missing exports for nvme-cli
Daniel Wagner [Mon, 27 Sep 2021 13:29:56 +0000 (15:29 +0200)]
libnvme.map: Add missing exports for nvme-cli

When building nvme-cli with a shared library a few symbols where
missing in the export list. Let's export the missing symbols.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agolibnvme.map: Sort global export section
Daniel Wagner [Mon, 27 Sep 2021 13:27:38 +0000 (15:27 +0200)]
libnvme.map: Sort global export section

Sort the global section so that we when new entries are inserted they
are in the correct position.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #38 from metaspace/nvme-iocs-wrong-cns
Keith Busch [Wed, 22 Sep 2021 21:12:56 +0000 (15:12 -0600)]
Merge pull request #38 from metaspace/nvme-iocs-wrong-cns

Fix bug in `nvme_identify_iocs`

3 years agoFix bug in `nvme_identify_iocs`
Andreas Hindborg [Wed, 22 Sep 2021 11:08:22 +0000 (13:08 +0200)]
Fix bug in `nvme_identify_iocs`

This patch fixes a bug in `nvme_identify_iocs` where the wrong CNS value used in
the Identify Command data structure.

Signed-off-by: Andreas Hindborg <andreas.hindborg@wdc.com>
3 years agoMerge pull request #37 from verschwindibussen/install-pynvme
Keith Busch [Tue, 21 Sep 2021 18:54:04 +0000 (12:54 -0600)]
Merge pull request #37 from verschwindibussen/install-pynvme

pynvme: Add install target to Makefile

3 years agopynvme: Add install target to Makefile
Daniel Wagner [Tue, 21 Sep 2021 11:55:16 +0000 (13:55 +0200)]
pynvme: Add install target to Makefile

Use setup.py to install the binding to the sitearch.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #36 from verschwindibussen/refactor-uuid_from_device_tree
Keith Busch [Tue, 21 Sep 2021 14:41:22 +0000 (08:41 -0600)]
Merge pull request #36 from verschwindibussen/refactor-uuid_from_device_tree

fabrics: Refactor uuid_from_device_tree

3 years agofabrics: Refactor uuid_from_device_tree
Daniel Wagner [Tue, 21 Sep 2021 07:03:06 +0000 (09:03 +0200)]
fabrics: Refactor uuid_from_device_tree

The recently added uuid_from_device_tree function can be refactored by
minimizing use of local variables and early returns in error
handling. No functional change.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #34 from wxiong38/hostnqn_uuid_ibm
Keith Busch [Wed, 15 Sep 2021 17:50:01 +0000 (11:50 -0600)]
Merge pull request #34 from wxiong38/hostnqn_uuid_ibm

nvme-cli: nvme gen-hostnqn use partition UUID on IBM POWER

3 years agonvme-cli: nvme gen-hostnqn use partition UUID on IBM
root [Wed, 15 Sep 2021 15:24:42 +0000 (11:24 -0400)]
nvme-cli: nvme gen-hostnqn use partition UUID on IBM

IBM POWER systems expose a platform created UUID in the device
tree. Use that as the UUID in the host NQN

Signed-Off-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Reviewed-by: Brian King <brking@linux.vnet.ibm.com>
3 years agotree: rework ctrl address generation
Hannes Reinecke [Mon, 13 Sep 2021 08:22:15 +0000 (10:22 +0200)]
tree: rework ctrl address generation

Older kernel do not display an 'address' sysfs attribute for pcie
controllers, so we need to infer it from the sysfs path itself.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: set default ANA state to 'optimized'
Hannes Reinecke [Mon, 13 Sep 2021 08:23:53 +0000 (10:23 +0200)]
tree: set default ANA state to 'optimized'

Older kernels do not provide an ANA state attribute, so always display
'optimized' here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: free 'subsysnqn'
Hannes Reinecke [Mon, 13 Sep 2021 08:24:50 +0000 (10:24 +0200)]
tree: free 'subsysnqn'

Valgrind complained.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: better logging output
Hannes Reinecke [Mon, 13 Sep 2021 08:18:07 +0000 (10:18 +0200)]
tree: better logging output

Add logging messages when scan fails, and remove the logging from
failure to read the individual attributes.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: fixup crash on pcie controller for older kernels
Hannes Reinecke [Fri, 10 Sep 2021 16:06:03 +0000 (18:06 +0200)]
tree: fixup crash on pcie controller for older kernels

Older kernels do not provide an 'address' sysfs entry for 'pcie'
controllers, causing a crash during scanning.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoexamples,test: depend on libnvme.a
Hannes Reinecke [Fri, 10 Sep 2021 12:50:12 +0000 (14:50 +0200)]
examples,test: depend on libnvme.a

When libnvme is changed we should be rebuilding the example and test
programs, too, to build them against the updated libnvme.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agofix path->nentry bugs
chengjike [Thu, 9 Sep 2021 14:57:09 +0000 (22:57 +0800)]
fix path->nentry bugs

The "path->nentry" is initialized after it is added to the list in
"nvme_subsystem_set_path_ns" function.

Signed-off-by: chengjike <chengjike.cheng@huawei.com>
3 years agoRevert "tree: rework topology for multiple hosts"
Keith Busch [Thu, 2 Sep 2021 16:53:29 +0000 (09:53 -0700)]
Revert "tree: rework topology for multiple hosts"

The hosts check breaks pci

This reverts commit aad3881a446560e6add56202e8029183d5dd825d.

Link: https://github.com/linux-nvme/libnvme/issues/32
Signed-off-by: Keith Busch <kbusch@kernel.org>
3 years agoMerge pull request #31 from martin-belanger/fix-compilation-warning
Keith Busch [Mon, 23 Aug 2021 18:34:41 +0000 (12:34 -0600)]
Merge pull request #31 from martin-belanger/fix-compilation-warning

Allow control objects to be deleted.

3 years agoUn-stub nvme_free_ctrl(). In other words, nvme_free_ctrl() will now properly delete...
Martin Belanger [Mon, 23 Aug 2021 17:52:38 +0000 (13:52 -0400)]
Un-stub nvme_free_ctrl(). In other words, nvme_free_ctrl() will now properly delete ctrl objects

3 years agoMerge pull request #30 from martin-belanger/fix-compilation-warning
Keith Busch [Thu, 19 Aug 2021 21:00:36 +0000 (15:00 -0600)]
Merge pull request #30 from martin-belanger/fix-compilation-warning

Fix memory leaks and double free

3 years agoFix memory leaks and double free
Martin Belanger [Thu, 19 Aug 2021 19:51:34 +0000 (15:51 -0400)]
Fix memory leaks and double free

4 years agoMerge pull request #28 from hreinecke/topology
Keith Busch [Fri, 13 Aug 2021 16:07:04 +0000 (10:07 -0600)]
Merge pull request #28 from hreinecke/topology

tree: rework topology for multiple hosts

4 years agoMerge pull request #29 from martin-belanger/fix-compilation-warning
Keith Busch [Fri, 13 Aug 2021 16:06:21 +0000 (10:06 -0600)]
Merge pull request #29 from martin-belanger/fix-compilation-warning

Fix compiler warning

4 years agoFix compiler warning
Martin Belanger [Fri, 13 Aug 2021 13:08:26 +0000 (09:08 -0400)]
Fix compiler warning

4 years agoprivate.h: drop 'hostid' and 'hostnqn' from nvme_ctrl_t
Hannes Reinecke [Fri, 13 Aug 2021 10:33:17 +0000 (12:33 +0200)]
private.h: drop 'hostid' and 'hostnqn' from nvme_ctrl_t

Never referenced anywhere.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agosrc/Makefile: fixup depencendy for private.h
Hannes Reinecke [Fri, 13 Aug 2021 10:28:27 +0000 (12:28 +0200)]
src/Makefile: fixup depencendy for private.h

The Makefile references 'private.h' as 'libnvme_priv', not
'libnvme_private'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: rework topology for multiple hosts
Hannes Reinecke [Fri, 13 Aug 2021 09:58:08 +0000 (11:58 +0200)]
tree: rework topology for multiple hosts

Our tree structure host->subsys->ctrl doesn't match the underlying
topology; the subsystem actually just a container for controllers,
and the hosts are specified on the controller level, not the subsystem
level.
So to flatten that into our tree structure we need to duplicate the
subsystem objects for each host, and filter out the controllers such
that only the controllers with the correct hostnqn will show up
in our internal tree.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #27 from martin-belanger/fix-empty-model
Keith Busch [Thu, 12 Aug 2021 19:58:57 +0000 (13:58 -0600)]
Merge pull request #27 from martin-belanger/fix-empty-model

Default empty model attribute to 'undefined'

4 years agoDefault empty model attribute to 'undefined'
Martin Belanger [Thu, 12 Aug 2021 19:52:30 +0000 (15:52 -0400)]
Default empty model attribute to 'undefined'

4 years agoMerge pull request #26 from hreinecke/discovery-fixes
Keith Busch [Thu, 12 Aug 2021 15:46:12 +0000 (09:46 -0600)]
Merge pull request #26 from hreinecke/discovery-fixes

Discovery fixes

4 years agotree.h: remove stale declaration of nvme_ctrl_get_nqn()
Hannes Reinecke [Thu, 12 Aug 2021 06:26:41 +0000 (08:26 +0200)]
tree.h: remove stale declaration of nvme_ctrl_get_nqn()

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agojson: use nvme_msg() instead of fprintf()
Hannes Reinecke [Wed, 11 Aug 2021 08:59:42 +0000 (10:59 +0200)]
json: use nvme_msg() instead of fprintf()

Use nvme logging to make error output configurable.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: set errno in nvme_create_ctrl()
Hannes Reinecke [Thu, 12 Aug 2021 06:25:45 +0000 (08:25 +0200)]
tree: set errno in nvme_create_ctrl()

There is no reason why we shouldn't be setting errno in
nvme_create_ctrl(); in fact, doing so will help with debugging.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agofabrics: add nvme_host_t as argument to build_options()
Hannes Reinecke [Thu, 12 Aug 2021 09:29:25 +0000 (11:29 +0200)]
fabrics: add nvme_host_t as argument to build_options()

build_options() can be called when the controller hasn't been
instantiated; in that case the 'subsystem' link in the controller
is empty, and there is no host associated with it.
Rather than selecting the default nvme host (and thereby losing
any different hostnqn settings which might have passed in from
the commandline) we should be passing in the nvme host directly
as argument to build_options().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: avoid crash on unset subsystem in nvme_ctrl_get_host{nqn,id}
Hannes Reinecke [Thu, 12 Aug 2021 09:28:31 +0000 (11:28 +0200)]
tree: avoid crash on unset subsystem in nvme_ctrl_get_host{nqn,id}

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #15 from jk-ozlabs/fixes
Keith Busch [Fri, 6 Aug 2021 19:34:08 +0000 (13:34 -0600)]
Merge pull request #15 from jk-ozlabs/fixes

Minor fixes for a couple of compilation failures

4 years agoioctl: Fix incorrect cdw initialisation in nvme_set_features
Jeremy Kerr [Mon, 2 Aug 2021 05:50:16 +0000 (13:50 +0800)]
ioctl: Fix incorrect cdw initialisation in nvme_set_features

We're not currently setting cdw15 in nvme_set_features due to a typo in
the struct initialisation. This change fixes the init.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
4 years agoBuild c++ objects with c++ compiler
Jeremy Kerr [Thu, 8 Jul 2021 04:46:43 +0000 (12:46 +0800)]
Build c++ objects with c++ compiler

We should use $(CXX) when building objects from .cc sources

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
4 years agoSeparate libs from link flags to fix link-order compile failure
Jeremy Kerr [Thu, 1 Jul 2021 06:26:57 +0000 (14:26 +0800)]
Separate libs from link flags to fix link-order compile failure

Currently, builds fail for me with a link error:

  /usr/bin/ld: ../src//libnvme.a(tree.ol): in function `nvme_ns_get_uuid':
  src/nvme/tree.c:1321: undefined reference to `uuid_copy'
  /usr/bin/ld: ../src//libnvme.a(json.ol): in function `json_read_config':
  src/nvme/json.c:152: undefined reference to `json_object_from_file'

Turns out my linker ("GNU ld (GNU Binutils for Debian) 2.35.2") is
sensitive to object argument order - the dependent libs need to be listed
last.

This change splits the required libraries into a LIBS variable, used
last on the Makefile rules to perform the link.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
4 years agoMerge pull request #24 from tbzatek/docs-updates-2
Keith Busch [Tue, 3 Aug 2021 17:24:18 +0000 (11:24 -0600)]
Merge pull request #24 from tbzatek/docs-updates-2

types: Device self-test doc strings update

4 years agotypes: Device self-test doc strings update
Tomas Bzatek [Tue, 3 Aug 2021 16:29:53 +0000 (18:29 +0200)]
types: Device self-test doc strings update

Doc strings update related to the device self-test log page
retrieval and the self-test command issue.

API changes:
 * renamed NVME_ST_CODE_RESRVED -> NVME_ST_CODE_RESERVED
 * added enum nvme_st_curr_op definiton

4 years agoMerge pull request #21 from martin-belanger/move-python-to-separate-dir
Keith Busch [Fri, 30 Jul 2021 14:52:57 +0000 (08:52 -0600)]
Merge pull request #21 from martin-belanger/move-python-to-separate-dir

Move python bindings to a separate directory (pynvme)

4 years agoMerge latest changes from master branch
Martin Belanger [Fri, 23 Jul 2021 19:39:29 +0000 (15:39 -0400)]
Merge latest changes from master branch