2014-07-09 01:17:05 +08:00
|
|
|
/*
|
|
|
|
NOTE: The API is in flux and mainly not implemented. Proceed with caution until further notice.
|
|
|
|
*/
|
2014-02-19 08:56:11 +08:00
|
|
|
package libcontainer
|
|
|
|
|
2014-07-09 01:17:05 +08:00
|
|
|
// A libcontainer container object.
|
2014-05-17 15:06:29 +08:00
|
|
|
//
|
2014-07-09 01:17:05 +08:00
|
|
|
// Each container is thread-safe within the same process. Since a container can
|
|
|
|
// be destroyed by a separate process, any function may return that the container
|
|
|
|
// was not found.
|
|
|
|
type Container interface {
|
|
|
|
// Returns the ID of this container.
|
|
|
|
ID() string
|
|
|
|
|
|
|
|
// Returns the current run state of the container.
|
|
|
|
//
|
|
|
|
// Errors: container no longer exists,
|
|
|
|
// system error.
|
|
|
|
RunState() (*RunState, error)
|
|
|
|
|
|
|
|
// Returns the current config of the container.
|
|
|
|
Config() *Config
|
|
|
|
|
|
|
|
// Destroys the container after killing all running processes.
|
|
|
|
//
|
|
|
|
// Any event registrations are removed before the container is destroyed.
|
|
|
|
// No error is returned if the container is already destroyed.
|
|
|
|
//
|
|
|
|
// Errors: system error.
|
|
|
|
Destroy() error
|
|
|
|
|
|
|
|
// Returns the PIDs inside this container. The PIDs are in the namespace of the calling process.
|
|
|
|
//
|
|
|
|
// Errors: container no longer exists,
|
|
|
|
// system error.
|
|
|
|
//
|
|
|
|
// Some of the returned PIDs may no longer refer to processes in the Container, unless
|
|
|
|
// the Container state is PAUSED in which case every PID in the slice is valid.
|
|
|
|
Processes() ([]int, error)
|
|
|
|
|
|
|
|
// Returns statistics for the container.
|
|
|
|
//
|
|
|
|
// Errors: container no longer exists,
|
|
|
|
// system error.
|
|
|
|
Stats() (*ContainerStats, error)
|
|
|
|
|
|
|
|
// If the Container state is RUNNING or PAUSING, sets the Container state to PAUSING and pauses
|
|
|
|
// the execution of any user processes. Asynchronously, when the container finished being paused the
|
|
|
|
// state is changed to PAUSED.
|
|
|
|
// If the Container state is PAUSED, do nothing.
|
|
|
|
//
|
|
|
|
// Errors: container no longer exists,
|
|
|
|
// system error.
|
|
|
|
Pause() error
|
|
|
|
|
|
|
|
// If the Container state is PAUSED, resumes the execution of any user processes in the
|
|
|
|
// Container before setting the Container state to RUNNING.
|
|
|
|
// If the Container state is RUNNING, do nothing.
|
|
|
|
//
|
|
|
|
// Errors: container no longer exists,
|
|
|
|
// system error.
|
|
|
|
Resume() error
|
2014-05-17 15:06:29 +08:00
|
|
|
}
|