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