[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_FAIL) ] = "Kernel create channel failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_ENABLE_FAIL) ] = "Enable kernel event failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DISABLE_FAIL) ] = "Disable kernel event failed",
+ [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_META_FAIL) ] = "Opening metadata failed",
[ LTTCOMM_ERR_INDEX(KCONSUMERD_COMMAND_SOCK_READY) ] = "Kconsumerd command socket ready",
[ LTTCOMM_ERR_INDEX(KCONSUMERD_SUCCESS_RECV_FD) ] = "Kconsumerd success on receiving fds",
[ LTTCOMM_ERR_INDEX(KCONSUMERD_ERROR_RECV_FD) ] = "Kconsumerd error on receiving fds",
KERNEL_CREATE_SESSION,
KERNEL_DISABLE_EVENT,
KERNEL_ENABLE_EVENT,
+ KERNEL_OPEN_METADATA,
KERNEL_START_TRACE,
KERNEL_STOP_TRACE,
LTTNG_CREATE_SESSION,
LTTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */
LTTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */
LTTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */
+ LTTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */
KCONSUMERD_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */
KCONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */
KCONSUMERD_ERROR_RECV_FD, /* error on receiving fds */
ret = kernctl_create_channel(cmd_ctx->session->kernel_session->fd, chan);
if (ret < 0) {
+ perror("ioctl create channel");
goto error;
}
error:
return ret;
}
+
+/*
+ * kernel_open_metadata
+ *
+ * Open metadata stream.
+ */
+int kernel_open_metadata(struct ltt_kernel_session *session)
+{
+ int ret;
+ struct ltt_kernel_metadata *lkm;
+ struct lttng_kernel_channel *conf;
+
+ lkm = malloc(sizeof(struct ltt_kernel_metadata));
+ conf = malloc(sizeof(struct lttng_kernel_channel));
+
+ if (lkm == NULL || conf == NULL) {
+ perror("kernel open metadata malloc");
+ ret = -errno;
+ goto error;
+ }
+
+ conf->overwrite = DEFAULT_KERNEL_OVERWRITE;
+ conf->subbuf_size = DEFAULT_KERNEL_SUBBUF_SIZE;
+ conf->num_subbuf = DEFAULT_KERNEL_SUBBUF_NUM;
+ conf->switch_timer_interval = DEFAULT_KERNEL_SWITCH_TIMER;
+ conf->read_timer_interval = DEFAULT_KERNEL_READ_TIMER;
+
+ ret = kernctl_open_metadata(session->fd, conf);
+ if (ret < 0) {
+ goto error;
+ }
+
+ session->metadata = lkm;
+ session->metadata->fd = ret;
+ session->metadata->conf = conf;
+
+ return 0;
+
+error:
+ return ret;
+}
int kernel_create_session(struct command_ctx *cmd_ctx, int tracer_fd);
int kernel_create_channel(struct command_ctx *cmd_ctx);
int kernel_enable_event(struct ltt_kernel_channel *channel, char *name);
+int kernel_open_metadata(struct ltt_kernel_session *session);
#endif /* _LTT_KERNEL_CTL_H */
switch (cmd_ctx->lsm->cmd_type) {
case KERNEL_CREATE_SESSION:
case KERNEL_CREATE_CHANNEL:
+ case KERNEL_DISABLE_EVENT:
+ case KERNEL_ENABLE_EVENT:
+ case KERNEL_OPEN_METADATA:
+ case KERNEL_START_TRACE:
+ case KERNEL_STOP_TRACE:
+ /* TODO: reconnect to kernel tracer to check if
+ * it's loadded */
if (kernel_tracer_fd == 0) {
ret = LTTCOMM_KERN_NA;
goto error;
ret = LTTCOMM_OK;
break;
}
+ case KERNEL_OPEN_METADATA:
+ {
+ /* Setup lttng message with no payload */
+ ret = setup_lttng_msg(cmd_ctx, 0);
+ if (ret < 0) {
+ goto setup_error;
+ }
+
+ DBG("Open kernel metadata");
+
+ ret = kernel_open_metadata(cmd_ctx->session->kernel_session);
+ if (ret < 0) {
+ ret = LTTCOMM_KERN_META_FAIL;
+ goto error;
+ }
+
+ ret = LTTCOMM_OK;
+ break;
+ }
case LTTNG_CREATE_SESSION:
{
/* Setup lttng message with no payload */
if (ret < 0) {
ERR("Unable to clean " LTTNG_RUNDIR);
}
+
+ // TODO Clean kernel trace fds
+ close(kernel_tracer_fd);
}
/*
struct ltt_kernel_event_list events_list;
};
+/* Metadata */
+struct ltt_kernel_metadata {
+ int fd;
+ struct lttng_kernel_channel *conf;
+};
+
/* Kernel session */
struct ltt_kernel_session {
int fd;
+ struct ltt_kernel_metadata *metadata;
struct ltt_kernel_channel *channel;
};