From: Jonathan Rajotte Date: Mon, 10 Feb 2020 01:33:55 +0000 (-0500) Subject: trigger: consider domain on register and unregister X-Git-Tag: v2.13.0-rc1~409 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9124c6304bba12b0d4424b4071a25a34445ff4da;p=lttng-tools.git trigger: consider domain on register and unregister This allows the sessiond to inform the client if a trigger that requires a particular domain (event rule based condition, for example) is at all valid. This is useful to fail early when a trigger being registered requires an unavailable tracer. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I660937e64b294f6239ba15faeef705438a93a41a --- diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index faf5d579f..3ccc29efc 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -769,8 +769,9 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, int *sock_error) { int ret = LTTNG_OK; - int need_tracing_session = 1; - int need_domain; + bool need_tracing_session = true; + bool need_domain; + bool need_consumerd; DBG("Processing client command %d", cmd_ctx->lsm.cmd_type); @@ -794,18 +795,27 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, case LTTNG_SET_SESSION_SHM_PATH: case LTTNG_REGENERATE_METADATA: case LTTNG_REGENERATE_STATEDUMP: - case LTTNG_REGISTER_TRIGGER: - case LTTNG_UNREGISTER_TRIGGER: case LTTNG_ROTATE_SESSION: case LTTNG_ROTATION_GET_INFO: case LTTNG_ROTATION_SET_SCHEDULE: case LTTNG_SESSION_LIST_ROTATION_SCHEDULES: case LTTNG_CLEAR_SESSION: case LTTNG_LIST_TRIGGERS: - need_domain = 0; + need_domain = false; + break; + default: + need_domain = true; + } + + /* Needs a functioning consumerd? */ + switch (cmd_ctx->lsm.cmd_type) { + case LTTNG_REGISTER_TRIGGER: + case LTTNG_UNREGISTER_TRIGGER: + need_consumerd = false; break; default: - need_domain = 1; + need_consumerd = true; + break; } if (config.no_kernel && need_domain @@ -848,6 +858,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, case LTTNG_DATA_PENDING: case LTTNG_ROTATE_SESSION: case LTTNG_ROTATION_GET_INFO: + case LTTNG_REGISTER_TRIGGER: case LTTNG_LIST_TRIGGERS: break; default: @@ -870,7 +881,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, case LTTNG_REGISTER_TRIGGER: case LTTNG_UNREGISTER_TRIGGER: case LTTNG_LIST_TRIGGERS: - need_tracing_session = 0; + need_tracing_session = false; break; default: DBG("Getting session %s by name", cmd_ctx->lsm.session.name); @@ -948,7 +959,8 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, } /* Consumer is in an ERROR state. Report back to client */ - if (uatomic_read(&kernel_consumerd_state) == CONSUMER_ERROR) { + if (need_consumerd && uatomic_read(&kernel_consumerd_state) == + CONSUMER_ERROR) { ret = LTTNG_ERR_NO_KERNCONSUMERD; goto error; } @@ -999,8 +1011,10 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, ret = LTTNG_ERR_NO_UST; goto error; } + /* Consumer is in an ERROR state. Report back to client */ - if (uatomic_read(&ust_consumerd_state) == CONSUMER_ERROR) { + if (need_consumerd && uatomic_read(&ust_consumerd_state) == + CONSUMER_ERROR) { ret = LTTNG_ERR_NO_USTCONSUMERD; goto error; } diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 91d6109e5..a295667fe 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -2971,6 +2971,7 @@ int lttng_register_trigger(struct lttng_trigger *trigger) struct lttng_payload message; struct lttng_payload reply; struct lttng_trigger *reply_trigger = NULL; + enum lttng_domain_type domain_type; const struct lttng_credentials user_creds = { .uid = LTTNG_OPTIONAL_INIT_VALUE(geteuid()), .gid = LTTNG_OPTIONAL_INIT_UNSET, @@ -3015,6 +3016,11 @@ int lttng_register_trigger(struct lttng_trigger *trigger) goto end; } + domain_type = lttng_trigger_get_underlying_domain_type_restriction( + trigger); + + lsm.domain.type = domain_type; + ret = lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm)); if (ret) { ret = -LTTNG_ERR_NOMEM;