Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lxcpp::Guard Class Reference

Guard process used for container's init configuration and control. More...

#include <guard.hpp>

Classes

struct  ContainerData
 

Public Member Functions

 Guard (const std::string &socketPath)
 
 ~Guard ()
 
int execute ()
 

Private Member Functions

void onConnection (const cargo::ipc::PeerID &peerID, const cargo::ipc::FileDescriptor)
 Called each time a new connection is opened to the Guard's socket. More...
 
void onDisconnection (const cargo::ipc::PeerID &peerID, const cargo::ipc::FileDescriptor)
 Called each time a connection to host is lost. More...
 
void onInitExit (struct::signalfd_siginfo &sigInfo)
 Called when the init process exits. More...
 
bool onSetConfig (const cargo::ipc::PeerID, std::shared_ptr< ContainerConfig > &data, cargo::ipc::MethodResult::Pointer result)
 Called when synchronizing configuration with the host. More...
 
bool onGetConfig (const cargo::ipc::PeerID, std::shared_ptr< api::Void > &, cargo::ipc::MethodResult::Pointer result)
 Called when synchronizing configuration with the host. More...
 
bool onStart (const cargo::ipc::PeerID, std::shared_ptr< api::Void > &, cargo::ipc::MethodResult::Pointer result)
 Host -> Guard: Start init in a container described by the configuration. More...
 
bool onStop (const cargo::ipc::PeerID, std::shared_ptr< api::Void > &, cargo::ipc::MethodResult::Pointer result)
 Host -> Guard: Stop the init process and return its exit status. More...
 

Static Private Member Functions

static int startContainer (void *data)
 Setups the init process and executes the init. More...
 

Private Attributes

cargo::ipc::epoll::EventPoll mEventPoll
 
cargo::ipc::PeerID mPeerID
 
utils::SignalFD mSignalFD
 
std::unique_ptr
< cargo::ipc::Service
mService
 
std::shared_ptr< ContainerConfigmConfig
 

Detailed Description

Guard process used for container's init configuration and control.

Guard is a one thread process with a polling loop running till the init process exits. Therefore no synchronization is needed inside the callbacks.

All actions are triggered by the host or init process.

Constructor & Destructor Documentation

lxcpp::Guard::Guard ( const std::string &  socketPath)
lxcpp::Guard::~Guard ( )

Member Function Documentation

int lxcpp::Guard::execute ( )
void lxcpp::Guard::onConnection ( const cargo::ipc::PeerID peerID,
const cargo::ipc::FileDescriptor   
)
private

Called each time a new connection is opened to the Guard's socket.

There should be only one peer. It's ID is saved for future reuse.

Parameters
peerIDpeerID of the connected client
void lxcpp::Guard::onDisconnection ( const cargo::ipc::PeerID peerID,
const cargo::ipc::FileDescriptor   
)
private

Called each time a connection to host is lost.

It resets the peerID.

Parameters
peerIDpeerID of the connected client
bool lxcpp::Guard::onGetConfig ( const cargo::ipc::PeerID  ,
std::shared_ptr< api::Void > &  ,
cargo::ipc::MethodResult::Pointer  result 
)
private

Called when synchronizing configuration with the host.

Parameters
resultnew config value
void lxcpp::Guard::onInitExit ( struct::signalfd_siginfo &  sigInfo)
private

Called when the init process exits.

Sends the exit status to the host.

Parameters
sigInfoinfo about the received signal
bool lxcpp::Guard::onSetConfig ( const cargo::ipc::PeerID  ,
std::shared_ptr< ContainerConfig > &  data,
cargo::ipc::MethodResult::Pointer  result 
)
private

Called when synchronizing configuration with the host.

Parameters
datanew config value
bool lxcpp::Guard::onStart ( const cargo::ipc::PeerID  ,
std::shared_ptr< api::Void > &  ,
cargo::ipc::MethodResult::Pointer  result 
)
private

Host -> Guard: Start init in a container described by the configuration.

bool lxcpp::Guard::onStop ( const cargo::ipc::PeerID  ,
std::shared_ptr< api::Void > &  ,
cargo::ipc::MethodResult::Pointer  result 
)
private

Host -> Guard: Stop the init process and return its exit status.

Returns the status asynchronously (outside onStop), when init dies.

int lxcpp::Guard::startContainer ( void *  data)
staticprivate

Setups the init process and executes the init.

Member Data Documentation

std::shared_ptr<ContainerConfig> lxcpp::Guard::mConfig
private
cargo::ipc::epoll::EventPoll lxcpp::Guard::mEventPoll
private
cargo::ipc::PeerID lxcpp::Guard::mPeerID
private
std::unique_ptr<cargo::ipc::Service> lxcpp::Guard::mService
private
utils::SignalFD lxcpp::Guard::mSignalFD
private

The documentation for this class was generated from the following files: