summaryrefslogtreecommitdiff
path: root/libopeniscsiusr
diff options
context:
space:
mode:
authorChris Leech <cleech@redhat.com>2021-02-17 13:48:25 -0800
committerChris Leech <cleech@redhat.com>2021-02-17 19:47:17 -0800
commitb21066fc07261e05590ccab839bf5eee2249d358 (patch)
treee694b19ea3ada478c2a4c87971ce82aab890583d /libopeniscsiusr
parenta744d91046865416a50ea27f143ef0f02fcaf1c6 (diff)
downloadopen-iscsi-b21066fc07261e05590ccab839bf5eee2249d358.tar.gz
libopeniscsiusr: dont error loudly if a session isn't found when working through iscsi_sessions_get()
Suppress the error message from iscsi_session_get when it's being called through iscsi_sessions_get now that it's not being treated as an error. There's no reason to be so alarmed the session being read in isn't specified exactly. Signed-off-by: Chris Leech <cleech@redhat.com>
Diffstat (limited to 'libopeniscsiusr')
-rw-r--r--libopeniscsiusr/session.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c
index 4a724c8..6b06241 100644
--- a/libopeniscsiusr/session.c
+++ b/libopeniscsiusr/session.c
@@ -101,8 +101,8 @@ _iscsi_getter_func_gen(iscsi_session, address, const char *);
_iscsi_getter_func_gen(iscsi_session, port, int32_t);
_iscsi_getter_func_gen(iscsi_session, iface, struct iscsi_iface *);
-int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
- struct iscsi_session **se)
+int _iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
+ struct iscsi_session **se, bool verbose)
{
int rc = LIBISCSI_OK;
char *sysfs_se_dir_path = NULL;
@@ -137,8 +137,14 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
rc = LIBISCSI_ERR_SESS_NOT_FOUND;
}
if (rc == LIBISCSI_ERR_SESS_NOT_FOUND) {
- _error(ctx, "Specified SID %" PRIu32 " does not exist",
- sid);
+ /* don't complain loudly if called through iscsi_sessions_get()
+ * the caller is not looking for a specific session,
+ * and the list could be changing as we work through it
+ */
+ if (verbose) {
+ _error(ctx, "Specified SID %" PRIu32 " does not exist",
+ sid);
+ }
goto out;
}
@@ -240,6 +246,11 @@ out:
return rc;
}
+int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
+ struct iscsi_session **se) {
+ return _iscsi_session_get(ctx, sid, se, true);
+}
+
int iscsi_sessions_get(struct iscsi_context *ctx,
struct iscsi_session ***sessions,
uint32_t *session_count)
@@ -265,7 +276,7 @@ int iscsi_sessions_get(struct iscsi_context *ctx,
for (i = 0; i < *session_count; ++i) {
_debug(ctx, "sid %" PRIu32, sids[i]);
- rc = iscsi_session_get(ctx, sids[i], &((*sessions)[j]));
+ rc = _iscsi_session_get(ctx, sids[i], &((*sessions)[j]), false);
if (rc == LIBISCSI_OK) {
/* if session info was successfully read from sysfs, advance the sessions pointer */
j++;