]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/commands.h
spelling: keepdata
[mirror_lxc.git] / src / lxc / commands.h
1 /*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2009
5 *
6 * Authors:
7 * Daniel Lezcano <daniel.lezcano at free.fr>
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
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef __LXC_COMMANDS_H
25 #define __LXC_COMMANDS_H
26
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <unistd.h>
30
31 #include "lxccontainer.h"
32 #include "macro.h"
33 #include "state.h"
34
35 typedef enum {
36 LXC_CMD_CONSOLE,
37 LXC_CMD_TERMINAL_WINCH,
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_GET_NAME,
45 LXC_CMD_GET_LXCPATH,
46 LXC_CMD_ADD_STATE_CLIENT,
47 LXC_CMD_CONSOLE_LOG,
48 LXC_CMD_SERVE_STATE_CLIENTS,
49 LXC_CMD_MAX,
50 } lxc_cmd_t;
51
52 struct lxc_cmd_req {
53 lxc_cmd_t cmd;
54 int datalen;
55 const void *data;
56 };
57
58 struct lxc_cmd_rsp {
59 int ret; /* 0 on success, -errno on failure */
60 int datalen;
61 void *data;
62 };
63
64 struct lxc_cmd_rr {
65 struct lxc_cmd_req req;
66 struct lxc_cmd_rsp rsp;
67 };
68
69 struct lxc_cmd_console_rsp_data {
70 int masterfd;
71 int ttynum;
72 };
73
74 struct lxc_cmd_console_log {
75 bool clear;
76 bool read;
77 uint64_t read_max;
78 bool write_logfile;
79
80 };
81
82 extern int lxc_cmd_terminal_winch(const char *name, const char *lxcpath);
83 extern int lxc_cmd_console(const char *name, int *ttynum, int *fd,
84 const char *lxcpath);
85 /*
86 * Get the 'real' cgroup path (as seen in /proc/self/cgroup) for a container
87 * for a particular subsystem
88 */
89 extern char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath,
90 const char *subsystem);
91 extern int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath);
92 extern char *lxc_cmd_get_config_item(const char *name, const char *item, const char *lxcpath);
93 extern char *lxc_cmd_get_name(const char *hashed_sock);
94 extern char *lxc_cmd_get_lxcpath(const char *hashed_sock);
95 extern pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath);
96 extern int lxc_cmd_get_state(const char *name, const char *lxcpath);
97 extern int lxc_cmd_stop(const char *name, const char *lxcpath);
98
99 /* lxc_cmd_add_state_client Register a new state client fd in the container's
100 * in-memory handler.
101 *
102 * @param[in] name Name of container to connect to.
103 * @param[in] lxcpath The lxcpath in which the container is running.
104 * @param[in] states The states to wait for.
105 * @param[out] state_client_fd The state client fd from which the state can be
106 * received.
107 * @return Return < 0 on error
108 * == MAX_STATE when state needs to retrieved
109 * via socket fd
110 * < MAX_STATE current container state
111 */
112 extern int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
113 lxc_state_t states[MAX_STATE],
114 int *state_client_fd);
115 extern int lxc_cmd_serve_state_clients(const char *name, const char *lxcpath,
116 lxc_state_t state);
117
118 struct lxc_epoll_descr;
119 struct lxc_handler;
120
121 extern int lxc_cmd_init(const char *name, const char *lxcpath, const char *suffix);
122 extern int lxc_cmd_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
123 struct lxc_handler *handler);
124 extern int lxc_try_cmd(const char *name, const char *lxcpath);
125 extern int lxc_cmd_console_log(const char *name, const char *lxcpath,
126 struct lxc_console_log *log);
127
128 #endif /* __commands_h */