LXC
/home/tamuki/work32/lxc-git_20140217/build/src/lxc/lxccontainer.h
Go to the documentation of this file.
00001 
00023 #ifndef __LXC_CONTAINER_H
00024 #define __LXC_CONTAINER_H
00025 #include <malloc.h>
00026 #include <semaphore.h>
00027 #include <stdbool.h>
00028 #include <stdlib.h>
00029 #include <stdint.h>
00030 
00031 #include <lxc/attach_options.h>
00032 
00033 #ifdef  __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 #define LXC_CLONE_KEEPNAME        (1 << 0) 
00038 #define LXC_CLONE_KEEPMACADDR     (1 << 1) 
00039 #define LXC_CLONE_SNAPSHOT        (1 << 2) 
00040 #define LXC_CLONE_KEEPBDEVTYPE    (1 << 3) 
00041 #define LXC_CLONE_MAYBE_SNAPSHOT  (1 << 4) 
00042 #define LXC_CLONE_MAXFLAGS        (1 << 5) 
00043 #define LXC_CREATE_QUIET          (1 << 0) 
00044 #define LXC_CREATE_MAXFLAGS       (1 << 1) 
00046 struct bdev_specs;
00047 
00048 struct lxc_snapshot;
00049 
00050 struct lxc_lock;
00051 
00055 struct lxc_container {
00056     // private fields
00061     char *name;
00062 
00067     char *configfile;
00068 
00073     char *pidfile;
00074 
00079     struct lxc_lock *slock;
00080 
00085     struct lxc_lock *privlock;
00086 
00092     int numthreads;
00093 
00100     struct lxc_conf *lxc_conf;
00101 
00102     // public fields
00104     char *error_string;
00105 
00107     int error_num;
00108 
00110     bool daemonize;
00111 
00113     char *config_path;
00114 
00122     bool (*is_defined)(struct lxc_container *c);
00123 
00133     const char *(*state)(struct lxc_container *c);
00134 
00142     bool (*is_running)(struct lxc_container *c);
00143 
00151     bool (*freeze)(struct lxc_container *c);
00152 
00160     bool (*unfreeze)(struct lxc_container *c);
00161 
00170     pid_t (*init_pid)(struct lxc_container *c);
00171 
00181     bool (*load_config)(struct lxc_container *c, const char *alt_file);
00182 
00192     bool (*start)(struct lxc_container *c, int useinit, char * const argv[]);
00193 
00207     bool (*startl)(struct lxc_container *c, int useinit, ...);
00208 
00216     bool (*stop)(struct lxc_container *c);
00217 
00227     bool (*want_daemonize)(struct lxc_container *c, bool state);
00228 
00239     bool (*want_close_all_fds)(struct lxc_container *c, bool state);
00240 
00250     char *(*config_file_name)(struct lxc_container *c);
00251 
00264     bool (*wait)(struct lxc_container *c, const char *state, int timeout);
00265 
00275     bool (*set_config_item)(struct lxc_container *c, const char *key, const char *value);
00276 
00286     bool (*destroy)(struct lxc_container *c);
00287 
00296     bool (*save_config)(struct lxc_container *c, const char *alt_file);
00297 
00315     bool (*create)(struct lxc_container *c, const char *t, const char *bdevtype,
00316             struct bdev_specs *specs, int flags, char *const argv[]);
00317 
00338     bool (*createl)(struct lxc_container *c, const char *t, const char *bdevtype,
00339             struct bdev_specs *specs, int flags, ...);
00340 
00349     bool (*rename)(struct lxc_container *c, const char *newname);
00350 
00358     bool (*reboot)(struct lxc_container *c);
00359 
00370     bool (*shutdown)(struct lxc_container *c, int timeout);
00371 
00377     void (*clear_config)(struct lxc_container *c);
00378 
00389     bool (*clear_config_item)(struct lxc_container *c, const char *key);
00390 
00409     int (*get_config_item)(struct lxc_container *c, const char *key, char *retv, int inlen);
00410 
00411 
00422     char* (*get_running_config_item)(struct lxc_container *c, const char *key);
00423 
00445     int (*get_keys)(struct lxc_container *c, const char *key, char *retv, int inlen);
00446 
00457     char** (*get_interfaces)(struct lxc_container *c);
00458 
00473     char** (*get_ips)(struct lxc_container *c, const char* interface, const char* family, int scope);
00474 
00490     int (*get_cgroup_item)(struct lxc_container *c, const char *subsys, char *retv, int inlen);
00491 
00501     bool (*set_cgroup_item)(struct lxc_container *c, const char *subsys, const char *value);
00502 
00519     const char *(*get_config_path)(struct lxc_container *c);
00520 
00530     bool (*set_config_path)(struct lxc_container *c, const char *path);
00531 
00562     struct lxc_container *(*clone)(struct lxc_container *c, const char *newname,
00563             const char *lxcpath, int flags, const char *bdevtype,
00564             const char *bdevdata, uint64_t newsize, char **hookargs);
00565 
00584     int (*console_getfd)(struct lxc_container *c, int *ttynum, int *masterfd);
00585 
00603     int (*console)(struct lxc_container *c, int ttynum,
00604             int stdinfd, int stdoutfd, int stderrfd, int escape);
00605 
00619     int (*attach)(struct lxc_container *c, lxc_attach_exec_t exec_function,
00620             void *exec_payload, lxc_attach_options_t *options, pid_t *attached_process);
00621 
00633     int (*attach_run_wait)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char * const argv[]);
00634 
00646     int (*attach_run_waitl)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char *arg, ...);
00647 
00664     int (*snapshot)(struct lxc_container *c, const char *commentfile);
00665 
00678     int (*snapshot_list)(struct lxc_container *c, struct lxc_snapshot **snapshots);
00679 
00697     bool (*snapshot_restore)(struct lxc_container *c, const char *snapname, const char *newname);
00698 
00707     bool (*snapshot_destroy)(struct lxc_container *c, const char *snapname);
00708 
00718     bool (*may_control)(struct lxc_container *c);
00719 
00730     bool (*add_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path);
00731 
00742     bool (*remove_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path);
00743 };
00744 
00748 struct lxc_snapshot {
00749     char *name; 
00750     char *comment_pathname; 
00751     char *timestamp; 
00752     char *lxcpath; 
00758     void (*free)(struct lxc_snapshot *s);
00759 };
00760 
00769 struct lxc_container *lxc_container_new(const char *name, const char *configpath);
00770 
00778 int lxc_container_get(struct lxc_container *c);
00779 
00790 int lxc_container_put(struct lxc_container *c);
00791 
00804 int lxc_get_wait_states(const char **states);
00805 
00813 const char *lxc_get_global_config_item(const char *key);
00814 
00821 const char *lxc_get_version(void);
00822 
00834 int list_defined_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
00835 
00850 int list_active_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
00851 
00866 int list_all_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
00867 
00868 #ifdef  __cplusplus
00869 }
00870 #endif
00871 
00872 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines