[lttng-dev] [PATCH lttng-tools] Introduce monitor_timer_interval to session configuration schema

Jonathan Rajotte jonathan.rajotte-julien at efficios.com
Thu May 11 19:28:21 UTC 2017


Session configuration schema version is bumped to 2.10

Fixes #1099

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
---
 src/bin/lttng-sessiond/save.c      | 27 ++++++++++++++++++++
 src/common/config/session-config.c | 52 +++++++++++++++++++++++++++++++++-----
 src/common/config/session.xsd      |  3 ++-
 3 files changed, 74 insertions(+), 8 deletions(-)

diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c
index 1a879b21..3c34c856 100644
--- a/src/bin/lttng-sessiond/save.c
+++ b/src/bin/lttng-sessiond/save.c
@@ -104,6 +104,18 @@ int save_kernel_channel_attributes(struct config_writer *writer,
 	if (ret) {
 		goto end;
 	}
+
+	if (attr->extended.ptr) {
+		struct lttng_channel_extended *ext = NULL;
+		ext = (struct lttng_channel_extended *) attr->extended.ptr;
+		ret = config_writer_write_element_unsigned_int(writer,
+				config_element_monitor_timer_interval,
+				ext->monitor_timer_interval);
+		if (ret) {
+			goto end;
+		}
+	}
+
 end:
 	return ret ? LTTNG_ERR_SAVE_IO_FAIL : 0;
 }
@@ -113,6 +125,7 @@ int save_ust_channel_attributes(struct config_writer *writer,
 	struct lttng_ust_channel_attr *attr)
 {
 	int ret;
+	struct ltt_ust_channel *channel = NULL;
 
 	ret = config_writer_write_element_string(writer,
 		config_element_overwrite_mode,
@@ -156,6 +169,20 @@ int save_ust_channel_attributes(struct config_writer *writer,
 	if (ret) {
 		goto end;
 	}
+
+	/*
+	 * Fetch the monitor timer which is located in the parent of
+	 * lttng_ust_channel_attr
+	 */
+
+	channel = caa_container_of(attr, struct ltt_ust_channel, attr);
+	ret = config_writer_write_element_unsigned_int(writer,
+		config_element_monitor_timer_interval,
+		channel->monitor_timer_interval);
+	if (ret) {
+		goto end;
+	}
+
 end:
 	return ret ? LTTNG_ERR_SAVE_IO_FAIL : 0;
 }
diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c
index 69b62d75..2445c8c4 100644
--- a/src/common/config/session-config.c
+++ b/src/common/config/session-config.c
@@ -2080,6 +2080,37 @@ int process_channel_attr_node(xmlNodePtr attr_node,
 		channel->attr.live_timer_interval =
 			live_timer_interval;
 	} else if (!strcmp((const char *) attr_node->name,
+			config_element_monitor_timer_interval)) {
+		xmlChar *content;
+		uint64_t monitor_timer_interval = 0;
+
+		/* monitor_timer_interval */
+		content = xmlNodeGetContent(attr_node);
+		if (!content) {
+			ret = -LTTNG_ERR_NOMEM;
+			goto end;
+		}
+
+		ret = parse_uint(content, &monitor_timer_interval);
+		free(content);
+		if (ret) {
+			ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
+			goto end;
+		}
+
+		if (monitor_timer_interval > UINT_MAX) {
+			WARN("monitor_timer_interval out of range.");
+			ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
+			goto end;
+		}
+
+		ret = lttng_channel_set_monitor_timer_interval(channel,
+			monitor_timer_interval);
+		if (ret) {
+			ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
+			goto end;
+		}
+	} else if (!strcmp((const char *) attr_node->name,
 			config_element_events)) {
 		/* events */
 		*events_node = attr_node;
@@ -2346,6 +2377,7 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
 	int ret;
 	struct lttng_domain domain = { 0 };
 	struct lttng_handle *handle = NULL;
+	struct lttng_channel *channel = NULL;
 	xmlNodePtr channels_node = NULL;
 	xmlNodePtr trackers_node = NULL;
 	xmlNodePtr pid_tracker_node = NULL;
@@ -2381,39 +2413,44 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
 	/* create all channels */
 	for (node = xmlFirstElementChild(channels_node); node;
 		node = xmlNextElementSibling(node)) {
-		struct lttng_channel channel;
 		xmlNodePtr contexts_node = NULL;
 		xmlNodePtr events_node = NULL;
 		xmlNodePtr channel_attr_node;
 
-		memset(&channel, 0, sizeof(channel));
-		lttng_channel_set_default_attr(&domain, &channel.attr);
+		channel = lttng_channel_create(&domain);
+		if (!channel) {
+			ret = 1;
+			goto end;
+		}
 
 		for (channel_attr_node = xmlFirstElementChild(node);
 			channel_attr_node; channel_attr_node =
 			xmlNextElementSibling(channel_attr_node)) {
 			ret = process_channel_attr_node(channel_attr_node,
-				&channel, &contexts_node, &events_node);
+				channel, &contexts_node, &events_node);
 			if (ret) {
 				goto end;
 			}
 		}
 
-		ret = lttng_enable_channel(handle, &channel);
+		ret = lttng_enable_channel(handle, channel);
 		if (ret < 0) {
 			goto end;
 		}
 
-		ret = process_events_node(events_node, handle, channel.name);
+		ret = process_events_node(events_node, handle, channel->name);
 		if (ret) {
 			goto end;
 		}
 
 		ret = process_contexts_node(contexts_node, handle,
-			channel.name);
+			channel->name);
 		if (ret) {
 			goto end;
 		}
+
+		lttng_channel_destroy(channel);
+		channel = NULL;
 	}
 
 	/* get the trackers node */
@@ -2446,6 +2483,7 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
 	}
 
 end:
+	lttng_channel_destroy(channel);
 	lttng_destroy_handle(handle);
 	return ret;
 }
diff --git a/src/common/config/session.xsd b/src/common/config/session.xsd
index 550fea0e..d3baf116 100644
--- a/src/common/config/session.xsd
+++ b/src/common/config/session.xsd
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -->
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
-elementFormDefault="qualified" version="2.8">
+elementFormDefault="qualified" version="2.10">
 
 <xs:simpleType name="name_type">
 	<xs:restriction base="xs:string">
@@ -192,6 +192,7 @@ elementFormDefault="qualified" version="2.8">
 		<xs:element name="live_timer_interval" type="uint32_type" default="0" minOccurs="0"/> <!-- usec -->
 		<xs:element name="events" type="event_list_type" minOccurs="0"/>
 		<xs:element name="contexts" type="event_context_list_type" minOccurs="0"/>
+		<xs:element name="monitor_timer_interval" type="uint64_type" default="0" minOccurs="0"/>  <!-- usec -->
 	</xs:all>
 </xs:complexType>
 
-- 
2.11.0



More information about the lttng-dev mailing list