2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; only version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include <lttng/lttng.h>
22 #include <lttng-sessiond-comm.h>
26 #include "hashtable.h"
32 * Return allocated channel attributes.
34 struct lttng_channel
*channel_new_default_attr(int dom
)
36 struct lttng_channel
*chan
;
38 chan
= zmalloc(sizeof(struct lttng_channel
));
40 perror("zmalloc channel init");
44 if (snprintf(chan
->name
, sizeof(chan
->name
), "%s",
45 DEFAULT_CHANNEL_NAME
) < 0) {
46 perror("snprintf default channel name");
50 chan
->attr
.overwrite
= DEFAULT_CHANNEL_OVERWRITE
;
51 chan
->attr
.switch_timer_interval
= DEFAULT_CHANNEL_SWITCH_TIMER
;
52 chan
->attr
.read_timer_interval
= DEFAULT_CHANNEL_READ_TIMER
;
55 case LTTNG_DOMAIN_KERNEL
:
56 chan
->attr
.subbuf_size
= DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE
;
57 chan
->attr
.num_subbuf
= DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM
;
58 chan
->attr
.output
= DEFAULT_KERNEL_CHANNEL_OUTPUT
;
60 case LTTNG_DOMAIN_UST
:
61 case LTTNG_DOMAIN_UST_PID
:
62 chan
->attr
.subbuf_size
= DEFAULT_UST_CHANNEL_SUBBUF_SIZE
;
63 chan
->attr
.num_subbuf
= DEFAULT_UST_CHANNEL_SUBBUF_NUM
;
64 chan
->attr
.output
= DEFAULT_UST_CHANNEL_OUTPUT
;
67 goto error
; /* Not implemented */
79 * Disable kernel channel of the kernel session.
81 int channel_kernel_disable(struct ltt_kernel_session
*ksession
,
85 struct ltt_kernel_channel
*kchan
;
87 kchan
= trace_kernel_get_channel_by_name(channel_name
, ksession
);
89 ret
= LTTCOMM_KERN_CHAN_NOT_FOUND
;
91 } else if (kchan
->enabled
== 1) {
92 ret
= kernel_disable_channel(kchan
);
95 ret
= LTTCOMM_KERN_CHAN_DISABLE_FAIL
;
108 * Enable kernel channel of the kernel session.
110 int channel_kernel_enable(struct ltt_kernel_session
*ksession
,
111 struct ltt_kernel_channel
*kchan
)
115 if (kchan
->enabled
== 0) {
116 ret
= kernel_enable_channel(kchan
);
118 ret
= LTTCOMM_KERN_CHAN_ENABLE_FAIL
;
130 * Create kernel channel of the kernel session and notify kernel thread.
132 int channel_kernel_create(struct ltt_kernel_session
*ksession
,
133 struct lttng_channel
*attr
, int kernel_pipe
)
136 struct lttng_channel
*defattr
= NULL
;
138 /* Creating channel attributes if needed */
140 defattr
= channel_new_default_attr(LTTNG_DOMAIN_KERNEL
);
141 if (defattr
== NULL
) {
148 /* Channel not found, creating it */
149 ret
= kernel_create_channel(ksession
, attr
, ksession
->trace_path
);
151 ret
= LTTCOMM_KERN_CHAN_FAIL
;
155 /* Notify kernel thread that there is a new channel */
156 ret
= notify_thread_pipe(kernel_pipe
);