]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/lxc.h
storage/dir: cleanup mount code
[mirror_lxc.git] / src / lxc / lxc.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #ifndef __LXC_LXC_H
4 #define __LXC_LXC_H
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <sys/select.h>
13 #include <sys/types.h>
14
15 #include "compiler.h"
16 #include "memory_utils.h"
17 #include "state.h"
18
19 struct lxc_msg;
20 struct lxc_conf;
21 struct lxc_arguments;
22 struct lxc_handler;
23
24 /**
25 Following code is for liblxc.
26
27 lxc/lxc.h will contain exports of liblxc
28 **/
29
30 /*
31 * Start the specified command inside a system container
32 * @argv : an array of char * corresponding to the command line
33 * @conf : configuration
34 * @daemonize : whether or not the container is daemonized
35 * Returns 0 on success, < 0 otherwise
36 */
37 __hidden extern int lxc_start(char *const argv[], struct lxc_handler *handler, const char *lxcpath,
38 bool daemonize, int *error_num);
39
40 /*
41 * Start the specified command inside an application container
42 * @name : the name of the container
43 * @argv : an array of char * corresponding to the command line
44 * @quiet : if != 0 then lxc-init won't produce any output
45 * @conf : configuration
46 * @daemonize : whether or not the container is daemonized
47 * Returns 0 on success, < 0 otherwise
48 */
49 __hidden extern int lxc_execute(const char *name, char *const argv[], int quiet,
50 struct lxc_handler *handler, const char *lxcpath, bool daemonize,
51 int *error_num);
52
53 /*
54 * Close the fd associated with the monitoring
55 * @fd : the file descriptor provided by lxc_monitor_open
56 * Returns 0 on success, < 0 otherwise
57 */
58 __hidden extern int lxc_monitor_close(int fd);
59
60 /*
61 * Freeze all the tasks running inside the container <name>
62 * @name : the container name
63 * Returns 0 on success, < 0 otherwise
64 */
65 __hidden extern int lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath);
66
67 /*
68 * Unfreeze all previously frozen tasks.
69 * @name : the name of the container
70 * Return 0 on success, < 0 otherwise
71 */
72 __hidden extern int lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath);
73
74 /*
75 * Retrieve the container state
76 * @name : the name of the container
77 * Returns the state of the container on success, < 0 otherwise
78 */
79 __hidden extern lxc_state_t lxc_state(const char *name, const char *lxcpath);
80
81 /*
82 * Create and return a new lxccontainer struct.
83 */
84 extern struct lxc_container *lxc_container_new(const char *name, const char *configpath);
85
86 /*
87 * Returns 1 on success, 0 on failure.
88 */
89 extern int lxc_container_get(struct lxc_container *c);
90
91 /*
92 * Put a lxccontainer struct reference.
93 * Return -1 on error.
94 * Return 0 if this was not the last reference.
95 * If it is the last reference, free the lxccontainer and return 1.
96 */
97 extern int lxc_container_put(struct lxc_container *c);
98 static inline void put_lxc_container(struct lxc_container *c)
99 {
100 if (c)
101 lxc_container_put(c);
102 }
103 define_cleanup_function(struct lxc_container *, put_lxc_container);
104 #define __put_lxc_container call_cleaner(put_lxc_container)
105
106 /*
107 * Get a list of valid wait states.
108 * If states is NULL, simply return the number of states
109 */
110 extern int lxc_get_wait_states(const char **states);
111
112 /*
113 * Add a dependency to a container
114 */
115 __hidden extern int add_rdepend(struct lxc_conf *lxc_conf, char *rdepend);
116
117 /*
118 * Set a key/value configuration option. Requires that to take a lock on the
119 * in-memory config of the container.
120 */
121 __hidden extern int lxc_set_config_item_locked(struct lxc_conf *conf, const char *key, const char *v);
122
123 #ifdef __cplusplus
124 }
125 #endif
126
127 #endif /* __LXC_LXC_H */