Fix: file-descriptor: missing include guards
[lttng-tools.git] / src / bin / lttng-sessiond / channel.cpp
CommitLineData
54d01ffb 1/*
21cf9b6b 2 * Copyright (C) 2011 EfficiOS Inc.
ab5be9fa 3 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
54d01ffb 4 *
ab5be9fa 5 * SPDX-License-Identifier: GPL-2.0-only
54d01ffb 6 *
54d01ffb
DG
7 */
8
6c1c0768 9#define _LGPL_SOURCE
28ab034a 10#include "agent.hpp"
c9e313bc 11#include "channel.hpp"
c9e313bc 12#include "kernel.hpp"
28ab034a 13#include "lttng-sessiond.hpp"
c9e313bc
SM
14#include "lttng-ust-ctl.hpp"
15#include "lttng-ust-error.hpp"
c9e313bc 16#include "ust-app.hpp"
28ab034a
JG
17#include "utils.hpp"
18
19#include <common/common.hpp>
20#include <common/defaults.hpp>
21#include <common/sessiond-comm/sessiond-comm.hpp>
22
23#include <inttypes.h>
24#include <string.h>
25#include <unistd.h>
54d01ffb
DG
26
27/*
28 * Return allocated channel attributes.
29 */
28ab034a 30struct lttng_channel *channel_new_default_attr(int dom, enum lttng_buffer_type type)
54d01ffb
DG
31{
32 struct lttng_channel *chan;
bdf64013 33 const char *channel_name = DEFAULT_CHANNEL_NAME;
cd9adb8b 34 struct lttng_channel_extended *extended_attr = nullptr;
54d01ffb 35
64803277 36 chan = zmalloc<lttng_channel>();
cd9adb8b 37 if (chan == nullptr) {
7885e399 38 PERROR("zmalloc channel init");
54d01ffb
DG
39 goto error_alloc;
40 }
41
64803277 42 extended_attr = zmalloc<lttng_channel_extended>();
e9404c27
JG
43 if (!extended_attr) {
44 PERROR("zmalloc channel extended init");
45 goto error;
46 }
47
48 chan->attr.extended.ptr = extended_attr;
49
0a9c6494 50 /* Same for all domains. */
54d01ffb 51 chan->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE;
0a9c6494
DG
52 chan->attr.tracefile_size = DEFAULT_CHANNEL_TRACEFILE_SIZE;
53 chan->attr.tracefile_count = DEFAULT_CHANNEL_TRACEFILE_COUNT;
54d01ffb
DG
54
55 switch (dom) {
1b1c65fa 56 case LTTNG_DOMAIN_KERNEL:
a0377dfe 57 LTTNG_ASSERT(type == LTTNG_BUFFER_GLOBAL);
28ab034a 58 chan->attr.subbuf_size = default_get_kernel_channel_subbuf_size();
1b1c65fa
MD
59 chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
60 chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
6bb9e85f
MD
61 chan->attr.switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
62 chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
ecc48a90 63 chan->attr.live_timer_interval = DEFAULT_KERNEL_CHANNEL_LIVE_TIMER;
491d1539 64 extended_attr->blocking_timeout = DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT;
28ab034a 65 extended_attr->monitor_timer_interval = DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER;
1b1c65fa 66 break;
bdf64013
JG
67 case LTTNG_DOMAIN_JUL:
68 channel_name = DEFAULT_JUL_CHANNEL_NAME;
69 goto common_ust;
70 case LTTNG_DOMAIN_LOG4J:
71 channel_name = DEFAULT_LOG4J_CHANNEL_NAME;
72 goto common_ust;
73 case LTTNG_DOMAIN_PYTHON:
74 channel_name = DEFAULT_PYTHON_CHANNEL_NAME;
75 goto common_ust;
1b1c65fa 76 case LTTNG_DOMAIN_UST:
28ab034a 77 common_ust:
0a9c6494
DG
78 switch (type) {
79 case LTTNG_BUFFER_PER_UID:
80 chan->attr.subbuf_size = default_get_ust_uid_channel_subbuf_size();
81 chan->attr.num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
82 chan->attr.output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
28ab034a
JG
83 chan->attr.switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
84 chan->attr.read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
85 chan->attr.live_timer_interval = DEFAULT_UST_UID_CHANNEL_LIVE_TIMER;
491d1539 86 extended_attr->blocking_timeout = DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT;
e9404c27
JG
87 extended_attr->monitor_timer_interval =
88 DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER;
0a9c6494
DG
89 break;
90 case LTTNG_BUFFER_PER_PID:
91 default:
92 chan->attr.subbuf_size = default_get_ust_pid_channel_subbuf_size();
93 chan->attr.num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
94 chan->attr.output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
28ab034a
JG
95 chan->attr.switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
96 chan->attr.read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
97 chan->attr.live_timer_interval = DEFAULT_UST_PID_CHANNEL_LIVE_TIMER;
491d1539 98 extended_attr->blocking_timeout = DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT;
e9404c27
JG
99 extended_attr->monitor_timer_interval =
100 DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER;
0a9c6494
DG
101 break;
102 }
1b1c65fa
MD
103 break;
104 default:
28ab034a 105 goto error; /* Not implemented */
54d01ffb
DG
106 }
107
28ab034a 108 if (snprintf(chan->name, sizeof(chan->name), "%s", channel_name) < 0) {
bdf64013
JG
109 PERROR("snprintf default channel name");
110 goto error;
111 }
54d01ffb
DG
112 return chan;
113
114error:
e9404c27 115 free(extended_attr);
54d01ffb
DG
116 free(chan);
117error_alloc:
cd9adb8b 118 return nullptr;
54d01ffb
DG
119}
120
e9404c27
JG
121void channel_attr_destroy(struct lttng_channel *channel)
122{
123 if (!channel) {
124 return;
125 }
126 free(channel->attr.extended.ptr);
127 free(channel);
128}
129
54d01ffb
DG
130/*
131 * Disable kernel channel of the kernel session.
132 */
28ab034a 133int channel_kernel_disable(struct ltt_kernel_session *ksession, char *channel_name)
54d01ffb
DG
134{
135 int ret;
136 struct ltt_kernel_channel *kchan;
137
a0377dfe
FD
138 LTTNG_ASSERT(ksession);
139 LTTNG_ASSERT(channel_name);
0525e9ae 140
54d01ffb 141 kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
cd9adb8b 142 if (kchan == nullptr) {
f73fabfd 143 ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
54d01ffb 144 goto error;
0525e9ae
DG
145 }
146
147 /* Only if channel is enabled disable it. */
66cefebd 148 if (kchan->enabled) {
54d01ffb 149 ret = kernel_disable_channel(kchan);
7885e399 150 if (ret < 0 && ret != -EEXIST) {
f73fabfd 151 ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL;
54d01ffb
DG
152 goto error;
153 }
154 }
155
f73fabfd 156 ret = LTTNG_OK;
54d01ffb
DG
157
158error:
159 return ret;
160}
161
162/*
163 * Enable kernel channel of the kernel session.
164 */
4878de5c 165enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
28ab034a 166 struct ltt_kernel_channel *kchan)
54d01ffb 167{
4878de5c 168 enum lttng_error_code ret_code;
54d01ffb 169
a0377dfe
FD
170 LTTNG_ASSERT(ksession);
171 LTTNG_ASSERT(kchan);
0525e9ae 172
66cefebd 173 if (!kchan->enabled) {
4878de5c
JG
174 if (kernel_enable_channel(kchan) < 0) {
175 ret_code = LTTNG_ERR_KERN_CHAN_ENABLE_FAIL;
54d01ffb
DG
176 goto error;
177 }
42224349 178 } else {
4878de5c 179 ret_code = LTTNG_ERR_KERN_CHAN_EXIST;
42224349 180 goto error;
54d01ffb
DG
181 }
182
4878de5c 183 ret_code = LTTNG_OK;
54d01ffb
DG
184
185error:
4878de5c 186 return ret_code;
54d01ffb
DG
187}
188
da9d9d9c
MD
189static int channel_validate(struct lttng_channel *attr)
190{
191 /*
192 * The ringbuffer (both in user space and kernel) behaves badly
193 * in overwrite mode and with less than 2 subbuffers so block it
194 * right away and send back an invalid attribute error.
195 */
196 if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
197 return -1;
198 }
199 return 0;
200}
201
491d1539
MD
202static int channel_validate_kernel(struct lttng_channel *attr)
203{
204 /* Kernel channels do not support blocking timeout. */
28ab034a 205 if (((struct lttng_channel_extended *) attr->attr.extended.ptr)->blocking_timeout) {
491d1539
MD
206 return -1;
207 }
208 return 0;
209}
210
54d01ffb
DG
211/*
212 * Create kernel channel of the kernel session and notify kernel thread.
213 */
4878de5c 214enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
28ab034a
JG
215 struct lttng_channel *attr,
216 int kernel_pipe)
54d01ffb 217{
4878de5c 218 enum lttng_error_code ret_code;
cd9adb8b 219 struct lttng_channel *defattr = nullptr;
54d01ffb 220
a0377dfe 221 LTTNG_ASSERT(ksession);
0525e9ae 222
54d01ffb 223 /* Creating channel attributes if needed */
cd9adb8b 224 if (attr == nullptr) {
28ab034a 225 defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
cd9adb8b 226 if (defattr == nullptr) {
4878de5c 227 ret_code = LTTNG_ERR_FATAL;
54d01ffb
DG
228 goto error;
229 }
ff4d74e6 230 attr = defattr;
54d01ffb
DG
231 }
232
8d5841ea
MD
233 /*
234 * Set the overwrite mode for this channel based on the session
235 * type unless the client explicitly overrides the channel mode.
236 */
237 if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) {
238 attr->attr.overwrite = !!ksession->snapshot_mode;
239 }
240
da9d9d9c
MD
241 /* Validate common channel properties. */
242 if (channel_validate(attr) < 0) {
4878de5c 243 ret_code = LTTNG_ERR_INVALID;
da9d9d9c
MD
244 goto error;
245 }
246
491d1539 247 if (channel_validate_kernel(attr) < 0) {
4878de5c 248 ret_code = LTTNG_ERR_INVALID;
491d1539
MD
249 goto error;
250 }
251
4878de5c
JG
252 /* Channel not found, creating it. */
253 if (kernel_create_channel(ksession, attr) < 0) {
254 ret_code = LTTNG_ERR_KERN_CHAN_FAIL;
54d01ffb
DG
255 goto error;
256 }
257
258 /* Notify kernel thread that there is a new channel */
4878de5c
JG
259 if (notify_thread_pipe(kernel_pipe) < 0) {
260 ret_code = LTTNG_ERR_FATAL;
54d01ffb
DG
261 goto error;
262 }
263
4878de5c 264 ret_code = LTTNG_OK;
54d01ffb 265error:
e9404c27 266 channel_attr_destroy(defattr);
4878de5c 267 return ret_code;
54d01ffb 268}
7885e399
DG
269
270/*
271 * Enable UST channel for session and domain.
272 */
4878de5c 273enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
28ab034a 274 struct ltt_ust_channel *uchan)
7885e399 275{
4878de5c 276 enum lttng_error_code ret_code = LTTNG_OK;
7885e399 277
a0377dfe
FD
278 LTTNG_ASSERT(usess);
279 LTTNG_ASSERT(uchan);
0525e9ae 280
7885e399
DG
281 /* If already enabled, everything is OK */
282 if (uchan->enabled) {
283 DBG3("Channel %s already enabled. Skipping", uchan->name);
4878de5c 284 ret_code = LTTNG_ERR_UST_CHAN_EXIST;
7885e399 285 goto end;
88e3c2f5 286 } else {
66cefebd 287 uchan->enabled = true;
88e3c2f5
JG
288 DBG2("Channel %s enabled successfully", uchan->name);
289 }
290
291 if (!usess->active) {
292 /*
293 * The channel will be activated against the apps
294 * when the session is started as part of the
295 * application channel "synchronize" operation.
296 */
297 goto end;
7885e399
DG
298 }
299
7972aab2
DG
300 DBG2("Channel %s being enabled in UST domain", uchan->name);
301
302 /*
303 * Enable channel for UST global domain on all applications. Ignore return
304 * value here since whatever error we got, it means that the channel was
305 * not created on one or many registered applications and we can not report
306 * this to the user yet. However, at this stage, the channel was
307 * successfully created on the session daemon side so the enable-channel
308 * command is a success.
309 */
d54b4440 310 (void) ust_app_enable_channel_glb(usess, uchan);
7885e399 311
7885e399 312end:
4878de5c 313 return ret_code;
7885e399
DG
314}
315
316/*
317 * Create UST channel for session and domain.
318 */
4878de5c 319enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
28ab034a
JG
320 struct lttng_channel *attr,
321 enum lttng_buffer_type type)
7885e399 322{
4878de5c 323 enum lttng_error_code ret_code = LTTNG_OK;
cd9adb8b
JG
324 struct ltt_ust_channel *uchan = nullptr;
325 struct lttng_channel *defattr = nullptr;
b63d638b 326 enum lttng_domain_type domain = LTTNG_DOMAIN_UST;
f86e086c 327 bool chan_published = false;
56047f5a 328 lttng::urcu::read_lock_guard read_lock;
7885e399 329
a0377dfe 330 LTTNG_ASSERT(usess);
0525e9ae 331
7885e399 332 /* Creating channel attributes if needed */
cd9adb8b 333 if (attr == nullptr) {
0a9c6494 334 defattr = channel_new_default_attr(LTTNG_DOMAIN_UST, type);
cd9adb8b 335 if (defattr == nullptr) {
4878de5c 336 ret_code = LTTNG_ERR_FATAL;
7885e399
DG
337 goto error;
338 }
339 attr = defattr;
b63d638b
JG
340 } else {
341 /*
342 * HACK: Set the channel's subdomain (JUL, Log4j, Python, etc.)
343 * based on the default name.
344 */
345 if (!strcmp(attr->name, DEFAULT_JUL_CHANNEL_NAME)) {
346 domain = LTTNG_DOMAIN_JUL;
347 } else if (!strcmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME)) {
348 domain = LTTNG_DOMAIN_LOG4J;
349 } else if (!strcmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME)) {
350 domain = LTTNG_DOMAIN_PYTHON;
351 }
7885e399
DG
352 }
353
8d5841ea
MD
354 /*
355 * Set the overwrite mode for this channel based on the session
356 * type unless the client explicitly overrides the channel mode.
357 */
358 if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) {
359 attr->attr.overwrite = !!usess->snapshot_mode;
360 }
361
362 /* Enforce mmap output for snapshot sessions. */
27babd3a 363 if (usess->snapshot_mode) {
27babd3a
DG
364 attr->attr.output = LTTNG_EVENT_MMAP;
365 }
366
da9d9d9c
MD
367 /* Validate common channel properties. */
368 if (channel_validate(attr) < 0) {
4878de5c 369 ret_code = LTTNG_ERR_INVALID;
da9d9d9c
MD
370 goto error;
371 }
372
b024d072 373 /*
0525e9ae
DG
374 * Validate UST buffer size and number of buffers: must both be power of 2
375 * and nonzero. We validate right here for UST, because applications will
376 * not report the error to the user (unlike kernel tracing).
b024d072 377 */
28ab034a 378 if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
4878de5c 379 ret_code = LTTNG_ERR_INVALID;
b024d072
MD
380 goto error;
381 }
0525e9ae 382
12744796
DG
383 /*
384 * Invalid subbuffer size if it's lower then the page size.
385 */
412d7227 386 if (attr->attr.subbuf_size < the_page_size) {
4878de5c 387 ret_code = LTTNG_ERR_INVALID;
12744796
DG
388 goto error;
389 }
390
28ab034a 391 if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
4878de5c 392 ret_code = LTTNG_ERR_INVALID;
b024d072
MD
393 goto error;
394 }
395
a79d84dd 396 if (attr->attr.output != LTTNG_EVENT_MMAP) {
4878de5c 397 ret_code = LTTNG_ERR_NOT_SUPPORTED;
a79d84dd
DG
398 goto error;
399 }
400
1624d5b7
JD
401 /*
402 * The tracefile_size should not be < to the subbuf_size, otherwise
403 * we won't be able to write the packets on disk
404 */
405 if ((attr->attr.tracefile_size > 0) &&
28ab034a 406 (attr->attr.tracefile_size < attr->attr.subbuf_size)) {
4878de5c 407 ret_code = LTTNG_ERR_INVALID;
1624d5b7
JD
408 goto error;
409 }
410
2e8269f7
DG
411 /* Validate buffer type. */
412 switch (type) {
413 case LTTNG_BUFFER_PER_PID:
0a9c6494 414 break;
2e8269f7
DG
415 case LTTNG_BUFFER_PER_UID:
416 break;
417 default:
4878de5c 418 ret_code = LTTNG_ERR_BUFFER_NOT_SUPPORTED;
2e8269f7
DG
419 goto error;
420 }
421
7885e399 422 /* Create UST channel */
b63d638b 423 uchan = trace_ust_create_channel(attr, domain);
cd9adb8b 424 if (uchan == nullptr) {
4878de5c 425 ret_code = LTTNG_ERR_FATAL;
7885e399
DG
426 goto error;
427 }
51755dc8 428
66cefebd 429 uchan->enabled = true;
7972aab2 430 if (trace_ust_is_max_id(usess->used_channel_id)) {
4878de5c 431 ret_code = LTTNG_ERR_UST_CHAN_FAIL;
7972aab2
DG
432 goto error;
433 }
434 uchan->id = trace_ust_get_next_chan_id(usess);
435
436 DBG2("Channel %s is being created for UST with buffer %d and id %" PRIu64,
28ab034a
JG
437 uchan->name,
438 type,
439 uchan->id);
7972aab2
DG
440
441 /* Flag session buffer type. */
442 if (!usess->buffer_type_changed) {
443 usess->buffer_type = type;
444 usess->buffer_type_changed = 1;
445 } else if (usess->buffer_type != type) {
446 /* Buffer type was already set. Refuse to create channel. */
4878de5c 447 ret_code = LTTNG_ERR_BUFFER_TYPE_MISMATCH;
7885e399
DG
448 goto error_free_chan;
449 }
450
fc34caaa 451 /* Adding the channel to the channel hash table. */
5c7248cd 452 if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name)) != 0) {
ad7a9107 453 lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node);
f86e086c 454 chan_published = true;
84ad93e8
DG
455 } else {
456 /*
457 * Copy channel attribute to session if this is metadata so if NO
458 * application exists we can access that data in the shadow copy during
459 * the global update of newly registered application.
460 */
28ab034a 461 memcpy(&usess->metadata_attr, &uchan->attr, sizeof(usess->metadata_attr));
ad7a9107 462 }
fc34caaa 463
7885e399 464 DBG2("Channel %s created successfully", uchan->name);
b63d638b
JG
465 if (domain != LTTNG_DOMAIN_UST) {
466 struct agent *agt = trace_ust_find_agent(usess, domain);
467
468 if (!agt) {
469 agt = agent_create(domain);
470 if (!agt) {
4878de5c 471 ret_code = LTTNG_ERR_NOMEM;
f86e086c 472 goto error_remove_chan;
b63d638b
JG
473 }
474 agent_add(agt, usess->agents);
475 }
476 }
7885e399 477
e9404c27 478 channel_attr_destroy(defattr);
f73fabfd 479 return LTTNG_OK;
7885e399 480
f86e086c
MD
481error_remove_chan:
482 if (chan_published) {
483 trace_ust_delete_channel(usess->domain_global.channels, uchan);
484 }
7885e399
DG
485error_free_chan:
486 trace_ust_destroy_channel(uchan);
487error:
e9404c27 488 channel_attr_destroy(defattr);
4878de5c 489 return ret_code;
7885e399
DG
490}
491
492/*
493 * Disable UST channel for session and domain.
494 */
28ab034a 495int channel_ust_disable(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan)
7885e399 496{
f73fabfd 497 int ret = LTTNG_OK;
7885e399 498
a0377dfe
FD
499 LTTNG_ASSERT(usess);
500 LTTNG_ASSERT(uchan);
0525e9ae 501
7885e399 502 /* Already disabled */
66cefebd 503 if (!uchan->enabled) {
7885e399
DG
504 DBG2("Channel UST %s already disabled", uchan->name);
505 goto end;
506 }
fbee8987 507
66cefebd 508 uchan->enabled = false;
fbee8987
FD
509
510 /*
511 * If session is inactive we don't notify the tracer right away. We
512 * wait for the next synchronization.
513 */
88e3c2f5
JG
514 if (!usess->active) {
515 goto end;
516 }
7885e399 517
7972aab2
DG
518 DBG2("Channel %s being disabled in UST global domain", uchan->name);
519 /* Disable channel for global domain */
520 ret = ust_app_disable_channel_glb(usess, uchan);
49c336c1 521 if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
f73fabfd 522 ret = LTTNG_ERR_UST_CHAN_DISABLE_FAIL;
7885e399
DG
523 goto error;
524 }
525
7885e399
DG
526 DBG2("Channel %s disabled successfully", uchan->name);
527
f73fabfd 528 return LTTNG_OK;
7885e399
DG
529
530end:
531error:
532 return ret;
533}
999af9c1 534
28ab034a 535struct lttng_channel *trace_ust_channel_to_lttng_channel(const struct ltt_ust_channel *uchan)
999af9c1 536{
cd9adb8b 537 struct lttng_channel *channel = nullptr, *ret = nullptr;
999af9c1
JR
538
539 channel = lttng_channel_create_internal();
540 if (!channel) {
541 ERR("Failed to create lttng_channel during conversion from ltt_ust_channel to lttng_channel");
542 goto end;
543 }
544
545 if (lttng_strncpy(channel->name, uchan->name, LTTNG_SYMBOL_NAME_LEN)) {
546 ERR("Failed to set channel name during conversion from ltt_ust_channel to lttng_channel");
547 goto end;
548 }
549
550 channel->attr.overwrite = uchan->attr.overwrite;
551 channel->attr.subbuf_size = uchan->attr.subbuf_size;
552 channel->attr.num_subbuf = uchan->attr.num_subbuf;
553 channel->attr.switch_timer_interval = uchan->attr.switch_timer_interval;
554 channel->attr.read_timer_interval = uchan->attr.read_timer_interval;
555 channel->enabled = uchan->enabled;
556 channel->attr.tracefile_size = uchan->tracefile_size;
557 channel->attr.tracefile_count = uchan->tracefile_count;
558
559 /*
560 * Map enum lttng_ust_output to enum lttng_event_output.
561 */
562 switch (uchan->attr.output) {
563 case LTTNG_UST_ABI_MMAP:
564 channel->attr.output = LTTNG_EVENT_MMAP;
565 break;
566 default:
567 /*
568 * LTTNG_UST_MMAP is the only supported UST
569 * output mode.
570 */
571 abort();
572 break;
573 }
574
28ab034a
JG
575 lttng_channel_set_blocking_timeout(channel, uchan->attr.u.s.blocking_timeout);
576 lttng_channel_set_monitor_timer_interval(channel, uchan->monitor_timer_interval);
999af9c1
JR
577
578 ret = channel;
cd9adb8b 579 channel = nullptr;
999af9c1
JR
580
581end:
582 lttng_channel_destroy(channel);
583 return ret;
584}
This page took 0.118668 seconds and 4 git commands to generate.