From: Julien Desfossez Date: Tue, 18 Jun 2013 19:25:53 +0000 (-0400) Subject: Add UST snapshot support X-Git-Tag: v2.3.0-rc1~78 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=10a5031171c7bca5b4498c871b119e5a88b6a3fb;p=lttng-tools.git Add UST snapshot support Signed-off-by: Julien Desfossez Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index ed4d6c86f..a6a81c5db 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "channel.h" #include "consumer.h" @@ -2403,6 +2404,14 @@ static int record_kernel_snapshot(struct ltt_kernel_session *ksess, assert(output); assert(session); + /* Get the datetime for the snapshot output directory. */ + ret = utils_get_current_time_str("%Y%m%d-%H%M%S", output->datetime, + sizeof(output->datetime)); + if (!ret) { + ret = -EINVAL; + goto error; + } + if (!output->kernel_sockets_copied) { ret = consumer_copy_sockets(output->consumer, ksess->consumer); if (ret < 0) { @@ -2439,6 +2448,14 @@ static int record_ust_snapshot(struct ltt_ust_session *usess, assert(output); assert(session); + /* Get the datetime for the snapshot output directory. */ + ret = utils_get_current_time_str("%Y%m%d-%H%M%S", output->datetime, + sizeof(output->datetime)); + if (!ret) { + ret = -EINVAL; + goto error; + } + if (!output->ust_sockets_copied) { ret = consumer_copy_sockets(output->consumer, usess->consumer); if (ret < 0) { @@ -2555,7 +2572,7 @@ int cmd_snapshot_record(struct ltt_session *session, rcu_read_lock(); cds_lfht_for_each_entry(session->snapshot.output_ht->ht, &iter.iter, sout, node.node) { - ret = record_ust_snapshot(usess, tmp_sout, session, wait); + ret = record_ust_snapshot(usess, sout, session, wait); if (ret < 0) { rcu_read_unlock(); goto error; diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 368837669..d3c561c9e 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "consumer.h" #include "health.h" @@ -752,9 +751,11 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); - strncpy(msg->u.ask_channel.pathname, pathname, - sizeof(msg->u.ask_channel.pathname)); - msg->u.ask_channel.pathname[sizeof(msg->u.ask_channel.pathname)-1] = '\0'; + if (pathname) { + strncpy(msg->u.ask_channel.pathname, pathname, + sizeof(msg->u.ask_channel.pathname)); + msg->u.ask_channel.pathname[sizeof(msg->u.ask_channel.pathname)-1] = '\0'; + } strncpy(msg->u.ask_channel.name, name, sizeof(msg->u.ask_channel.name)); msg->u.ask_channel.name[sizeof(msg->u.ask_channel.name) - 1] = '\0'; @@ -1198,7 +1199,6 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, const char *session_path, int wait) { int ret; - char datetime[16]; struct lttcomm_consumer_msg msg; assert(socket); @@ -1208,13 +1208,6 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, DBG("Consumer snapshot channel key %" PRIu64, key); - ret = utils_get_current_time_str("%Y%m%d-%H%M%S", datetime, - sizeof(datetime)); - if (!ret) { - ret = -EINVAL; - goto error; - } - memset(&msg, 0, sizeof(msg)); msg.cmd_type = LTTNG_CONSUMER_SNAPSHOT_CHANNEL; msg.u.snapshot_channel.key = key; @@ -1226,7 +1219,7 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, msg.u.snapshot_channel.use_relayd = 1; ret = snprintf(msg.u.snapshot_channel.pathname, sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s", - output->consumer->subdir, output->name, datetime, + output->consumer->subdir, output->name, output->datetime, session_path); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; @@ -1235,8 +1228,8 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, } else { ret = snprintf(msg.u.snapshot_channel.pathname, sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s", - output->consumer->dst.trace_path, output->name, datetime, - session_path); + output->consumer->dst.trace_path, output->name, + output->datetime, session_path); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; goto error; diff --git a/src/bin/lttng-sessiond/snapshot.c b/src/bin/lttng-sessiond/snapshot.c index 5265cf557..b14a398c3 100644 --- a/src/bin/lttng-sessiond/snapshot.c +++ b/src/bin/lttng-sessiond/snapshot.c @@ -214,11 +214,6 @@ error: return output; } -struct snapshot *snapshot_alloc(void) -{ - return zmalloc(sizeof(struct snapshot)); -} - /* * Initialized a snapshot object that was already allocated. * diff --git a/src/bin/lttng-sessiond/snapshot.h b/src/bin/lttng-sessiond/snapshot.h index 91215272a..bf594b5fe 100644 --- a/src/bin/lttng-sessiond/snapshot.h +++ b/src/bin/lttng-sessiond/snapshot.h @@ -36,6 +36,12 @@ struct snapshot_output { struct consumer_output *consumer; int kernel_sockets_copied; int ust_sockets_copied; + /* + * Contains the string with "-