]>
Commit | Line | Data |
---|---|---|
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 | |
ef6e34ee DE |
27 | #include "state.h" |
28 | ||
eab15c1e | 29 | #define LXC_CMD_DATA_MAX (MAXPATHLEN * 2) |
ef6e34ee DE |
30 | |
31 | /* https://developer.gnome.org/glib/2.28/glib-Type-Conversion-Macros.html */ | |
eab15c1e CB |
32 | #define INT_TO_PTR(n) ((void *)(long)(n)) |
33 | #define PTR_TO_INT(p) ((int)(long)(p)) | |
ef6e34ee DE |
34 | |
35 | typedef enum { | |
36 | LXC_CMD_CONSOLE, | |
b5159817 | 37 | LXC_CMD_CONSOLE_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, |
ef6e34ee DE |
47 | LXC_CMD_MAX, |
48 | } lxc_cmd_t; | |
96fa1ff0 | 49 | |
ef6e34ee DE |
50 | struct lxc_cmd_req { |
51 | lxc_cmd_t cmd; | |
52 | int datalen; | |
53 | const void *data; | |
96fa1ff0 MN |
54 | }; |
55 | ||
ef6e34ee | 56 | struct lxc_cmd_rsp { |
96fa1ff0 | 57 | int ret; /* 0 on success, -errno on failure */ |
ef6e34ee DE |
58 | int datalen; |
59 | void *data; | |
96fa1ff0 MN |
60 | }; |
61 | ||
ef6e34ee DE |
62 | struct lxc_cmd_rr { |
63 | struct lxc_cmd_req req; | |
64 | struct lxc_cmd_rsp rsp; | |
96fa1ff0 MN |
65 | }; |
66 | ||
ef6e34ee | 67 | struct lxc_cmd_console_rsp_data { |
0115f8fd | 68 | int masterfd; |
ef6e34ee DE |
69 | int ttynum; |
70 | }; | |
724e753c | 71 | |
b5159817 | 72 | extern int lxc_cmd_console_winch(const char *name, const char *lxcpath); |
ef6e34ee DE |
73 | extern int lxc_cmd_console(const char *name, int *ttynum, int *fd, |
74 | const char *lxcpath); | |
b98f7d6e SH |
75 | /* |
76 | * Get the 'real' cgroup path (as seen in /proc/self/cgroup) for a container | |
77 | * for a particular subsystem | |
78 | */ | |
79 | extern char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath, | |
80 | const char *subsystem); | |
ef6e34ee DE |
81 | extern int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath); |
82 | extern char *lxc_cmd_get_config_item(const char *name, const char *item, const char *lxcpath); | |
88556fd7 ÇO |
83 | extern char *lxc_cmd_get_name(const char *hashed_sock); |
84 | extern char *lxc_cmd_get_lxcpath(const char *hashed_sock); | |
ef6e34ee | 85 | extern pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath); |
dbc9832d | 86 | extern int lxc_cmd_get_state(const char *name, const char *lxcpath); |
ef6e34ee | 87 | extern int lxc_cmd_stop(const char *name, const char *lxcpath); |
54446942 CB |
88 | extern int lxc_cmd_add_state_client(const char *name, const char *lxcpath, |
89 | lxc_state_t states[MAX_STATE]); | |
43eb6f29 | 90 | |
724e753c MN |
91 | struct lxc_epoll_descr; |
92 | struct lxc_handler; | |
93 | ||
ef6e34ee | 94 | extern int lxc_cmd_init(const char *name, struct lxc_handler *handler, |
13f5be62 | 95 | const char *lxcpath); |
ef6e34ee | 96 | extern int lxc_cmd_mainloop_add(const char *name, struct lxc_epoll_descr *descr, |
724e753c | 97 | struct lxc_handler *handler); |
b494d2dd | 98 | extern int lxc_try_cmd(const char *name, const char *lxcpath); |
724e753c | 99 | |
ef6e34ee | 100 | #endif /* __commands_h */ |