]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
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 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

4 years agoBug fix in Python SWIG module
Martin Belanger [Fri, 23 Jul 2021 19:35:17 +0000 (15:35 -0400)]
Bug fix in Python SWIG module

4 years agoMerge pull request #20 from tbzatek/json-c-build-fixes
Keith Busch [Fri, 23 Jul 2021 15:47:31 +0000 (09:47 -0600)]
Merge pull request #20 from tbzatek/json-c-build-fixes

build: Fix build without json-c

4 years agoMerge pull request #19 from tbzatek/status-to-string
Keith Busch [Fri, 23 Jul 2021 15:19:01 +0000 (09:19 -0600)]
Merge pull request #19 from tbzatek/status-to-string

Add new status codes, add nvme_status_to_string()

4 years agobuild: Fix build without json-c
Tomas Bzatek [Fri, 23 Jul 2021 14:16:47 +0000 (16:16 +0200)]
build: Fix build without json-c

4 years agoutil: Add strings for new status codes
Tomas Bzatek [Fri, 23 Jul 2021 14:03:02 +0000 (16:03 +0200)]
util: Add strings for new status codes

4 years agotypes: Add new status codes
Tomas Bzatek [Fri, 23 Jul 2021 14:01:15 +0000 (16:01 +0200)]
types: Add new status codes

Sync with nvme-cli master, doc strings updates.

4 years agoutil: Add nvme_status_to_string()
Tomas Bzatek [Thu, 22 Jul 2021 14:42:51 +0000 (16:42 +0200)]
util: Add nvme_status_to_string()

Taken from nvme-cli/libnvme-int-3.4.2021 branch,
commit 70b9835a9dace56557acc5ed10fd4c77ac063238.

4 years agoadd README file for python bindings
Martin Belanger [Fri, 16 Jul 2021 13:08:31 +0000 (09:08 -0400)]
add README file for python bindings

4 years agoMove 'Python bindings' SWIG and Makefile to 'pynvme' directory
Martin Belanger [Wed, 14 Jul 2021 17:49:59 +0000 (13:49 -0400)]
Move 'Python bindings' SWIG and Makefile to 'pynvme' directory

4 years agorename Python class names using SWIG's %rename
Martin Belanger [Wed, 14 Jul 2021 15:10:47 +0000 (11:10 -0400)]
rename Python class names using SWIG's %rename

4 years agofix memory leak
Martin Belanger [Wed, 14 Jul 2021 14:51:52 +0000 (10:51 -0400)]
fix memory leak

4 years agoMerge branch 'logging.v2' of https://github.com/hreinecke/libnvme
Martin Belanger [Wed, 14 Jul 2021 14:05:04 +0000 (10:05 -0400)]
Merge branch 'logging.v2' of https://github.com/hreinecke/libnvme

4 years agore-arm discovery AEN
Keith Busch [Fri, 9 Jul 2021 15:19:17 +0000 (08:19 -0700)]
re-arm discovery AEN

Ensure that the discovery AEN is unmasked by clearing RAE on the last
read of the full discovery log page.

Link: https://github.com/linux-nvme/libnvme/issues/17
Signed-off-by: Keith Busch <kbusch@kernel.org>
4 years agofabrics: Remove trailing newline from debugging messages
Martin Belanger [Sat, 26 Jun 2021 12:02:25 +0000 (14:02 +0200)]
fabrics: Remove trailing newline from debugging messages

The debugging messages in __nvmf_add_ctrl() contained newlines,
making for an improper formatted message.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
4 years agoMakefile: fix libnvme_wrap targets
Martin Belanger [Sat, 26 Jun 2021 11:58:41 +0000 (13:58 +0200)]
Makefile: fix libnvme_wrap targets

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
4 years agotree: do not free 'path' in nvme_init_ctrl()
Hannes Reinecke [Sat, 26 Jun 2021 11:46:22 +0000 (13:46 +0200)]
tree: do not free 'path' in nvme_init_ctrl()

After nvme_configure_ctrl() completes successfully we must not
free the 'path' argument as control has been transferred to the
controller structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: implement nvme_deconfigure_ctrl()
Hannes Reinecke [Sat, 26 Jun 2021 11:09:14 +0000 (13:09 +0200)]
tree: implement nvme_deconfigure_ctrl()

Separate out nvme_deconfigure_ctrl() from nvme_disconnect_ctrl()
to make it symmetric with nvme_configure_ctrl().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: rename __nvme_init_ctrl() to nvme_configure_ctrl()
Hannes Reinecke [Sat, 26 Jun 2021 11:08:29 +0000 (13:08 +0200)]
tree: rename __nvme_init_ctrl() to nvme_configure_ctrl()

To clarify the intent on the function, and reduce confusion between
nvme_ctrl_init() and __nvme_init_ctrl().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: use 'stat' to lookup nvme controller
Hannes Reinecke [Sat, 26 Jun 2021 11:05:10 +0000 (13:05 +0200)]
tree: use 'stat' to lookup nvme controller

When looking up nvme subsystems for individual controllers we should
be using 'stat()' instead of 'opendir()'; this is less heavy-handed
and provides better error checking.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add error logging when failing to lookup subsystem name
Hannes Reinecke [Thu, 24 Jun 2021 14:28:52 +0000 (16:28 +0200)]
tree: add error logging when failing to lookup subsystem name

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolibnvme.i: add a 'log_level' function to nvme_root object
Hannes Reinecke [Thu, 24 Jun 2021 07:20:25 +0000 (09:20 +0200)]
libnvme.i: add a 'log_level' function to nvme_root object

Add a 'log_level' function to the nvme_root object to allow to
increase the logging level of the libnvme library.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolibnvme.i: display last error message on connect()
Hannes Reinecke [Thu, 24 Jun 2021 06:28:09 +0000 (08:28 +0200)]
libnvme.i: display last error message on connect()

Instead of displaying just a generic 'connect failed' message
we should be using nvme_log_message to display the most recent
failure message to the user.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolog: export last error message
Hannes Reinecke [Thu, 24 Jun 2021 06:26:46 +0000 (08:26 +0200)]
log: export last error message

Add a static string 'nvme_log_message' containing the last error
message written out by 'nvme_msg'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #14 from hreinecke/realloc
Keith Busch [Wed, 23 Jun 2021 14:16:48 +0000 (08:16 -0600)]
Merge pull request #14 from hreinecke/realloc

Rework tree reallocation

4 years agotree: rework topology deallocation
Hannes Reinecke [Wed, 23 Jun 2021 09:51:10 +0000 (11:51 +0200)]
tree: rework topology deallocation

The original idea of implementing a simple refcount doesn't really
work out, as refcounting is everything but.
And especially when used with the SWIG bindings it's not easy to
figure if and when a refcount needs to be released.
So kill the entire refcounting and free the internal structure
only when calling nvme_free_tree(); the object-dependent functions
like nvme_free_subsystem() etc now merely become stubs for
symmetry and to keep SWIG happy.
That removes the need for refcounting at all as the tree
and its contents will always be available, and a call to
nvme_free_tree() will clear the entire structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: initialize all lists
Hannes Reinecke [Wed, 23 Jun 2021 07:43:07 +0000 (09:43 +0200)]
tree: initialize all lists

As otherwise python will crash horribly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolibnvme.i: decode discover log page entry fields
Hannes Reinecke [Wed, 23 Jun 2021 06:59:56 +0000 (08:59 +0200)]
libnvme.i: decode discover log page entry fields

Decode the individual fields from the discover log page entry to
make the output usable for creating controllers.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #13 from hreinecke/swig.v3
Keith Busch [Tue, 22 Jun 2021 17:16:28 +0000 (11:16 -0600)]
Merge pull request #13 from hreinecke/swig.v3

SWIG Python bindings

4 years agotree: check hostnqn and hostid when scanning topology
Hannes Reinecke [Mon, 21 Jun 2021 15:09:27 +0000 (17:09 +0200)]
tree: check hostnqn and hostid when scanning topology

Newer kernel versions will display the hostnqn and hostid in sysfs
attributes, so we should be using them to find the host structure
instead of the default host.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotest/tree.py: add test script for the python binding
Hannes Reinecke [Thu, 17 Jun 2021 11:08:20 +0000 (13:08 +0200)]
test/tree.py: add test script for the python binding

Add a simple test script for the python binding which just
prints out details about the NVMe subsystem.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoexamples/discover-loop.py: python example for nvme discovery
Hannes Reinecke [Tue, 11 May 2021 15:27:58 +0000 (17:27 +0200)]
examples/discover-loop.py: python example for nvme discovery

Add an example script on how nvme discovery can be done with
the libnvme python binding.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoAdd SWIG interface generator files
Hannes Reinecke [Thu, 6 May 2021 06:19:32 +0000 (08:19 +0200)]
Add SWIG interface generator files

Add files to generate a python binding via SWIG.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: re-read 'state' attribute
Hannes Reinecke [Tue, 11 May 2021 15:59:20 +0000 (17:59 +0200)]
tree: re-read 'state' attribute

The 'state' attribute might change at any time, so we need to update
it upon access.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: rename nvme_disconnect_ctrl()
Hannes Reinecke [Fri, 7 May 2021 15:13:22 +0000 (17:13 +0200)]
tree: rename nvme_disconnect_ctrl()

Rename nvme_ctrl_disconnect() to nvme_disconnect_ctrl() to avoid
name clash with SWIG generated interface files.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: export nvme_free_subsystem()
Hannes Reinecke [Thu, 17 Jun 2021 07:50:32 +0000 (09:50 +0200)]
tree: export nvme_free_subsystem()

Required for SWIG interface.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: export nvme_free_host()
Hannes Reinecke [Thu, 17 Jun 2021 07:50:32 +0000 (09:50 +0200)]
tree: export nvme_free_host()

Required for SWIG interface.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add nvme_rescan_ctrl()
Hannes Reinecke [Fri, 7 May 2021 14:54:19 +0000 (16:54 +0200)]
tree: add nvme_rescan_ctrl()

Add a function to rescan a controller eg after receiving an AEN.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add refcounting for objects
Hannes Reinecke [Tue, 11 May 2021 10:30:47 +0000 (12:30 +0200)]
tree: add refcounting for objects

Each object can be referenced multiple times, so add
reference counting for hosts, subsystems, and controllers.

Signed-off-by: Hannes Reinecke <hare@suse.com>
4 years agotree: Move structures to private.h
Hannes Reinecke [Fri, 7 May 2021 13:49:59 +0000 (15:49 +0200)]
tree: Move structures to private.h

Move generic structures to private.h to avoid having to duplicate
definitions in the SWIG interface file.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: move static declarations into private header file
Hannes Reinecke [Wed, 5 May 2021 12:35:36 +0000 (14:35 +0200)]
tree: move static declarations into private header file

Static directory declarations are not part of the libnvme API, so
move them into the private header file.

Signed-off-by: Hannes Reinecke <hare@suse.de>