Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Member Functions | Private Attributes | List of all members
DobbyStartState Class Reference

Stores the start state of the container. More...

#include <DobbyStartState.h>

Inheritance diagram for DobbyStartState:
Inheritance graph
[legend]
Collaboration diagram for DobbyStartState:
Collaboration graph
[legend]

Public Member Functions

 DobbyStartState (const std::shared_ptr< DobbyConfig > &config, const std::list< int > &files)
 
bool isValid () const
 
int addFileDescriptor (const std::string &pluginName, int fd) override
 Adds another file descriptor to be passed into the container. More...
 
bool addEnvironmentVariable (const std::string &envVar) override
 Adds an environment variable to the container. More...
 
bool addMount (const std::string &source, const std::string &target, const std::string &fsType, unsigned long mountFlags, const std::list< std::string > &mountOptions) override
 Adds a new mount to the container. More...
 
std::list< int > files () const override
 Gets all file descriptor registered by any client. More...
 
std::list< int > files (const std::string &pluginName) const override
 Gets all file descriptor registered by concrete client. More...
 

Private Attributes

const std::shared_ptr< DobbyConfigmConfig
 
std::list< std::pair< std::string, int > > mFiles
 
bool mValid
 
std::mutex mLock
 

Detailed Description

Stores the start state of the container.

See also
IDobbyStartState

One of these objects is created when a container is first initialised, it stores some state and is passed to the postConstruction hook so plugins can add extra file descriptors or environment variables to the container.

This class is thrown away once the container is launched.

Member Function Documentation

◆ addEnvironmentVariable()

bool DobbyStartState::addEnvironmentVariable ( const std::string &  envVar)
overridevirtual

Adds an environment variable to the container.

Simple appends another environment variable to the container

Parameters
[in]envVarThe environment variable to set
Returns
true on success, false on failure

Implements IDobbyStartState.

◆ addFileDescriptor()

int DobbyStartState::addFileDescriptor ( const std::string &  pluginName,
int  fd 
)
overridevirtual

Adds another file descriptor to be passed into the container.

The number of the file descriptor in the container namespace is returned, unless there was an error in which case a negative value is returned. File descriptors start at 3.

The method dups the supplied file descriptor so it can be closed immmediatly after the call. The file descriptor will be closed after the container is started and handed over.

File descriptors are recorded per client (plugin name).

Lastly to help find issues, this function will log an error and reject the file descriptor if it doesn't have the FD_CLOEXEC bit set.

Parameters
[in]pluginNameThe plugin name for which fd will be recorded
[in]fdThe file descriptor to pass to the container
Returns
the number of the file descriptor inside the container on success, on failure -1

Implements IDobbyStartState.

◆ addMount()

bool DobbyStartState::addMount ( const std::string &  source,
const std::string &  target,
const std::string &  fsType,
unsigned long  mountFlags,
const std::list< std::string > &  mountOptions 
)
overridevirtual

Adds a new mount to the container.

Adds a mount entry to the config.json for the container.

Warning
this can't be used to add loopback mounts, only standard /dev mounts or bind mounts of directories and files.
Parameters
[in]sourceThe source of the mount
[in]targetThe target mount point
[in]fsTypeThe filesystem type of the mount
[in]mountFlagsThe mount flags (i.e. MS_BIND, MS_??)
[in]mountOptionsAny additional mount options.
Returns
true on success, false on failure

Implements IDobbyStartState.

◆ files() [1/2]

std::list< int > DobbyStartState::files ( ) const
overridevirtual

Gets all file descriptor registered by any client.

Returns
List of all file descriptors

Implements IDobbyStartState.

◆ files() [2/2]

std::list< int > DobbyStartState::files ( const std::string &  pluginName) const
overridevirtual

Gets all file descriptor registered by concrete client.

Parameters
[in]pluginNameRDK plugin name
Returns
List of file descriptors assiociated with given plugin name

Implements IDobbyStartState.


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