Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libnvme/nvme.i
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ PyObject *hostid_from_file();
%exception nvme_ctrl::discover {
discover_err = 0;
$action /* $action sets discover_err to non-zero value on failure */
if (discover_err) {
if (discover_err == 1) {
SWIG_exception(SWIG_AttributeError, "No controller connection");
} else if (discover_err) {
SWIG_exception(SWIG_RuntimeError, "Discover failed");
}
}
Expand Down Expand Up @@ -748,6 +750,7 @@ struct nvme_ns {

%newobject discover;
struct nvmf_discovery_log *discover(int lsp = 0, int max_retries = 6) {
const char *dev;
struct nvmf_discovery_log *logp;
struct nvme_get_discovery_args args = {
.c = $self,
Expand All @@ -758,11 +761,16 @@ struct nvme_ns {
.lsp = lsp,
};

dev = nvme_ctrl_get_name($self);
if (dev) {
discover_err = 1;
return NULL;
}
Py_BEGIN_ALLOW_THREADS /* Release Python GIL */
logp = nvmf_get_discovery_wargs(&args);
Py_END_ALLOW_THREADS /* Reacquire Python GIL */

if (logp == NULL) discover_err = 1;
if (logp == NULL) discover_err = 2;
return logp;
}

Expand Down