]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/commands.h
seccomp: SECCOMP_RET_USER_NOTIF support
[mirror_lxc.git] / src / lxc / commands.h
CommitLineData
96fa1ff0
MN
1/*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2009
5 *
6 * Authors:
9afe19d6 7 * Daniel Lezcano <daniel.lezcano at free.fr>
96fa1ff0
MN
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
250b1eec 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
96fa1ff0 22 */
ef6e34ee 23
f1a4a029
ÇO
24#ifndef __LXC_COMMANDS_H
25#define __LXC_COMMANDS_H
96fa1ff0 26
92e35018 27#include <stdio.h>
92e35018 28#include <sys/types.h>
9b8d4c58 29#include <unistd.h>
92e35018 30
191d43cc 31#include "lxccontainer.h"
9b8d4c58
CB
32#include "macro.h"
33#include "state.h"
ef6e34ee
DE
34
35typedef enum {
36 LXC_CMD_CONSOLE,
8ccbbf94 37 LXC_CMD_TERMINAL_WINCH,
ef6e34ee
DE
38 LXC_CMD_STOP,
39 LXC_CMD_GET_STATE,
40 LXC_CMD_GET_INIT_PID,
41 LXC_CMD_GET_CLONE_FLAGS,
42 LXC_CMD_GET_CGROUP,
43 LXC_CMD_GET_CONFIG_ITEM,
88556fd7
ÇO
44 LXC_CMD_GET_NAME,
45 LXC_CMD_GET_LXCPATH,
54446942 46 LXC_CMD_ADD_STATE_CLIENT,
191d43cc 47 LXC_CMD_CONSOLE_LOG,
974a8aba 48 LXC_CMD_SERVE_STATE_CLIENTS,
cdb2a47f 49 LXC_CMD_SECCOMP_NOTIFY_ADD_LISTENER,
ef6e34ee
DE
50 LXC_CMD_MAX,
51} lxc_cmd_t;
96fa1ff0 52
ef6e34ee
DE
53struct lxc_cmd_req {
54 lxc_cmd_t cmd;
55 int datalen;
56 const void *data;
96fa1ff0
MN
57};
58
ef6e34ee 59struct lxc_cmd_rsp {
96fa1ff0 60 int ret; /* 0 on success, -errno on failure */
ef6e34ee
DE
61 int datalen;
62 void *data;
96fa1ff0
MN
63};
64
ef6e34ee
DE
65struct lxc_cmd_rr {
66 struct lxc_cmd_req req;
67 struct lxc_cmd_rsp rsp;
96fa1ff0
MN
68};
69
ef6e34ee 70struct lxc_cmd_console_rsp_data {
0115f8fd 71 int masterfd;
ef6e34ee
DE
72 int ttynum;
73};
724e753c 74
191d43cc
CB
75struct lxc_cmd_console_log {
76 bool clear;
77 bool read;
78 uint64_t read_max;
63b74cda 79 bool write_logfile;
191d43cc
CB
80
81};
82
8ccbbf94 83extern int lxc_cmd_terminal_winch(const char *name, const char *lxcpath);
ef6e34ee
DE
84extern int lxc_cmd_console(const char *name, int *ttynum, int *fd,
85 const char *lxcpath);
b98f7d6e
SH
86/*
87 * Get the 'real' cgroup path (as seen in /proc/self/cgroup) for a container
88 * for a particular subsystem
89 */
90extern char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath,
91 const char *subsystem);
ef6e34ee
DE
92extern int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath);
93extern char *lxc_cmd_get_config_item(const char *name, const char *item, const char *lxcpath);
88556fd7
ÇO
94extern char *lxc_cmd_get_name(const char *hashed_sock);
95extern char *lxc_cmd_get_lxcpath(const char *hashed_sock);
ef6e34ee 96extern pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath);
dbc9832d 97extern int lxc_cmd_get_state(const char *name, const char *lxcpath);
ef6e34ee 98extern int lxc_cmd_stop(const char *name, const char *lxcpath);
92e35018
CB
99
100/* lxc_cmd_add_state_client Register a new state client fd in the container's
101 * in-memory handler.
102 *
103 * @param[in] name Name of container to connect to.
104 * @param[in] lxcpath The lxcpath in which the container is running.
105 * @param[in] states The states to wait for.
106 * @param[out] state_client_fd The state client fd from which the state can be
107 * received.
108 * @return Return < 0 on error
109 * == MAX_STATE when state needs to retrieved
110 * via socket fd
111 * < MAX_STATE current container state
112 */
54446942 113extern int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
92e35018
CB
114 lxc_state_t states[MAX_STATE],
115 int *state_client_fd);
974a8aba
CB
116extern int lxc_cmd_serve_state_clients(const char *name, const char *lxcpath,
117 lxc_state_t state);
43eb6f29 118
724e753c
MN
119struct lxc_epoll_descr;
120struct lxc_handler;
121
9dfa4041 122extern int lxc_cmd_init(const char *name, const char *lxcpath, const char *suffix);
ef6e34ee 123extern int lxc_cmd_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
724e753c 124 struct lxc_handler *handler);
b494d2dd 125extern int lxc_try_cmd(const char *name, const char *lxcpath);
191d43cc
CB
126extern int lxc_cmd_console_log(const char *name, const char *lxcpath,
127 struct lxc_console_log *log);
cdb2a47f
CB
128extern int lxc_cmd_seccomp_notify_add_listener(const char *name,
129 const char *lxcpath,
130 int fd,
131 /* unused */ unsigned int command,
132 /* unused */ unsigned int flags);
0d9cd9c3 133
ef6e34ee 134#endif /* __commands_h */