Skip to content

Commit 317ea24

Browse files
committed
Fix: load: incomplete error handling for load_session_from_file
This fix is adapted from a fix against the stable-2.11 branch. The commit message of the stable-2.11 branch follows. An equivalent fix was already in place in `load_session_from_path()`, but the same problem as the stable-2.11 branch is present in `load_session_from_file()`. Original message: Observed issue ============== lttng-ivc test fails to fail. test_save_load_blocking_timeout[lttng-tools-2.12-lttng-tools-2.11-False] Here we load a xml created by lttng-tools-2.12 and try to load it using lttng-tools 2.11. We expect this to fail on the load. The command report an error on the stderr but the command return code value is zero. From lttng-ivc test runtime.log: Command #0 Return value: 0 Command: lttng load --input-path=/home/joraj/lttng/lttng-ivc/.tox/py3/tmp/test_save_load_blocking_timeou0/save_load saved_trace STDOUT: Session saved_trace has been loaded successfully STDERR: XML Error: Element 'process_attr_trackers': This element is not expected. Error: Session configuration file validation failed Cause ===== The error coming from load_session_from_file is not handled correctly. Solution ======== Rework error handling in load_session_from_path and load_session_from_file. LTTNG_ERR_LOAD_SESSION_NOENT is NOT an error when session_name is specified in load_session_from_path. In this scenario, we are actively looking for the configuration of the session. Signed-off-by: Jérémie Galarneau <[email protected]> Signed-off-by: Jonathan Rajotte <[email protected]> Change-Id: Ic68c253aa194bf8ab72c3c271f10d443118bdeee
1 parent 2666d35 commit 317ea24

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/common/config/session-config.c

+18-7
Original file line numberDiff line numberDiff line change
@@ -3767,20 +3767,31 @@ int load_session_from_file(const char *path, const char *session_name,
37673767
xmlNextElementSibling(session_node)) {
37683768
ret = process_session_node(session_node,
37693769
session_name, overwrite, overrides);
3770-
if (session_name && ret == 0) {
3771-
/* Target session found and loaded */
3772-
session_found = 1;
3773-
break;
3770+
if (!session_name && ret) {
3771+
/* Loading error occurred. */
3772+
goto end;
3773+
} else if (session_name) {
3774+
if (ret == 0) {
3775+
/* Target session found and loaded */
3776+
session_found = 1;
3777+
break;
3778+
} else if (ret == -LTTNG_ERR_NO_SESSION) {
3779+
/*
3780+
* Ignore this error, we are looking for a
3781+
* specific session.
3782+
*/
3783+
ret = 0;
3784+
} else {
3785+
/* Loading error occurred. */
3786+
goto end;
3787+
}
37743788
}
37753789
}
37763790
end:
37773791
xmlFreeDoc(doc);
37783792
if (!ret) {
37793793
ret = session_found ? 0 : -LTTNG_ERR_LOAD_SESSION_NOENT;
37803794
}
3781-
if (ret == -LTTNG_ERR_NO_SESSION) {
3782-
ret = -LTTNG_ERR_LOAD_SESSION_NOENT;
3783-
}
37843795
return ret;
37853796
}
37863797

0 commit comments

Comments
 (0)