2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "ltt-sessiond.h"
24 #include "libkernelctl.h"
25 #include "kernel-ctl.h"
29 * kernel_create_session
31 * Create a new kernel session using the command context session.
33 int kernel_create_session(struct command_ctx
*cmd_ctx
, int tracer_fd
)
36 struct ltt_kernel_session
*lks
;
38 /* Allocate a new kernel session */
39 lks
= malloc(sizeof(struct ltt_kernel_session
));
41 perror("kernel session malloc");
46 ret
= kernctl_create_session(tracer_fd
);
51 /* Assigning session fd and to the command context */
53 cmd_ctx
->session
->kernel_session
= lks
;
54 cmd_ctx
->session
->kern_session_count
++;
63 * kernel_create_channel
65 * Create a kernel channel within the kernel session.
67 int kernel_create_channel(struct command_ctx
*cmd_ctx
)
70 struct ltt_kernel_channel
*lkc
;
71 struct lttng_channel
*chan
;
73 lkc
= malloc(sizeof(struct ltt_kernel_channel
));
74 chan
= malloc(sizeof(struct lttng_channel
));
76 if (lkc
== NULL
|| chan
== NULL
) {
77 perror("kernel channel malloc");
82 chan
->overwrite
= DEFAULT_KERNEL_OVERWRITE
;
83 chan
->subbuf_size
= DEFAULT_KERNEL_SUBBUF_SIZE
;
84 chan
->num_subbuf
= DEFAULT_KERNEL_SUBBUF_NUM
;
85 chan
->switch_timer_interval
= DEFAULT_KERNEL_SWITCH_TIMER
;
86 chan
->read_timer_interval
= DEFAULT_KERNEL_READ_TIMER
;
88 ret
= kernctl_create_channel(cmd_ctx
->session
->kernel_session
->fd
, chan
);
95 CDS_INIT_LIST_HEAD(&lkc
->events_list
.head
);
97 cmd_ctx
->session
->kernel_session
->channel
= lkc
;