[−][src]Struct lxc_sys2::lxc_container
An LXC container.
version: 1.0.0
Fields
error_string: *mut c_char
Human-readable string representing last error
version: 1.0.0
error_num: c_int
Last error number
version: 1.0.0
daemonize: bool
Whether container wishes to be daemonized
version: 1.0.0
config_path: *mut c_char
Full path to configuration file
version: 1.0.0
is_defined: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Determine if /var/lib/lxc/$name/config
exists.
Parameters
c Container.
Returns
true
if container is defined, else false
.
version: 1.0.0
state: unsafe extern "C" fn(c: *mut lxc_container) -> *const c_char
Determine state of container.
Parameters
c Container.
Returns
Static upper-case string representing state of container.
note: Returned string must not be freed.
version: 1.0.0
is_running: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Determine if container is running.
Parameters
c Container.
Returns
true
on success, else false
.
version: 1.0.0
freeze: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Freeze running container.
Parameters
c Container.
Returns
true
on success, else false
.
version: 1.0.0
unfeeze: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Thaw a frozen container.
Parameters
c Container.
Returns
true
on success, else false
.
version: 1.0.0
init_pid: unsafe extern "C" fn(c: *mut lxc_container) -> c_uint
Determine process ID of the containers init process.
Parameters
c Container.
Returns
pid of init process as seen from outside the container.
version: 1.0.0
load_config: unsafe extern "C" fn(c: *mut lxc_container, alt_file: *const c_char) -> bool
Load the specified configuration for the container.
Parameters
c Container.
alt_file Full path to alternate configuration file, or
NULL
to use the default configuration file.
Returns
true
on success, else false
.
version: 1.0.0
start: unsafe extern "C" fn(c: *mut lxc_container, useinit: c_int, argv: *const *mut c_char)
Start the container.
Parameters
c Container.
useinit Use lxcinit rather than /sbin/init
.
argv Array of arguments to pass to init.
Returns
true
on success, else false
.
version: 1.0.0
start1: unsafe extern "C" fn(c: *mut lxc_container, useinit: c_int, ...) -> bool
Start the container (list variant).
Parameters
c Container.
useinit Use lxcinit rather than /sbin/init
.
... Command-line to pass to init (must end in NULL
).
Returns
true
on success, else false
.
note: Identical to start except that that the init arguments are specified via a list rather than an array of pointers.
version: 1.0.0
stop: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Stop the container.
Parameters
c Container.
Returns
true
on success, else false
.
version: 1.0.0
want_daemonize: unsafe extern "C" fn(c: *mut lxc_container, state: bool) -> bool
Determine if the container wants to run disconnected from the terminal.
Parameters
c Container.
state Value for the daemonize bit (0 or 1).
Returns
true
if container wants to be daemonised, else false
.
version: 1.0.0
want_close_all_fds: unsafe extern "C" fn(c: *mut lxc_container, state: bool) -> bool
Determine whether container wishes all file descriptors to be closed on startup.
Parameters
c Container.
state Value for the close_all_fds bit (0 or 1).
Returns
true
if container wants all file descriptors closed,
else false
.
version: 1.0.0
config_file_name: unsafe extern "C" fn(c: *mut lxc_container) -> *mut c_char
Return current config file name.
Parameters
c Container.
Returns
config file name, or NULL
on error.
note: The result is allocated, so the caller must free the result.
version: 1.0.0
wait: unsafe extern "C" fn(c: *mut lxc_container, state: *const c_char, timeout: c_int) -> bool
Wait for container to reach a particular state.
Parameters
c Container.
state State to wait for.
timeout Timeout in seconds.
Returns
true
if state reached within timeout,
else false
.
note: A timeout
of -1
means wait forever. A timeout
of 0
means do not wait.
version: 1.0.0
set_config_item: unsafe extern "C" fn(c: *mut lxc_container, key: *const c_char, value: *const c_char) -> bool
Set a key/value configuration option.
Parameters
c Container.
key Name of option to set.
value Value of name
to set.
Returns
true
on success, else false
.
version: 1.0.0
destroy: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Delete the container.
Parameters
c Container.
Returns
true
on success, else false
.
note: Container must be stopped and have no dependent snapshots.
version: 1.0.0
save_config: unsafe extern "C" fn(c: *mut lxc_container, alt_file: *const c_char) -> bool
Save configuaration to a file.
Parameters
c Container.
alt_file Full path to file to save configuration in.
Returns
true
on success, else false
.
version: 1.0.0
create: unsafe extern "C" fn(c: *mut lxc_container, t: *const c_char, bdevtype: *const c_char, specs: *mut bdev_specs, flags: c_int, argv: *const *mut c_char) -> bool
Create a container.
Parameters
c Container (with lxcpath, name and a starting configuration set).
t Template to execute to instantiate the root filesystem and adjust the configuration.
bdevtype Backing store type to use (if NULL,
dir
will be used).
specs Additional parameters for the backing store (for example LVM volume group to use).
flags LXC_CREATE_*
options (currently only
LXC_CREATE_QUIET is supported).
argv Arguments to pass to the template, terminated by NULL
(if no arguments are required, just pass NULL)
.
Returns
true
on success, else false
.
version: 1.0.0
createl: unsafe extern "C" fn(c: *mut lxc_container, t: *const c_char, bdevtype: *const c_char, specs: *mut bdev_specs, flags: c_int, ...) -> bool
Create a container (list variant).
Parameters
c Container (with lxcpath, name and a starting configuration set).
t Template to execute to instantiate the root filesystem and adjust the configuration.
bdevtype Backing store type to use (if NULL,
dir
will be used).
specs Additional parameters for the backing store (for example LVM volume group to use).
flags LXC_CREATE_*
options (currently only
LXC_CREATE_QUIET is supported).
... Command-line to pass to init (must end in NULL)
.
Returns
true
on success, else false
.
note: Identical to create except that the template arguments are specified as a list rather than an array of pointers.
version: 1.0.0
rename: unsafe extern "C" fn(c: *mut lxc_container, newname: *const c_char) -> bool
Rename a container
Parameters
c Container.
newname New name to be used for the container.
Returns
true
on success, else false
.
version: 1.0.0
reboot: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Request the container reboot by sending it SIGINT
.
Parameters
c Container.
Returns
true
if reboot request successful, else false
.
version: 1.0.0
shutdown: unsafe extern "C" fn(c: *mut lxc_container, timeout: c_int) -> bool
Request the container shutdown by sending it SIGPWR
.
Parameters
c Container.
timeout Seconds to wait before returning false. (-1 to wait forever, 0 to avoid waiting).
Returns
true
if the container was shutdown successfully, else false
.
version: 1.0.0
clear_config: unsafe extern "C" fn(c: *mut lxc_container) -> c_void
Completely clear the containers in-memory configuration.
Parameters
c Container.
version: 1.0.0
clear_config_item: unsafe extern "C" fn(c: *mut lxc_container, key: *const c_char) -> bool
Clear a configuration item.
Parameters
c Container.
key Name of option to clear.
Returns
true
on success, else false
.
note: Analog of set_config_item.
version: 1.0.0
get_config_item: unsafe extern "C" fn(c: *mut lxc_container, key: *const c_char, retv: *mut c_char, inlen: c_int) -> c_int
Retrieve the value of a config item.
Parameters
c Container.
key Name of option to get.
retv out Caller-allocated buffer to write value of key
into (or
NULL
to determine length of value).
inlen Length of retv
(may be zero).
Returns
Length of config items value, or < 0 on error.
note: The caller can (and should) determine how large a buffer to
allocate for retv
by initially passing its value as NULL
and
considering the return value. This function can then be called again
passing a newly-allocated suitably-sized buffer.
note: If retv
is NULL, inlen
is ignored.
note: If inlen
is smaller than required, the value written to
retv
will be truncated.
version: 1.0.0
get_running_config_item: unsafe extern "C" fn(c: *mut lxc_container, key: *const c_char) -> *mut c_char
Retrieve the value of a config item from running container.
Parameters
c Container.
key Name of option to get.
Returns
the item or NULL on error.
note: Returned string must be freed by the caller.
version: 1.0.0
get_keys: unsafe extern "C" fn(c: *mut lxc_container, key: *const c_char, retv: *mut c_char, inlen: c_int) -> c_int
Retrieve a list of config item keys given a key prefix
Parameters
c Container.
key Name of option to get.
retv out Caller-allocated buffer to write list of keys to (or
NULL
to determine overall length of keys list).
inlen Length of retv
(may be zero).
Returns
Length of keys list, or < 0 on error.
note: The list values written to retv
are separated by a newline
character ('\n').
note: The caller can (and should) determine how large a buffer to
allocate for retv
by initially passing its value as NULL
and
considering the return value. This function can then be called again
passing a newly-allocated suitably-sized buffer.
note: If retv
is NULL, inlen
is ignored.
note: If inlen
is smaller than required, the value written to
retv
will be truncated.
version: 1.0.0
get_interfaces: unsafe extern "C" fn(c: *mut lxc_container) -> *mut *mut c_char
Obtain a list of network interfaces.
Parameters
c Container.
Returns
Newly-allocated array of network interfaces, or NULL
on error.
note: The returned array is allocated, so the caller must free it.
note: The returned array is terminated with a NULL
entry.
version: 1.0.0
get_ips: unsafe extern "C" fn(c: *mut lxc_container, interface: *const c_char, family: *const c_char, scope: c_int) -> *mut *mut c_char
Determine the list of container IP addresses.
Parameters
c Container.
interface Network interface name to consider.
family Network family (for example "inet", "inet6").
scope IPv6 scope id (ignored if family
is not "inet6").
Returns
Newly-allocated array of network interfaces, or NULL
on error.
note: The returned array is allocated, so the caller must free it.
note: The returned array is terminated with a NULL
entry.
version: 1.0.0
get_cgroup_item: unsafe extern "C" fn(c: *mut lxc_container, subsys: *const c_char, retv: *mut c_char, inlen: c_int) -> c_int
Retrieve the specified cgroup subsystem value for the container.
Parameters
c Container.
subsys cgroup subsystem to retrieve.
retv out Caller-allocated buffer to write value of subsys
into
(or NULL
to determine length of value).
inlen length of retv
(may be zero).
Returns
Length of subsys
value, or < 0 on error.
note: If retv
is NULL,
inlen
is ignored.
note: If inlen
is smaller than required, the value written to
retv
will be truncated.
version: 1.0.0
set_cgroup_item: unsafe extern "C" fn(c: *mut lxc_container, subsys: *const c_char, value: *const c_char) -> bool
Set the specified cgroup subsystem value for the container.
Parameters
c Container.
subsys cgroup subsystem to consider.
value Value to set for subsys
.
Returns
true
on success, else false
.
version: 1.0.0
get_config_path: unsafe extern "C" fn(c: *mut lxc_container) -> *const c_char
Determine full path to the containers configuration file.
Each container can have a custom configuration path. However
by default it will be set to either the LXCPATH
configure
variable, or the lxcpath value in the LXC_GLOBAL_CONF
configuration
file (i.e. /etc/lxc/lxc
.conf).
The value for a specific container can be changed using
set_config_path. There is no other way
to specify this in general at the moment.
Parameters
c Container.
Returns
Static string representing full path to configuration file.
note: Returned string must not be freed.
version: 1.0.0
set_config_path: unsafe extern "C" fn(c: *mut lxc_container, path: *const c_char) -> bool
Set the full path to the containers configuration file.
Parameters
c Container.
path Full path to configuration file.
Returns
true
on success, else false
.
version: 1.0.0
clone: unsafe extern "C" fn(c: *mut lxc_container, newname: *const c_char, lxcpath: *const c_char, flags: c_int, bdevtype: *const c_char, bdevdata: *const c_char, newsize: u64, hookargs: *mut *mut c_char) -> *mut lxc_container
Copy a stopped container.
Parameters
c Original container.
newname New name for the container. If NULL,
the same name is
used and a new lxcpath MUST be specified.
lxcpath lxcpath in which to create the new container. If NULL,
the original container's lxcpath will be used.
flags Additional LXC_CLONE*
flags to change the cloning behaviour:
bdevtype Optionally force the cloned bdevtype to a specified plugin. By default the original is used (subject to snapshot requirements).
bdevdata Information about how to create the new storage (i.e. fstype and fsdata).
newsize In case of a block device backing store, an optional size.
If 0,
the original backing store's size will be used if possible. Note
this only applies to the rootfs. For any other filesystems, the original
size will be duplicated.
hookargs Additional arguments to pass to the clone hook script.
Returns
Newly-allocated copy of container c,
or NULL
on error.
note: If devtype was not specified, and flags
contains
LXC_CLONE_SNAPSHOT then use the
native bdevtype
if possible, else use an overlayfs.
version: 1.0.0
console_getfd: unsafe extern "C" fn(c: *mut lxc_container, ttynum: *mut c_int, masterfd: *mut c_int) -> c_int
Allocate a console tty for the container.
Parameters
c Container.
ttynum in,out Terminal number to attempt to allocate, or -1
to
allocate the first available tty.
masterfd out File descriptor refering to the master side of the pty.
Returns
tty file descriptor number on success, or -1
on failure.
note: On successful return, ttynum
will contain the tty number
that was allocated.
note: The returned file descriptor is used to keep the tty allocated. The caller should call close(2) on the returned file descriptor when no longer required so that it may be allocated by another caller.
version: 1.0.0
console: unsafe extern "C" fn(c: *mut lxc_container, ttynum: c_int, stdinfd: c_int, stdoutfd: c_int, stderrfd: c_int, escape: c_int) -> c_int
Allocate and run a console tty.
Parameters
c Container.
ttynum Terminal number to attempt to allocate, -1
to
allocate the first available tty or 0
to allocate the
console.
stdinfd File descriptor to read input from.
stdoutfd File descriptor to write output to.
stderrfd File descriptor to write error output to.
escape The escape character (1 == 'a', 2 == 'b', ...).
Returns
0
on success, -1
on failure.
note: This function will not return until the console has been exited by the user.
version: 1.0.0
attach: unsafe extern "C" fn(c: *mut lxc_container, exec_function: lxc_attach_exec_t, exec_payload: *mut c_void, options: lxc_attach_options_t, attached_process: c_uint) -> c_int
Create a sub-process attached to a container and run a function inside it.
Parameters
c Container.
exec_function Function to run.
exec_payload Data to pass to exec_function
.
options See lxc_attach_options_t.
attached_process out Process ID of process running inside
container c
that is running exec_function
.
Returns
0
on success, -1
on error.
version: 1.0.0
attach_run_wait: unsafe extern "C" fn(c: *mut lxc_container, options: lxc_attach_options_t, program: *const c_char, argv: *const *const c_char) -> c_int
Run a program inside a container and wait for it to exit.
Parameters
c Container.
options See lxc_attach_options_t.
program Full path inside container of program to run.
argv Array of arguments to pass to program
.
Returns
waitpid(2)
status of exited process that ran program,
or -1
on
error.
version: 1.0.0
attach_run_wait1: unsafe extern "C" fn(c: *mut lxc_container, options: lxc_attach_options_t, program: *const c_char, ...) -> c_int
Run a program inside a container and wait for it to exit (list variant).
Parameters
c Container.
options See lxc_attach_options_t.
program Full path inside container of program to run.
... Command-line to pass to program
(must end in NULL)
.
Returns
waitpid(2)
status of exited process that ran program,
or -1
on
error.
version: 1.0.0
snapshot: unsafe extern "C" fn(c: *mut lxc_container, commentfile: *const c_char) -> c_int
Create a container snapshot.
Assuming default paths, snapshots will be created as
/var/lib/lxc/<c>/snaps/snap<n>
where <c>
represents the container
name and <n>
represents the zero-based snapshot number.
Parameters
c Container.
commentfile Full path to file containing a description of the snapshot.
Returns
-1 on error, or zero-based snapshot number.
note: commentfile
may be NULL
but this is discouraged.
version: 1.0.0
snapshot_list: unsafe extern "C" fn(c: *mut lxc_container, snapshots: *mut *mut lxc_snapshot) -> c_int
Obtain a list of container snapshots.
Parameters
c Container.
snapshots Dynamically-allocated Array of lxc_snapshot's.
Returns
Number of snapshots.
note: The array returned in snapshots
is allocated, so the caller
must free it.
note: To free an individual snapshot as returned in \p
snapshots, call the snapshots free
function (see
src/tests/snapshot.c
for an example).
version: 1.0.0
snapshot_restore: unsafe extern "C" fn(c: *mut lxc_container, snapname: *const c_char, newname: *const c_char) -> bool
Create a new container based on a snapshot.
The restored container will be a copy (not snapshot) of the snapshot, and restored in the lxcpath of the original container.
Parameters
c Container.
snapname Name of snapshot.
newname Name to be used for the restored snapshot.
Returns
true
on success, else false
.
warning: If newname
is the same as the current container
name, the container will be destroyed. However, this will
fail if the snapshot is overlay-based, since the snapshots
will pin the original container.
note: As an example, if the container exists as /var/lib/lxc/c1,
snapname might be 'snap0'
(representing /var/lib/lxcsnaps/c1/snap0)
.
If newname
is c2,
then snap0
will be copied to /var/lib/lxc/c2
.
version: 1.0.0
snapshot_destroy: unsafe extern "C" fn(c: *mut lxc_container, snapname: *const c_char) -> bool
Destroy the specified snapshot.
Parameters
c Container.
snapname Name of snapshot.
Returns
true
on success, else false
.
version: 1.0.0
may_control: unsafe extern "C" fn(c: *mut lxc_container) -> bool
Determine if the caller may control the container.
Parameters
c Container.
Returns
false
if there is a control socket for the container monitor and the
caller may not access it, otherwise returns true
.
version: 1.0.0
add_device_node: unsafe extern "C" fn(c: *mut lxc_container, src_path: *const c_char, dest_path: *const c_char) -> bool
Add specified device to the container.
Parameters
c Container.
src_path Full path of the device.
dest_path Alternate path in the container (or NULL
to use
src_path)
.
Returns
true
on success, else false
.
version: 1.0.0
remove_device_node: unsafe extern "C" fn(c: *mut lxc_container, src_path: *const c_char, dest_path: *const c_char) -> bool
Remove specified device from the container.
Parameters
c Container.
src_path Full path of the device.
dest_path Alternate path in the container (or NULL
to use
src_path)
.
Returns
true
on success, else false
.
version: 1.0.0
Trait Implementations
impl Clone for lxc_container
[src]
fn clone(&self) -> lxc_container
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for lxc_container
[src]
impl Debug for lxc_container
[src]
Auto Trait Implementations
impl RefUnwindSafe for lxc_container
impl !Send for lxc_container
impl !Sync for lxc_container
impl Unpin for lxc_container
impl UnwindSafe for lxc_container
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,