case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL:
context_type_string = config_event_context_callstack_kernel;
break;
+ case LTTNG_KERNEL_CONTEXT_CGROUP_NS:
+ context_type_string = config_event_context_cgroup_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_IPC_NS:
+ context_type_string = config_event_context_ipc_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_MNT_NS:
+ context_type_string = config_event_context_mnt_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_NET_NS:
+ context_type_string = config_event_context_net_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_PID_NS:
+ context_type_string = config_event_context_pid_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_USER_NS:
+ context_type_string = config_event_context_user_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_UTS_NS:
+ context_type_string = config_event_context_uts_ns;
+ break;
+ case LTTNG_KERNEL_CONTEXT_UID:
+ context_type_string = config_event_context_uid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_EUID:
+ context_type_string = config_event_context_euid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_SUID:
+ context_type_string = config_event_context_suid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_GID:
+ context_type_string = config_event_context_gid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_EGID:
+ context_type_string = config_event_context_egid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_SGID:
+ context_type_string = config_event_context_sgid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_VUID:
+ context_type_string = config_event_context_vuid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_VEUID:
+ context_type_string = config_event_context_veuid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_VSUID:
+ context_type_string = config_event_context_vsuid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_VGID:
+ context_type_string = config_event_context_vgid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_VEGID:
+ context_type_string = config_event_context_vegid;
+ break;
+ case LTTNG_KERNEL_CONTEXT_VSGID:
+ context_type_string = config_event_context_vsgid;
+ break;
default:
context_type_string = NULL;
}
case LTTNG_UST_CONTEXT_APP_CONTEXT:
context_type_string = config_event_context_app;
break;
+ case LTTNG_UST_CONTEXT_CGROUP_NS:
+ context_type_string = config_event_context_cgroup_ns;
+ break;
+ case LTTNG_UST_CONTEXT_IPC_NS:
+ context_type_string = config_event_context_ipc_ns;
+ break;
+ case LTTNG_UST_CONTEXT_MNT_NS:
+ context_type_string = config_event_context_mnt_ns;
+ break;
+ case LTTNG_UST_CONTEXT_NET_NS:
+ context_type_string = config_event_context_net_ns;
+ break;
+ case LTTNG_UST_CONTEXT_PID_NS:
+ context_type_string = config_event_context_pid_ns;
+ break;
+ case LTTNG_UST_CONTEXT_USER_NS:
+ context_type_string = config_event_context_user_ns;
+ break;
+ case LTTNG_UST_CONTEXT_UTS_NS:
+ context_type_string = config_event_context_uts_ns;
+ break;
+ case LTTNG_UST_CONTEXT_VUID:
+ context_type_string = config_event_context_vuid;
+ break;
+ case LTTNG_UST_CONTEXT_VEUID:
+ context_type_string = config_event_context_veuid;
+ break;
+ case LTTNG_UST_CONTEXT_VSUID:
+ context_type_string = config_event_context_vsuid;
+ break;
+ case LTTNG_UST_CONTEXT_VGID:
+ context_type_string = config_event_context_vgid;
+ break;
+ case LTTNG_UST_CONTEXT_VEGID:
+ context_type_string = config_event_context_vegid;
+ break;
+ case LTTNG_UST_CONTEXT_VSGID:
+ context_type_string = config_event_context_vsgid;
+ break;
case LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER:
/*
* Error, should not be stored in the XML, perf contexts
{
int ret = 0;
const char *probe_name, *provider_name, *binary_path;
- struct lttng_userspace_probe_location *userspace_probe_location;
- struct lttng_userspace_probe_location_lookup_method *lookup_method;
+ const struct lttng_userspace_probe_location *userspace_probe_location;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method;
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
/* Get userspace probe location from the event. */
{
int ret = 0;
const char *function_name, *binary_path;
- struct lttng_userspace_probe_location *userspace_probe_location;
- struct lttng_userspace_probe_location_lookup_method *lookup_method;
+ const struct lttng_userspace_probe_location *userspace_probe_location;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method;
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
/* Get userspace probe location from the event. */
ret = config_writer_open_element(writer,
config_element_rotation_schedules);
+ if (ret) {
+ goto end;
+ }
if (session->rotate_timer_period) {
ret = save_session_rotation_schedule(writer,
LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC,
int save_session(struct ltt_session *session,
struct lttng_save_session_attr *attr, lttng_sock_cred *creds)
{
- int ret, fd;
- unsigned int file_opened = 0; /* Indicate if the file has been opened */
+ int ret, fd = -1;
char config_file_path[PATH_MAX];
size_t len;
struct config_writer *writer = NULL;
if (!session_access_ok(session,
LTTNG_SOCK_GET_UID_CRED(creds),
- LTTNG_SOCK_GET_GID_CRED(creds))) {
+ LTTNG_SOCK_GET_GID_CRED(creds)) || session->destroyed) {
ret = LTTNG_ERR_EPERM;
goto end;
}
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- file_opened = 1;
writer = config_writer_create(fd, 1);
if (!writer) {
}
if (ret) {
/* Delete file in case of error */
- if (file_opened && unlink(config_file_path)) {
+ if ((fd >= 0) && unlink(config_file_path)) {
PERROR("Unlinking XML session configuration.");
}
}
- if (file_opened) {
+ if (fd >= 0) {
ret = close(fd);
if (ret) {
PERROR("Closing XML session configuration");
session_lock(session);
ret = save_session(session, attr, creds);
session_unlock(session);
+ session_put(session);
if (ret) {
goto end;
}
struct ltt_session_list *list = session_get_list();
cds_list_for_each_entry(session, &list->head, list) {
+ if (!session_get(session)) {
+ continue;
+ }
session_lock(session);
ret = save_session(session, attr, creds);
session_unlock(session);
-
+ session_put(session);
/* Don't abort if we don't have the required permissions. */
if (ret && ret != LTTNG_ERR_EPERM) {
goto end;