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< ContainerConfig > | mConfig |
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.
lxcpp::Guard::Guard | ( | const std::string & | socketPath | ) |
lxcpp::Guard::~Guard | ( | ) |
int lxcpp::Guard::execute | ( | ) |
|
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.
peerID | peerID of the connected client |
|
private |
Called each time a connection to host is lost.
It resets the peerID.
peerID | peerID of the connected client |
|
private |
Called when synchronizing configuration with the host.
result | new config value |
|
private |
Called when the init process exits.
Sends the exit status to the host.
sigInfo | info about the received signal |
|
private |
Called when synchronizing configuration with the host.
data | new config value |
|
private |
|
private |
|
staticprivate |
Setups the init process and executes the init.
|
private |
|
private |
|
private |
|
private |
|
private |