From: Mathieu Desnoyers Date: Thu, 21 Mar 2013 15:08:14 +0000 (-0400) Subject: Add channel ID field to attr X-Git-Tag: v2.2.0-rc1~41 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6ca18e666d018ec79d517485a310c542cf735fa9;p=lttng-ust.git Add channel ID field to attr Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 2cf537a3..f9315a61 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -50,6 +50,7 @@ struct ustctl_consumer_channel_attr { unsigned int switch_timer_interval; /* usec */ unsigned int read_timer_interval; /* usec */ enum lttng_ust_output output; /* splice, mmap */ + uint32_t chan_id; /* channel ID */ unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ } LTTNG_PACKED; diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 2ffadde1..2b960305 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -384,7 +384,8 @@ struct lttng_channel_ops { size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, unsigned int read_timer_interval, - unsigned char *uuid); + unsigned char *uuid, + uint32_t chan_id); void (*channel_destroy)(struct lttng_channel *chan); int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, uint32_t event_id); diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index 4056221d..375b4db5 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -960,7 +960,7 @@ struct ustctl_consumer_channel * attr->subbuf_size, attr->num_subbuf, attr->switch_timer_interval, attr->read_timer_interval, - attr->uuid); + attr->uuid, attr->chan_id); if (!chan->chan) { goto chan_error; } diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 78a4f760..d5597ca6 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -262,6 +262,7 @@ int lttng_session_enable(struct lttng_session *session) const struct lttng_ctx *ctx; const struct lttng_event_field *fields = NULL; size_t nr_fields = 0; + uint32_t chan_id; /* don't change it if session stop/restart */ if (chan->header_type) @@ -276,12 +277,17 @@ int lttng_session_enable(struct lttng_session *session) chan->objd, nr_fields, fields, - &chan->id, + &chan_id, &chan->header_type); if (ret) { DBG("Error (%d) registering channel to sessiond", ret); return ret; } + if (chan_id != chan->id) { + DBG("Error: channel registration id (%u) does not match id assigned at creation (%u)", + chan_id, chan->id); + return -EINVAL; + } } /* Set atomically the state to "active" */ diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h index a67c65ae..c65a50ef 100644 --- a/liblttng-ust/lttng-ring-buffer-client.h +++ b/liblttng-ust/lttng-ring-buffer-client.h @@ -414,7 +414,8 @@ struct lttng_channel *_channel_create(const char *name, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, unsigned int read_timer_interval, - unsigned char *uuid) + unsigned char *uuid, + uint32_t chan_id) { struct lttng_channel chan_priv_init; struct lttng_ust_shm_handle *handle; @@ -423,6 +424,7 @@ struct lttng_channel *_channel_create(const char *name, memset(&chan_priv_init, 0, sizeof(chan_priv_init)); memcpy(chan_priv_init.uuid, uuid, LTTNG_UST_UUID_LEN); + chan_priv_init.id = chan_id; handle = channel_create(&client_config, name, &priv, __alignof__(*lttng_chan), sizeof(*lttng_chan), &chan_priv_init, diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h index 5c82187d..7dbdb821 100644 --- a/liblttng-ust/lttng-ring-buffer-metadata-client.h +++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h @@ -182,7 +182,8 @@ struct lttng_channel *_channel_create(const char *name, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, unsigned int read_timer_interval, - unsigned char *uuid) + unsigned char *uuid, + uint32_t chan_id) { struct lttng_channel chan_priv_init; struct lttng_ust_shm_handle *handle; @@ -191,6 +192,7 @@ struct lttng_channel *_channel_create(const char *name, memset(&chan_priv_init, 0, sizeof(chan_priv_init)); memcpy(chan_priv_init.uuid, uuid, LTTNG_UST_UUID_LEN); + chan_priv_init.id = chan_id; handle = channel_create(&client_config, name, &priv, __alignof__(*lttng_chan), sizeof(*lttng_chan), &chan_priv_init,