]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/lxccontainer.h
Merge the liblxc API work by Serge Hallyn.
[mirror_lxc.git] / src / lxc / lxccontainer.h
CommitLineData
72d0e1cb
SG
1#include "lxclock.h"
2#include <stdlib.h>
3#include <malloc.h>
4
5#include <stdbool.h>
6
7struct lxc_container {
8 // private fields
9 char *name;
10 char *configfile;
11 sem_t *slock;
12 sem_t *privlock;
13 int numthreads; /* protected by privlock. */
14 struct lxc_conf *lxc_conf; // maybe we'll just want the whole lxc_handler?
15
16 // public fields
17 char *error_string;
18 int error_num;
19 int daemonize;
20
21#define LXCDIR "/var/lib/lxc"
22 bool (*is_defined)(struct lxc_container *c); // did /var/lib/lxc/$name/config exist
23 const char *(*state)(struct lxc_container *c);
24 bool (*is_running)(struct lxc_container *c); // true so long as defined and not stopped
25 bool (*freeze)(struct lxc_container *c);
26 bool (*unfreeze)(struct lxc_container *c);
27 pid_t (*init_pid)(struct lxc_container *c);
28 bool (*load_config)(struct lxc_container *c, char *alt_file);
29 /* The '...' is the command line. If provided, it must be ended with a NULL */
30 bool (*start)(struct lxc_container *c, int useinit, char ** argv);
31 bool (*startl)(struct lxc_container *c, int useinit, ...);
32 bool (*stop)(struct lxc_container *c);
33 void (*want_daemonize)(struct lxc_container *c);
34 // Return current config file name. The result is strdup()d, so free the result.
35 char *(*config_file_name)(struct lxc_container *c);
36 // for wait, timeout == -1 means wait forever, timeout == 0 means don't wait.
37 // otherwise timeout is seconds to wait.
38 bool (*wait)(struct lxc_container *c, char *state, int timeout);
39 bool (*set_config_item)(struct lxc_container *c, char *key, char *value);
40 bool (*destroy)(struct lxc_container *c);
41 bool (*save_config)(struct lxc_container *c, char *alt_file);
42 bool (*create)(struct lxc_container *c, char *t, char **argv);
43 bool (*createl)(struct lxc_container *c, char *t, ...);
44 /* send SIGPWR. if timeout is not 0 or -1, do a hard stop after timeout seconds */
45 bool (*shutdown)(struct lxc_container *c, int timeout);
46 /* clear all network or capability items in the in-memory configuration */
47 bool (*clear_config_item)(struct lxc_container *c, char *key);
48 /* print a config item to a in-memory string allocated by the caller. Return
49 * the length which was our would be printed. */
50 int (*get_config_item)(struct lxc_container *c, char *key, char *retv, int inlen);
51 int (*get_keys)(struct lxc_container *c, char *key, char *retv, int inlen);
52
53#if 0
54 bool (*commit_cgroups)(struct lxc_container *c);
55 bool (*reread_cgroups)(struct lxc_container *c);
56 // question with clone: how do we handle non-standard config file in orig?
57 struct lxc_container (*clone)(struct container *c);
58 int (*ns_attach)(struct lxc_container *c, int ns_mask);
59 // we'll need some plumbing to support lxc-console
60#endif
61};
62
63struct lxc_container *lxc_container_new(char *name);
64int lxc_container_get(struct lxc_container *c);
65int lxc_container_put(struct lxc_container *c);
66int lxc_get_wait_states(char **states);
67
68#if 0
69char ** lxc_get_valid_keys();
70char ** lxc_get_valid_values(char *key);
71#endif