LXC
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Enumerations | Functions
lxccontainer.h File Reference
#include <malloc.h>
#include <semaphore.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <lxc/attach_options.h>
Include dependency graph for lxccontainer.h:

Go to the source code of this file.

Data Structures

struct  lxc_container
 
struct  lxc_snapshot
 An LXC container snapshot. More...
 
struct  bdev_specs
 Specifications for how to create a new backing store. More...
 
struct  migrate_opts
 Options for the migrate API call. More...
 
struct  lxc_log
 

Macros

#define LXC_CLONE_KEEPNAME   (1 << 0)
 
#define LXC_CLONE_KEEPMACADDR   (1 << 1)
 
#define LXC_CLONE_SNAPSHOT   (1 << 2)
 
#define LXC_CLONE_KEEPBDEVTYPE   (1 << 3)
 
#define LXC_CLONE_MAYBE_SNAPSHOT   (1 << 4)
 
#define LXC_CLONE_MAXFLAGS   (1 << 5)
 
#define LXC_CREATE_QUIET   (1 << 0)
 
#define LXC_CREATE_MAXFLAGS   (1 << 1)
 

Enumerations

enum  { MIGRATE_PRE_DUMP, MIGRATE_DUMP, MIGRATE_RESTORE }
 Commands for the migrate API call.
 

Functions

struct lxc_containerlxc_container_new (const char *name, const char *configpath)
 Create a new container. More...
 
int lxc_container_get (struct lxc_container *c)
 Add a reference to the specified container. More...
 
int lxc_container_put (struct lxc_container *c)
 Drop a reference to the specified container. More...
 
int lxc_get_wait_states (const char **states)
 Obtain a list of all container states. More...
 
const char * lxc_get_global_config_item (const char *key)
 Get the value for a global config key. More...
 
const char * lxc_get_version (void)
 Determine version of LXC. More...
 
int list_defined_containers (const char *lxcpath, char ***names, struct lxc_container ***cret)
 Get a list of defined containers in a lxcpath. More...
 
int list_active_containers (const char *lxcpath, char ***names, struct lxc_container ***cret)
 Get a list of active containers for a given lxcpath. More...
 
int list_all_containers (const char *lxcpath, char ***names, struct lxc_container ***cret)
 Get a complete list of all containers for a given lxcpath. More...
 
int lxc_log_init (struct lxc_log *log)
 Initialize the log. More...
 
void lxc_log_close (void)
 Close log file.
 
bool lxc_config_item_is_supported (const char *key)
 Check if the configuration item is supported by this LXC instance. More...
 

Detailed Description

liblxcapi

Copyright © 2012 Serge Hallyn serge.nosp@m..hal.nosp@m.lyn@u.nosp@m.bunt.nosp@m.u.com. Copyright © 2012 Canonical Ltd.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Macro Definition Documentation

#define LXC_CLONE_KEEPBDEVTYPE   (1 << 3)

Use the same bdev type

#define LXC_CLONE_KEEPMACADDR   (1 << 1)

Do not change the MAC address on network interfaces

#define LXC_CLONE_KEEPNAME   (1 << 0)

Do not edit the rootfs to change the hostname

#define LXC_CLONE_MAXFLAGS   (1 << 5)

Number of LXC_CLONE_* flags

#define LXC_CLONE_MAYBE_SNAPSHOT   (1 << 4)

Snapshot only if bdev supports it, else copy

#define LXC_CLONE_SNAPSHOT   (1 << 2)

Snapshot the original filesystem(s)

#define LXC_CREATE_MAXFLAGS   (1 << 1)

Number of LXC_CREATE* flags

#define LXC_CREATE_QUIET   (1 << 0)

Redirect stdin to /dev/zero and stdout and stderr to /dev/null

Function Documentation

int list_active_containers ( const char *  lxcpath,
char ***  names,
struct lxc_container ***  cret 
)

Get a list of active containers for a given lxcpath.

Parameters
lxcpathFull LXCPATH path to consider.
[out]namesDynamically-allocated array of container names.
[out]cretDynamically-allocated list of containers.
Returns
Number of containers found, or -1 on error.
Note
Some of the containers may not be "defined".
Values returned in cret are sorted by container name.
names and cret may both (or either) be specified as NULL.
names and cret must be freed by the caller.
int list_all_containers ( const char *  lxcpath,
char ***  names,
struct lxc_container ***  cret 
)

Get a complete list of all containers for a given lxcpath.

Parameters
lxcpathFull LXCPATH path to consider.
[out]namesDynamically-allocated array of container name.
[out]cretDynamically-allocated list of containers.
Returns
Number of containers, or -1 on error.
Note
Some of the containers may not be "defined".
Values returned in cret are sorted by container name.
names and cret may both (or either) be specified as NULL.
names and cret must be freed by the caller.
int list_defined_containers ( const char *  lxcpath,
char ***  names,
struct lxc_container ***  cret 
)

Get a list of defined containers in a lxcpath.

Parameters
lxcpathlxcpath under which to look.
namesIf not NULL, then a list of container names will be returned here.
cretIf not NULL, then a list of lxc_containers will be returned here.
Returns
Number of containers found, or -1 on error.
Note
Values returned in cret are sorted by container name.
bool lxc_config_item_is_supported ( const char *  key)

Check if the configuration item is supported by this LXC instance.

Parameters
keyConfiguration item to check for.
int lxc_container_get ( struct lxc_container c)

Add a reference to the specified container.

Parameters
cContainer.
Returns
true on success, false on error.
struct lxc_container* lxc_container_new ( const char *  name,
const char *  configpath 
)

Create a new container.

Parameters
nameName to use for container.
configpathFull path to configuration file to use.
Returns
Newly-allocated container, or NULL on error.
int lxc_container_put ( struct lxc_container c)

Drop a reference to the specified container.

Parameters
cContainer.
Returns
0 on success, 1 if reference was successfully dropped and container has been freed, and -1 on error.
Warning
If 1 is returned, c is no longer valid.
const char* lxc_get_global_config_item ( const char *  key)

Get the value for a global config key.

Parameters
keyThe name of the config key
Returns
String representing the current value for the key.
const char* lxc_get_version ( void  )

Determine version of LXC.

Returns
Static string representing version of LXC in use.
Note
Returned string must not be freed.
int lxc_get_wait_states ( const char **  states)

Obtain a list of all container states.

Parameters
[out]statesCaller-allocated array to hold all states (may be NULL).
Returns
Number of container states.
Note
Passing NULL for states allows the caller to first calculate how many states there are before calling the function again, the second time providing a suitably-sized array to store the static string pointers in.
The states array should be freed by the caller, but not the strings the elements point to.
int lxc_log_init ( struct lxc_log log)

Initialize the log.

Parameters
loglxc log configuration.