cmd-2-1.c cmd-2-1.h \
cmd-2-2.c cmd-2-2.h \
cmd-2-4.c cmd-2-4.h \
+ cmd-2-11.c cmd-2-11.h \
health-relayd.c health-relayd.h \
lttng-viewer-abi.h testpoint.h \
viewer-stream.h viewer-stream.c \
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _LGPL_SOURCE
+#include <assert.h>
+
+#include <common/common.h>
+#include <common/sessiond-comm/relayd.h>
+
+#include <common/compat/endian.h>
+#include <common/compat/string.h>
+#include <lttng/constant.h>
+
+#include "cmd-generic.h"
+#include "cmd-2-1.h"
+#include "utils.h"
+
+/*
+ * cmd_recv_stream_2_11 allocates path_name and channel_name.
+ */
+int cmd_recv_stream_2_11(struct relay_connection *conn,
+ char **ret_path_name, char **ret_channel_name,
+ uint64_t *tracefile_size, uint64_t *tracefile_count,
+ struct relay_session *session)
+{
+ int ret;
+ struct lttcomm_relayd_add_stream_2_11 stream_info;
+ char *path_name = NULL;
+ char *channel_name = NULL;
+ size_t len;
+
+ ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info));
+ if (ret < 0) {
+ ERR("Unable to recv stream version 2.11");
+ goto error;
+ }
+
+ len = lttng_strnlen(stream_info.pathname, sizeof(stream_info.pathname));
+ /* Ensure that NULL-terminated and fits in local filename length. */
+ if (len == sizeof(stream_info.pathname) || len >= LTTNG_NAME_MAX) {
+ ret = -ENAMETOOLONG;
+ ERR("Path name too long");
+ goto error;
+ }
+ path_name = create_output_path(stream_info.pathname);
+ if (!path_name) {
+ PERROR("Path name allocation");
+ ret = -ENOMEM;
+ goto error;
+ }
+ len = lttng_strnlen(stream_info.channel_name, sizeof(stream_info.channel_name));
+ if (len == sizeof(stream_info.channel_name) || len >= DEFAULT_STREAM_NAME_LEN) {
+ ret = -ENAMETOOLONG;
+ ERR("Channel name too long");
+ goto error;
+ }
+ channel_name = strdup(stream_info.channel_name);
+ if (!channel_name) {
+ ret = -errno;
+ PERROR("Channel name allocation");
+ goto error;
+ }
+
+ *tracefile_size = be64toh(stream_info.tracefile_size);
+ *tracefile_count = be64toh(stream_info.tracefile_count);
+ *ret_path_name = path_name;
+ *ret_channel_name = channel_name;
+
+ switch (be32toh(stream_info.domain)) {
+ case LTTNG_DOMAIN_KERNEL:
+ session->kernel_session = 1;
+ break;
+ case LTTNG_DOMAIN_UST:
+ session->ust_session = 1;
+ break;
+ default:
+ ERR("Unknown domain in add_stream");
+ ret = -1;
+ goto error;
+ }
+ return 0;
+error:
+ free(path_name);
+ free(channel_name);
+ return ret;
+}
--- /dev/null
+#ifndef RELAYD_CMD_2_11_H
+#define RELAYD_CMD_2_11_H
+
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "lttng-relayd.h"
+
+int cmd_recv_stream_2_11(struct relay_connection *conn,
+ char **path_name, char **channel_name,
+ uint64_t *tracefile_size, uint64_t *tracefile_count,
+ struct relay_session *session);
+
+#endif /* RELAYD_CMD_2_11_H */
#include "cmd-2-1.h"
#include "cmd-2-2.h"
#include "cmd-2-4.h"
+#include "cmd-2-11.h"
#endif /* RELAYD_CMD_H */
&channel_name);
break;
case 2: /* LTTng sessiond 2.2. Allocates path_name and channel_name. */
- default:
+ case 3: /* LTTng sessiond 2.3. Allocates path_name and channel_name. */
+ case 4: /* LTTng sessiond 2.4. Allocates path_name and channel_name. */
+ case 5: /* LTTng sessiond 2.5. Allocates path_name and channel_name. */
+ case 6: /* LTTng sessiond 2.6. Allocates path_name and channel_name. */
+ case 7: /* LTTng sessiond 2.7. Allocates path_name and channel_name. */
+ case 8: /* LTTng sessiond 2.8. Allocates path_name and channel_name. */
+ case 9: /* LTTng sessiond 2.9. Allocates path_name and channel_name. */
+ case 10: /* LTTng sessiond 2.10. Allocates path_name and channel_name. */
ret = cmd_recv_stream_2_2(conn, &path_name,
&channel_name, &tracefile_size, &tracefile_count);
break;
+ case 11: /* LTTng sessiond 2.11. Allocates path_name and channel_name. */
+ default:
+ ret = cmd_recv_stream_2_11(conn, &path_name,
+ &channel_name, &tracefile_size, &tracefile_count,
+ session);
+ break;
}
if (ret < 0) {
goto send_reply;
*/
struct cds_list_head viewer_session_node;
struct rcu_head rcu_node; /* For call_rcu teardown. */
+ /*
+ * Domains in this session.
+ */
+ unsigned int ust_session:1;
+ unsigned int kernel_session:1;
};
struct relay_session *session_create(const char *session_name,
* Returns 0 on success, < 0 on error
*/
int consumer_send_relayd_stream(struct lttng_consumer_stream *stream,
- char *path)
+ char *path, enum lttng_domain_type domain)
{
int ret = 0;
struct consumer_relayd_sock_pair *relayd;
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
ret = relayd_add_stream(&relayd->control_sock, stream->name,
path, &stream->relayd_stream_id,
- stream->chan->tracefile_size, stream->chan->tracefile_count);
+ stream->chan->tracefile_size, stream->chan->tracefile_count,
+ domain);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
goto end;
/* lttng-relayd consumer command */
struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key);
-int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path);
+int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path,
+ enum lttng_domain_type domain);
int consumer_send_relayd_streams_sent(uint64_t net_seq_idx);
void close_relayd_stream(struct lttng_consumer_stream *stream);
struct lttng_consumer_channel *consumer_find_channel(uint64_t key);
stream->net_seq_idx = relayd_id;
channel->relayd_id = relayd_id;
if (relayd_id != (uint64_t) -1ULL) {
- ret = consumer_send_relayd_stream(stream, path);
+ ret = consumer_send_relayd_stream(stream, path,
+ LTTNG_DOMAIN_KERNEL);
if (ret < 0) {
ERR("sending stream to relayd");
goto end_unlock;
}
if (use_relayd) {
- ret = consumer_send_relayd_stream(metadata_stream, path);
+ ret = consumer_send_relayd_stream(metadata_stream, path,
+ LTTNG_DOMAIN_KERNEL);
if (ret < 0) {
goto error;
}
/* Send stream to relayd if the stream has an ID. */
if (new_stream->net_seq_idx != (uint64_t) -1ULL) {
ret = consumer_send_relayd_stream(new_stream,
- new_stream->chan->pathname);
+ new_stream->chan->pathname,
+ LTTNG_DOMAIN_KERNEL);
if (ret < 0) {
consumer_stream_free(new_stream);
goto end_nosignal;
*/
int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_name,
const char *pathname, uint64_t *stream_id,
- uint64_t tracefile_size, uint64_t tracefile_count)
+ uint64_t tracefile_size, uint64_t tracefile_count,
+ enum lttng_domain_type domain)
{
int ret;
struct lttcomm_relayd_add_stream msg;
struct lttcomm_relayd_add_stream_2_2 msg_2_2;
+ struct lttcomm_relayd_add_stream_2_11 msg_2_11;
struct lttcomm_relayd_status_stream reply;
/* Code flow error. Safety net. */
DBG("Relayd adding stream for channel name %s", channel_name);
/* Compat with relayd 2.1 */
- if (rsock->minor == 1) {
+ switch (rsock->minor) {
+ case 1:
memset(&msg, 0, sizeof(msg));
if (lttng_strncpy(msg.channel_name, channel_name,
sizeof(msg.channel_name))) {
if (ret < 0) {
goto error;
}
- } else {
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
memset(&msg_2_2, 0, sizeof(msg_2_2));
/* Compat with relayd 2.2+ */
if (lttng_strncpy(msg_2_2.channel_name, channel_name,
if (ret < 0) {
goto error;
}
+ break;
+ case 11:
+ default:
+ memset(&msg_2_11, 0, sizeof(msg_2_11));
+ /* Compat with relayd 2.11+ */
+ if (lttng_strncpy(msg_2_11.channel_name, channel_name,
+ sizeof(msg_2_11.channel_name))) {
+ ret = -1;
+ goto error;
+ }
+ if (lttng_strncpy(msg_2_11.pathname, pathname,
+ sizeof(msg_2_11.pathname))) {
+ ret = -1;
+ goto error;
+ }
+ msg_2_11.tracefile_size = htobe64(tracefile_size);
+ msg_2_11.tracefile_count = htobe64(tracefile_count);
+ msg_2_11.domain = htobe32(domain);
+
+ /* Send command */
+ ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) &msg_2_11, sizeof(msg_2_11), 0);
+ if (ret < 0) {
+ goto error;
+ }
+ break;
}
/* Waiting for reply */
unsigned int snapshot);
int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
const char *pathname, uint64_t *stream_id,
- uint64_t tracefile_size, uint64_t tracefile_count);
+ uint64_t tracefile_size, uint64_t tracefile_count,
+ enum lttng_domain_type domain);
int relayd_streams_sent(struct lttcomm_relayd_sock *rsock);
int relayd_send_close_stream(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
uint64_t last_net_seq_num);
uint64_t tracefile_count;
} LTTNG_PACKED;
+/*
+ * Used to add a stream on the relay daemon.
+ * Protocol version 2.11
+ */
+struct lttcomm_relayd_add_stream_2_11 {
+ char channel_name[DEFAULT_STREAM_NAME_LEN];
+ char pathname[LTTNG_PATH_MAX];
+ uint32_t domain; /* enum lttng_domain_type */
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+} LTTNG_PACKED;
+
/*
* Answer from an add stream command.
*/
health_code_update();
/* Try to send the stream to the relayd if one is available. */
- ret = consumer_send_relayd_stream(stream, stream->chan->pathname);
+ ret = consumer_send_relayd_stream(stream, stream->chan->pathname,
+ LTTNG_DOMAIN_UST);
if (ret < 0) {
/*
* Flag that the relayd was the problem here probably due to a
/* Send metadata stream to relayd if needed. */
if (metadata->metadata_stream->net_seq_idx != (uint64_t) -1ULL) {
ret = consumer_send_relayd_stream(metadata->metadata_stream,
- metadata->pathname);
+ metadata->pathname, LTTNG_DOMAIN_UST);
if (ret < 0) {
ret = LTTCOMM_CONSUMERD_ERROR_METADATA;
goto error;
if (relayd_id != (uint64_t) -1ULL) {
metadata_stream->net_seq_idx = relayd_id;
- ret = consumer_send_relayd_stream(metadata_stream, path);
+ ret = consumer_send_relayd_stream(metadata_stream, path,
+ LTTNG_DOMAIN_UST);
if (ret < 0) {
goto error_stream;
}
stream->net_seq_idx = relayd_id;
if (use_relayd) {
- ret = consumer_send_relayd_stream(stream, path);
+ ret = consumer_send_relayd_stream(stream, path,
+ LTTNG_DOMAIN_UST);
if (ret < 0) {
goto error_unlock;
}