From 4fc2b12601cd1bd62a6bbdb75f08f1d32cdb781f Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 6 Jul 2017 11:08:42 -0400 Subject: [PATCH] Introduce monitor_timer_interval to session configuration schema MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Session configuration schema version is bumped to 2.10 Fixes #1099 Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/save.c | 27 +++++++++++++++++ src/common/config/session-config.c | 47 +++++++++++++++++++++++++----- src/common/config/session.xsd | 3 +- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 1a879b214..b9bcc666d 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -104,6 +104,19 @@ 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 +126,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 +170,19 @@ 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 5d0c23655..389d05427 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -2080,6 +2080,31 @@ 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; + } + + 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 */ @@ -2340,13 +2365,13 @@ end: return ret; } - static 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; @@ -2382,40 +2407,45 @@ 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 */ for (node = xmlFirstElementChild(domain_node); node; @@ -2447,6 +2477,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 6efdc433c..83f04bc53 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. --> +elementFormDefault="qualified" version="2.10"> @@ -205,6 +205,7 @@ by its signed 32-bit representation when converted to msec. + -- 2.34.1