LXC
/home/tamuki/work64/lxc-git_20131226/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 "attach_options.h"
00026 #include <malloc.h>
00027 #include <semaphore.h>
00028 #include <stdbool.h>
00029 #include <stdlib.h>
00030 
00031 #ifdef  __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 #define LXC_CLONE_KEEPNAME        (1 << 0) 
00036 #define LXC_CLONE_KEEPMACADDR     (1 << 1) 
00037 #define LXC_CLONE_SNAPSHOT        (1 << 2) 
00038 #define LXC_CLONE_MAXFLAGS        (1 << 3) 
00039 #define LXC_CREATE_QUIET          (1 << 0) 
00040 #define LXC_CREATE_MAXFLAGS       (1 << 1) 
00042 struct bdev_specs;
00043 
00044 struct lxc_snapshot;
00045 
00046 struct lxc_lock;
00047 
00051 struct lxc_container {
00052     // private fields
00057     char *name;
00058 
00063     char *configfile;
00064 
00069     struct lxc_lock *slock;
00070 
00075     struct lxc_lock *privlock;
00076 
00082     int numthreads;
00083 
00090     struct lxc_conf *lxc_conf;
00091 
00092     // public fields
00094     char *error_string;
00095 
00097     int error_num;
00098 
00100     bool daemonize;
00101 
00103     char *config_path;
00104 
00112     bool (*is_defined)(struct lxc_container *c);
00113 
00123     const char *(*state)(struct lxc_container *c);
00124 
00132     bool (*is_running)(struct lxc_container *c);
00133 
00141     bool (*freeze)(struct lxc_container *c);
00142 
00150     bool (*unfreeze)(struct lxc_container *c);
00151 
00160     pid_t (*init_pid)(struct lxc_container *c);
00161 
00171     bool (*load_config)(struct lxc_container *c, const char *alt_file);
00172 
00182     bool (*start)(struct lxc_container *c, int useinit, char * const argv[]);
00183 
00197     bool (*startl)(struct lxc_container *c, int useinit, ...);
00198 
00206     bool (*stop)(struct lxc_container *c);
00207 
00217     bool (*want_daemonize)(struct lxc_container *c, bool state);
00218 
00229     bool (*want_close_all_fds)(struct lxc_container *c, bool state);
00230 
00240     char *(*config_file_name)(struct lxc_container *c);
00241 
00254     bool (*wait)(struct lxc_container *c, const char *state, int timeout);
00255 
00265     bool (*set_config_item)(struct lxc_container *c, const char *key, const char *value);
00266 
00276     bool (*destroy)(struct lxc_container *c);
00277 
00286     bool (*save_config)(struct lxc_container *c, const char *alt_file);
00287 
00305     bool (*create)(struct lxc_container *c, const char *t, const char *bdevtype,
00306             struct bdev_specs *specs, int flags, char *const argv[]);
00307 
00328     bool (*createl)(struct lxc_container *c, const char *t, const char *bdevtype,
00329             struct bdev_specs *specs, int flags, ...);
00330 
00339     bool (*rename)(struct lxc_container *c, const char *newname);
00340 
00348     bool (*reboot)(struct lxc_container *c);
00349 
00362     bool (*shutdown)(struct lxc_container *c, int timeout);
00363 
00369     void (*clear_config)(struct lxc_container *c);
00370 
00381     bool (*clear_config_item)(struct lxc_container *c, const char *key);
00382 
00401     int (*get_config_item)(struct lxc_container *c, const char *key, char *retv, int inlen);
00402 
00424     int (*get_keys)(struct lxc_container *c, const char *key, char *retv, int inlen);
00425 
00436     char** (*get_interfaces)(struct lxc_container *c);
00437 
00452     char** (*get_ips)(struct lxc_container *c, const char* interface, const char* family, int scope);
00453 
00469     int (*get_cgroup_item)(struct lxc_container *c, const char *subsys, char *retv, int inlen);
00470 
00480     bool (*set_cgroup_item)(struct lxc_container *c, const char *subsys, const char *value);
00481 
00498     const char *(*get_config_path)(struct lxc_container *c);
00499 
00509     bool (*set_config_path)(struct lxc_container *c, const char *path);
00510 
00541     struct lxc_container *(*clone)(struct lxc_container *c, const char *newname,
00542             const char *lxcpath, int flags, const char *bdevtype,
00543             const char *bdevdata, unsigned long newsize, char **hookargs);
00544 
00563     int (*console_getfd)(struct lxc_container *c, int *ttynum, int *masterfd);
00564 
00582     int (*console)(struct lxc_container *c, int ttynum,
00583             int stdinfd, int stdoutfd, int stderrfd, int escape);
00584 
00598     int (*attach)(struct lxc_container *c, lxc_attach_exec_t exec_function,
00599             void *exec_payload, lxc_attach_options_t *options, pid_t *attached_process);
00600 
00612     int (*attach_run_wait)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char * const argv[]);
00613 
00625     int (*attach_run_waitl)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char *arg, ...);
00626 
00643     int (*snapshot)(struct lxc_container *c, const char *commentfile);
00644 
00657     int (*snapshot_list)(struct lxc_container *c, struct lxc_snapshot **snapshots);
00658 
00676     bool (*snapshot_restore)(struct lxc_container *c, const char *snapname, const char *newname);
00677 
00686     bool (*snapshot_destroy)(struct lxc_container *c, const char *snapname);
00687 
00697     bool (*may_control)(struct lxc_container *c);
00698 
00709     bool (*add_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path);
00710 
00721     bool (*remove_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path);
00722 };
00723 
00727 struct lxc_snapshot {
00728     char *name; 
00729     char *comment_pathname; 
00730     char *timestamp; 
00731     char *lxcpath; 
00737     void (*free)(struct lxc_snapshot *s);
00738 };
00739 
00748 struct lxc_container *lxc_container_new(const char *name, const char *configpath);
00749 
00757 int lxc_container_get(struct lxc_container *c);
00758 
00769 int lxc_container_put(struct lxc_container *c);
00770 
00783 int lxc_get_wait_states(const char **states);
00784 
00793 const char *lxc_get_default_config_path(void);
00794 
00803 const char *lxc_get_default_lvm_vg(void);
00804 
00813 const char *lxc_get_default_lvm_thin_pool(void);
00814 
00823 const char *lxc_get_default_zfs_root(void);
00824 
00831 const char *lxc_get_version(void);
00832 
00844 int list_defined_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
00845 
00860 int list_active_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
00861 
00876 int list_all_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
00877 
00878 #ifdef  __cplusplus
00879 }
00880 #endif
00881 
00882 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines