const char *lttng_load_session_attr_get_override_data_url(
struct lttng_load_session_attr *attr);
+/*
+ * Return the configuration override session name attribute.
+ * This attribute indicates a session name override to be applied during
+ * the loading of the configuration(s).
+ *
+ * NULL indicates no session name override will be applied on configuration
+ * load.
+ */
+const char *lttng_load_session_attr_get_override_session_name(
+ struct lttng_load_session_attr *attr);
+
/*
* Load session attribute setter family of functions.
*
int lttng_load_session_attr_set_override_data_url(
struct lttng_load_session_attr *attr, const char *url);
+/*
+ * Set the session name override attribute.
+ *
+ * Loading a configuration file defining multiple sessions will fail if a
+ * session name is provided.
+ */
+int lttng_load_session_attr_set_override_session_name(
+ struct lttng_load_session_attr *attr, const char *session_name);
+
/*
* Load session configuration(s).
*
free(attr->override_attr->path_url);
free(attr->override_attr->ctrl_url);
free(attr->override_attr->data_url);
+ free(attr->override_attr->session_name);
}
}
}
}
+static int validate_attr(const struct lttng_load_session_attr *attr)
+{
+ int ret = 0;
+
+ if (!attr) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ if (!attr->override_attr) {
+ goto end;
+ }
+
+ /*
+ * Refuse override name if the objective is to load multiple session
+ * since this operation is ambiguous while loading multiple session.
+ */
+ if (attr->override_attr->session_name
+ && attr->session_name[0] == '\0') {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+end:
+ return ret;
+}
+
const char *lttng_load_session_attr_get_session_name(
struct lttng_load_session_attr *attr)
{
return ret;
}
+const char *lttng_load_session_attr_get_override_session_name(
+ struct lttng_load_session_attr *attr)
+{
+ const char *ret = NULL;
+
+ if (!attr || !attr->override_attr) {
+ goto end;
+ }
+
+ ret = attr->override_attr->session_name;
+end:
+ return ret;
+}
+
int lttng_load_session_attr_set_session_name(
struct lttng_load_session_attr *attr, const char *session_name)
{
return ret;
}
+int lttng_load_session_attr_set_override_session_name(
+ struct lttng_load_session_attr *attr, const char *session_name)
+{
+ int ret = 0;
+ size_t len;
+
+ if (!attr ||!session_name) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ if (!attr->override_attr) {
+ attr->override_attr = zmalloc(
+ sizeof(struct config_load_session_override_attr));
+ if (!attr->override_attr) {
+ ret = -LTTNG_ERR_NOMEM;
+ goto end;
+ }
+ }
+
+ len = strlen(session_name);
+ if (len >= LTTNG_NAME_MAX) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ attr->override_attr->session_name = lttng_strndup(session_name,
+ len);
+ if (!attr->override_attr->session_name) {
+ ret = -LTTNG_ERR_NOMEM;
+ goto end;
+ }
+end:
+ return ret;
+}
+
int lttng_load_session(struct lttng_load_session_attr *attr)
{
int ret;
goto end;
}
+ ret = validate_attr(attr);
+ if (ret) {
+ goto end;
+ }
+
url = attr->input_url[0] != '\0' ? attr->input_url : NULL;
session_name = attr->session_name[0] != '\0' ?
attr->session_name : NULL;