From 658f12fa973b58f324b6f018672cc03222cfc7b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 4 Mar 2019 22:16:10 -0500 Subject: [PATCH] relayd: send sessiond uuid and session id as part of create session MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Send the sessiond's instance UUID and session id as part of the relay daemon control protocol's CREATE_SESSION command. Those attributes will be used to uniquely identify trace chunks in follow-up commits. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/consumer.c | 4 +++- src/common/relayd/relayd.c | 18 ++++++++++++------ src/common/relayd/relayd.h | 7 ++++--- src/common/sessiond-comm/relayd.h | 5 +++++ tests/regression/tools/live/Makefile.am | 4 +++- tests/unit/Makefile.am | 2 ++ 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 336c76071..171301ab5 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -35,6 +35,7 @@ #include "health-sessiond.h" #include "ust-app.h" #include "utils.h" +#include "lttng-sessiond.h" /* * Send a data payload using a given consumer socket of size len. @@ -1078,7 +1079,8 @@ int consumer_send_relayd_socket(struct consumer_socket *consumer_sock, ret = relayd_create_session(rsock, &msg.u.relayd_sock.relayd_session_id, session_name, hostname, session_live_timer, - consumer->snapshot); + consumer->snapshot, session_id, + sessiond_uuid); if (ret < 0) { /* Close the control socket. */ (void) relayd_close(rsock); diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index 78ed85558..ff0be32a1 100644 --- a/src/common/relayd/relayd.c +++ b/src/common/relayd/relayd.c @@ -127,7 +127,8 @@ error: */ static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock, char *session_name, char *hostname, - int session_live_timer, unsigned int snapshot) + int session_live_timer, unsigned int snapshot, + uint64_t sessiond_session_id, const lttng_uuid sessiond_uuid) { int ret; struct lttcomm_relayd_create_session_2_11 *msg = NULL; @@ -165,6 +166,9 @@ static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock, msg->live_timer = htobe32(session_live_timer); msg->snapshot = !!snapshot; + lttng_uuid_copy(msg->sessiond_uuid, sessiond_uuid); + msg->session_id = htobe64(sessiond_session_id); + /* Send command */ ret = send_command(rsock, RELAYD_CREATE_SESSION, msg, msg_length, 0); if (ret < 0) { @@ -231,15 +235,16 @@ error: * On success, return 0 else a negative value which is either an errno error or * a lttng error code from the relayd. */ -int relayd_create_session(struct lttcomm_relayd_sock *rsock, uint64_t *session_id, +int relayd_create_session(struct lttcomm_relayd_sock *rsock, uint64_t *relayd_session_id, char *session_name, char *hostname, int session_live_timer, - unsigned int snapshot) + unsigned int snapshot, uint64_t sessiond_session_id, + const lttng_uuid sessiond_uuid) { int ret; struct lttcomm_relayd_status_session reply; assert(rsock); - assert(session_id); + assert(relayd_session_id); DBG("Relayd create session"); @@ -253,7 +258,8 @@ int relayd_create_session(struct lttcomm_relayd_sock *rsock, uint64_t *session_i } else { /* From 2.11 to ... */ ret = relayd_create_session_2_11(rsock, session_name, - hostname, session_live_timer, snapshot); + hostname, session_live_timer, snapshot, + sessiond_session_id, sessiond_uuid); } if (ret < 0) { @@ -276,7 +282,7 @@ int relayd_create_session(struct lttcomm_relayd_sock *rsock, uint64_t *session_i goto error; } else { ret = 0; - *session_id = reply.session_id; + *relayd_session_id = reply.session_id; } DBG("Relayd session created with id %" PRIu64, reply.session_id); diff --git a/src/common/relayd/relayd.h b/src/common/relayd/relayd.h index 9353fc2d7..2fcdcf4c7 100644 --- a/src/common/relayd/relayd.h +++ b/src/common/relayd/relayd.h @@ -25,9 +25,10 @@ int relayd_connect(struct lttcomm_relayd_sock *sock); int relayd_close(struct lttcomm_relayd_sock *sock); -int relayd_create_session(struct lttcomm_relayd_sock *sock, uint64_t *session_id, - char *session_name, char *hostname, int session_live_timer, - unsigned int snapshot); +int relayd_create_session(struct lttcomm_relayd_sock *sock, + uint64_t *relayd_session_id, char *session_name, char *hostname, + int session_live_timer, unsigned int snapshot, + uint64_t sessiond_session_id, const lttng_uuid sessiond_uuid); 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, diff --git a/src/common/sessiond-comm/relayd.h b/src/common/sessiond-comm/relayd.h index 579a41df1..cbeb5b5d6 100644 --- a/src/common/sessiond-comm/relayd.h +++ b/src/common/sessiond-comm/relayd.h @@ -26,6 +26,7 @@ #include #include #include +#include #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR @@ -206,6 +207,10 @@ struct lttcomm_relayd_create_session_2_11 { uint32_t hostname_len; uint32_t live_timer; uint8_t snapshot; + /* Sessiond instance UUID */ + lttng_uuid sessiond_uuid; + /* Sessiond session id */ + uint64_t session_id; /* Contains the session_name and hostname */ char names[]; } LTTNG_PACKED; diff --git a/tests/regression/tools/live/Makefile.am b/tests/regression/tools/live/Makefile.am index 7a26b42cf..be9388b17 100644 --- a/tests/regression/tools/live/Makefile.am +++ b/tests/regression/tools/live/Makefile.am @@ -7,8 +7,10 @@ LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la LIBRELAYD=$(top_builddir)/src/common/relayd/librelayd.la LIBHEALTH=$(top_builddir)/src/common/health/libhealth.la +LIBCOMPAT=$(top_builddir)/src/common/compat/libcompat.la LIVE= $(top_builddir)/src/bin/lttng-sessiond/consumer.$(OBJEXT) \ + $(top_builddir)/src/bin/lttng-sessiond/globals.$(OBJEXT) \ $(top_builddir)/src/bin/lttng-sessiond/utils.$(OBJEXT) \ $(top_builddir)/src/bin/lttng-sessiond/snapshot.$(OBJEXT) @@ -21,7 +23,7 @@ endif live_test_SOURCES = live_test.c live_test_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBRELAYD) $(LIBSESSIOND_COMM) \ - $(LIBHASHTABLE) $(LIBHEALTH) $(DL_LIBS) -lrt + $(LIBHASHTABLE) $(LIBHEALTH) $(DL_LIBS) $(LIBCOMPAT) -lrt live_test_LDADD += $(LIVE) \ $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index a949d3cdd..4ded1dfb1 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -126,7 +126,9 @@ endif # Kernel data structures unit test KERN_DATA_TRACE=$(top_builddir)/src/bin/lttng-sessiond/trace-kernel.$(OBJEXT) \ + $(top_builddir)/src/common/compat/libcompat.la \ $(top_builddir)/src/bin/lttng-sessiond/consumer.$(OBJEXT) \ + $(top_builddir)/src/bin/lttng-sessiond/globals.$(OBJEXT) \ $(top_builddir)/src/bin/lttng-sessiond/utils.$(OBJEXT) \ $(top_builddir)/src/common/health/libhealth.la \ $(top_builddir)/src/bin/lttng-sessiond/notification-thread-commands.$(OBJEXT) \ -- 2.34.1