3 #ifndef __LXC_CONTAINER_H
4 #define __LXC_CONTAINER_H
12 #include <lxc/attach_options.h>
18 #define LXC_CLONE_KEEPNAME (1 << 0)
19 #define LXC_CLONE_KEEPMACADDR (1 << 1)
20 #define LXC_CLONE_SNAPSHOT (1 << 2)
21 #define LXC_CLONE_KEEPBDEVTYPE (1 << 3)
22 #define LXC_CLONE_MAYBE_SNAPSHOT (1 << 4)
23 #define LXC_CLONE_MAXFLAGS (1 << 5)
24 #define LXC_CLONE_ALLOW_RUNNING (1 << 6)
25 #define LXC_CREATE_QUIET (1 << 0)
26 #define LXC_CREATE_MAXFLAGS (1 << 1)
27 #define LXC_MOUNT_API_V1 1
29 #define LXC_IMAGE_OCI_KEY "lxc.imagetype.oci"
57 uint64_t pids_current;
59 uint64_t cpu_use_nanos;
60 uint64_t cpu_use_user;
75 uint64_t inactive_file_total;
130 struct lxc_conf *lxc_conf;
167 unsigned int start_timeout;
375 struct bdev_specs *specs,
int flags,
char *
const argv[]);
532 char** (*get_ips)(
struct lxc_container *c,
const char* interface,
const char* family,
int scope);
622 const char *lxcpath,
int flags,
const char *bdevtype,
623 const char *bdevdata, uint64_t newsize,
char **hookargs);
663 int stdinfd,
int stdoutfd,
int stderrfd,
int escape);
906 const char *target,
const char *filesystemtype,
907 unsigned long mountflags,
const void *data,
914 unsigned long mountflags,
struct lxc_mount *mnt);
964 bool (*set_terminal_winch)(
struct lxc_container *c,
unsigned int height,
unsigned int width);
966 bool (*set_exec_terminal_winch)(
struct lxc_container *c,
const char *suffix,
unsigned int height,
unsigned int width);
1088 MIGRATE_FEATURE_CHECK,
1094 #define FEATURE_MEM_TRACK (1ULL << 0)
1095 #define FEATURE_LAZY_PAGES (1ULL << 1)
1107 char *pageserver_address;
1108 char *pageserver_port;
1115 bool preserves_inodes;
1120 char *action_script;
1126 bool disable_skip_in_flight;
1132 uint64_t ghost_limit;
1139 uint64_t features_to_check;
1172 struct lxc_container *lxc_container_new(
const char *name,
const char *configpath);
1184 struct lxc_container *lxc_container_without_config_new(
const char *name,
const char *configpath);
1219 int lxc_get_wait_states(
const char **states);
1228 const char *lxc_get_global_config_item(
const char *key);
1236 const char *lxc_get_version(
void);
1249 int list_defined_containers(
const char *lxcpath,
char ***names,
struct lxc_container ***cret);
1265 int list_active_containers(
const char *lxcpath,
char ***names,
struct lxc_container ***cret);
1281 int list_all_containers(
const char *lxcpath,
char ***names,
struct lxc_container ***cret);
1285 const char *lxcpath;
1297 int lxc_log_init(
struct lxc_log *log);
1302 void lxc_log_close(
void);
1309 bool lxc_config_item_is_supported(
const char *key);
1316 bool lxc_has_api_extension(
const char *extension);
bool(* snapshot_destroy_all)(struct lxc_container *c)
Destroy all the container's snapshot.
Definition: lxccontainer.h:867
int(* get_keys)(struct lxc_container *c, const char *key, char *retv, int inlen)
Retrieve a list of config item keys given a key prefix.
Definition: lxccontainer.h:504
bool(* is_defined)(struct lxc_container *c)
Determine if /var/lib/lxc/$name/config exists.
Definition: lxccontainer.h:182
bool(* wait)(struct lxc_container *c, const char *state, int timeout)
Wait for container to reach a particular state.
Definition: lxccontainer.h:323
An LXC container snapshot.
Definition: lxccontainer.h:1046
Definition: lxccontainer.h:85
void(* clear_config)(struct lxc_container *c)
Completely clear the containers in-memory configuration.
Definition: lxccontainer.h:436
bool(* may_control)(struct lxc_container *c)
Determine if the caller may control the container.
Definition: lxccontainer.h:777
int(* snapshot)(struct lxc_container *c, const char *commentfile)
Create a container snapshot.
Definition: lxccontainer.h:723
bool(* createl)(struct lxc_container *c, const char *t, const char *bdevtype, struct bdev_specs *specs, int flags,...)
Create a container (list variant).
Definition: lxccontainer.h:397
int(* snapshot_list)(struct lxc_container *c, struct lxc_snapshot **snapshots)
Obtain a list of container snapshots.
Definition: lxccontainer.h:737
void(* free)(struct lxc_snapshot *s)
De-allocate the snapshot.
Definition: lxccontainer.h:1056
int(* mount)(struct lxc_container *c, const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data, struct lxc_mount *mnt)
Mount the host's path source onto the container's path target.
Definition: lxccontainer.h:905
char * lxcpath
Definition: lxccontainer.h:1050
bool(* destroy)(struct lxc_container *c)
Delete the container.
Definition: lxccontainer.h:345
bool(* want_disable_pty)(struct lxc_container *c, bool state)
Change whether the container wants to create pty or pipes from the console log.
Definition: lxccontainer.h:977
bool(* set_config_item)(struct lxc_container *c, const char *key, const char *value)
Set a key/value configuration option.
Definition: lxccontainer.h:334
int(* get_cgroup_item)(struct lxc_container *c, const char *subsys, char *retv, int inlen)
Retrieve the specified cgroup subsystem value for the container.
Definition: lxccontainer.h:549
int(* migrate)(struct lxc_container *c, unsigned int cmd, struct migrate_opts *opts, unsigned int size)
An API call to perform various migration operations.
Definition: lxccontainer.h:879
Definition: lxccontainer.h:1142
char * zfsroot
Definition: lxccontainer.h:1067
char * name
Definition: lxccontainer.h:1047
int(* attach_run_waitl)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char *arg,...)
Run a program inside a container and wait for it to exit (list variant).
Definition: lxccontainer.h:705
char * thinpool
Definition: lxccontainer.h:1072
bool(* create)(struct lxc_container *c, const char *t, const char *bdevtype, struct bdev_specs *specs, int flags, char *const argv[])
Create a container.
Definition: lxccontainer.h:374
int(* get_config_item)(struct lxc_container *c, const char *key, char *retv, int inlen)
Retrieve the value of a config item.
Definition: lxccontainer.h:468
Definition: lxccontainer.h:41
bool(* reboot2)(struct lxc_container *c, int timeout)
Request the container reboot by sending it SIGINT.
Definition: lxccontainer.h:900
bool(* start)(struct lxc_container *c, int useinit, char *const argv[])
Start the container.
Definition: lxccontainer.h:252
int(* attach_run_wait)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char *const argv[])
Run a program inside a container and wait for it to exit.
Definition: lxccontainer.h:692
char * rbdname
Definition: lxccontainer.h:1076
Definition: lxccontainer.h:45
bool(* set_container_info_file)(struct lxc_container *c, const char *info_file)
An API call to set the path of info file.
Definition: lxccontainer.h:942
bool(* add_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path)
Add specified device to the container.
Definition: lxccontainer.h:789
char * fstype
Definition: lxccontainer.h:1064
bool(* snapshot_restore)(struct lxc_container *c, const char *snapname, const char *newname)
Create a new container based on a snapshot.
Definition: lxccontainer.h:756
bool open_stdin
Definition: lxccontainer.h:154
Specifications for how to create a new backing store.
Definition: lxccontainer.h:1063
bool(* attach_interface)(struct lxc_container *c, const char *dev, const char *dst_dev)
Add specified netdev to the container.
Definition: lxccontainer.h:813
char * dir
Definition: lxccontainer.h:1074
bool(* is_running)(struct lxc_container *c)
Determine if container is running.
Definition: lxccontainer.h:202
bool disable_pty
Definition: lxccontainer.h:151
bool(* checkpoint)(struct lxc_container *c, char *directory, bool stop, bool verbose)
Checkpoint a container.
Definition: lxccontainer.h:835
bool(* destroy_with_snapshots)(struct lxc_container *c)
Delete the container and all its snapshots.
Definition: lxccontainer.h:858
bool(* add_terminal_fifos)(struct lxc_container *c, const char *in, const char *out, const char *err)
An API call to add the path of terminal fifos.
Definition: lxccontainer.h:962
bool(* save_config)(struct lxc_container *c, const char *alt_file)
Save configuration to a file.
Definition: lxccontainer.h:355
bool(* set_terminal_init_fifos)(struct lxc_container *c, const char *in, const char *out, const char *err)
An API call to change the path of the console default fifos.
Definition: lxccontainer.h:952
char * comment_pathname
Definition: lxccontainer.h:1048
bool(* shutdown)(struct lxc_container *c, int timeout)
Request the container shutdown by sending it SIGPWR.
Definition: lxccontainer.h:429
bool(* rename)(struct lxc_container *c, const char *newname)
Rename a container.
Definition: lxccontainer.h:408
char * lv
Definition: lxccontainer.h:1071
int(* console_getfd)(struct lxc_container *c, int *ttynum, int *masterfd)
Allocate a console tty for the container.
Definition: lxccontainer.h:643
bool(* want_daemonize)(struct lxc_container *c, bool state)
Change whether the container wants to run disconnected from the terminal.
Definition: lxccontainer.h:287
bool(* set_start_timeout)(struct lxc_container *c, unsigned int start_timeout)
An API call to set start timeout.
Definition: lxccontainer.h:1019
Definition: attach_options.h:61
bool(* load_config)(struct lxc_container *c, const char *alt_file)
Load the specified configuration for the container.
Definition: lxccontainer.h:241
bool(* set_oci_type)(struct lxc_container *c, bool image_type_oci)
An API call to set oci type.
Definition: lxccontainer.h:1029
bool(* remove_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path)
Remove specified device from the container.
Definition: lxccontainer.h:801
bool(* clear_config_item)(struct lxc_container *c, const char *key)
Clear a configuration item.
Definition: lxccontainer.h:448
char * vg
Definition: lxccontainer.h:1070
bool(* unfreeze)(struct lxc_container *c)
Thaw a frozen container.
Definition: lxccontainer.h:220
bool(* stop)(struct lxc_container *c)
Stop the container.
Definition: lxccontainer.h:276
bool(* detach_interface)(struct lxc_container *c, const char *dev, const char *dst_dev)
Remove specified netdev from the container.
Definition: lxccontainer.h:823
char * error_string
Definition: lxccontainer.h:134
pid_t(* init_pid)(struct lxc_container *c)
Determine process ID of the containers init process.
Definition: lxccontainer.h:230
uint64_t fssize
Definition: lxccontainer.h:1065
int error_num
Definition: lxccontainer.h:137
bool(* set_cgroup_item)(struct lxc_container *c, const char *subsys, const char *value)
Set the specified cgroup subsystem value for the container.
Definition: lxccontainer.h:560
bool(* restore)(struct lxc_container *c, char *directory, bool verbose)
Restore a container from a checkpoint.
Definition: lxccontainer.h:847
bool(* get_container_pids)(struct lxc_container *c, pid_t **pids, size_t *pids_len)
An API call to get container pids.
Definition: lxccontainer.h:1009
bool(* reboot)(struct lxc_container *c)
Request the container reboot by sending it SIGINT.
Definition: lxccontainer.h:417
Definition: lxccontainer.h:51
int(* umount)(struct lxc_container *c, const char *target, unsigned long mountflags, struct lxc_mount *mnt)
Unmount the container's path target.
Definition: lxccontainer.h:913
const char *(* state)(struct lxc_container *c)
Determine state of container.
Definition: lxccontainer.h:193
char * rbdpool
Definition: lxccontainer.h:1077
int(* init_pidfd)(struct lxc_container *c)
Retrieve a pidfd for the container's init process.
Definition: lxccontainer.h:932
Options for the migrate API call.
Definition: lxccontainer.h:1100
int(* seccomp_notify_fd)(struct lxc_container *c)
Retrieve a file descriptor for the container's seccomp filter.
Definition: lxccontainer.h:923
char * config_path
Definition: lxccontainer.h:143
bool(* freeze)(struct lxc_container *c)
Freeze running container.
Definition: lxccontainer.h:211
bool daemonize
Definition: lxccontainer.h:140
bool(* want_close_all_fds)(struct lxc_container *c, bool state)
Change whether the container wishes all file descriptors to be closed on startup.
Definition: lxccontainer.h:298
bool(* snapshot_destroy)(struct lxc_container *c, const char *snapname)
Destroy the specified snapshot.
Definition: lxccontainer.h:766
Definition: lxccontainer.h:1283
int(* console)(struct lxc_container *c, int ttynum, int stdinfd, int stdoutfd, int stderrfd, int escape)
Allocate and run a console tty.
Definition: lxccontainer.h:662
int(* console_log)(struct lxc_container *c, struct lxc_console_log *log)
Query the console log of a container.
Definition: lxccontainer.h:889
bool(* get_container_metrics)(struct lxc_container *c, struct lxc_container_metrics *metrics)
An API call to set start timeout.
Definition: lxccontainer.h:1039
bool(* set_config_path)(struct lxc_container *c, const char *path)
Set the full path to the containers configuration file.
Definition: lxccontainer.h:589
bool(* startl)(struct lxc_container *c, int useinit,...)
Start the container (list variant).
Definition: lxccontainer.h:267
bool(* want_open_stdin)(struct lxc_container *c, bool state)
Change whether the container wants to keep stdin active for parent process of container.
Definition: lxccontainer.h:988
int(* attach)(struct lxc_container *c, lxc_attach_exec_t exec_function, void *exec_payload, lxc_attach_options_t *options, pid_t *attached_process)
Create a sub-process attached to a container and run a function inside it.
Definition: lxccontainer.h:678
bool(* clean_container_resource)(struct lxc_container *c, pid_t pid)
An API call to clean resources of container.
Definition: lxccontainer.h:998
char * timestamp
Definition: lxccontainer.h:1049