Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Types | Public Member Functions | List of all members
IDobbyPlugin Class Referenceabstract

Interface that plugin libraries have to implement. More...

#include <IDobbyPlugin.h>

Inheritance diagram for IDobbyPlugin:
Inheritance graph
[legend]

Public Types

enum  HintFlags : unsigned {
  PostConstructionSync = (1 << 0) , PreStartSync = (1 << 1) , PostStartSync = (1 << 2) , PostStopSync = (1 << 3) ,
  PreDestructionSync = (1 << 4) , PostConstructionAsync = (1 << 16) , PreStartAsync = (1 << 17) , PostStartAsync = (1 << 18) ,
  PostStopAsync = (1 << 19) , PreDestructionAsync = (1 << 20)
}
 Bit flags that should be returned by hookHints. More...
 

Public Member Functions

virtual std::string name () const =0
 Should return the name of the plugin, this is used to match against the json spec file used to create the container. More...
 
virtual unsigned hookHints () const =0
 Should return a bitfield of the hook points implemented by the plugin. More...
 
virtual bool postConstruction (const ContainerId &id, const std::shared_ptr< IDobbyStartState > &startupState, const std::string &rootfsPath, const Json::Value &jsonData)=0
 Hook function called after the rootfs has been created, but before the container is launched. More...
 
virtual bool preStart (const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData)=0
 Hook function called after the container is setup, but before the init process is executed. More...
 
virtual bool postStart (const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData)=0
 Hook function called after the container is started and the init process is now running. More...
 
virtual bool postStop (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData)=0
 Hook function called after the container has stopped. More...
 
virtual bool preDestruction (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData)=0
 Hook function called just before the rootfs is deleted, this is called even if there was an error starting the container. More...
 

Detailed Description

Interface that plugin libraries have to implement.

Member Enumeration Documentation

◆ HintFlags

enum IDobbyPlugin::HintFlags : unsigned

Bit flags that should be returned by hookHints.

The flags are fairly self explanatory.

Member Function Documentation

◆ hookHints()

virtual unsigned IDobbyPlugin::hookHints ( ) const
pure virtual

Should return a bitfield of the hook points implemented by the plugin.

Only bits that are set will be called as hooks. This is to optimise the implementation of the hook code in the daemon and means threads aren't spawned for null hook points.

The value returned should be constant for the lifetime of the class, as the value may be cached by the daemon at startup.

Returns
bitmask of the HintFlags bits.

Implemented in PerfettoPlugin, OpenCDMPlugin, MulticastSocketPlugin, and EthanLogPlugin.

◆ name()

virtual std::string IDobbyPlugin::name ( ) const
pure virtual

Should return the name of the plugin, this is used to match against the json spec file used to create the container.

The value returned should be constant for the lifetime of the class, as the value may be cached by the daemon at startup.

Returns
string with the name of the hook.

Implemented in PerfettoPlugin, OpenCDMPlugin, MulticastSocketPlugin, and EthanLogPlugin.

◆ postConstruction()

virtual bool IDobbyPlugin::postConstruction ( const ContainerId id,
const std::shared_ptr< IDobbyStartState > &  startupState,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
pure virtual

Hook function called after the rootfs has been created, but before the container is launched.

At this point you can setup mounts that the container will see as it hasn't yet created the namespaces. This is typically used to mount something that wouldn't be allowed inside a userns, then once mounted you can hook the prestart phase to move mount it into the container's namespace.

See also
LoopMounterHook class for where this is used.

You can also hook this point to allow you to add extra environment variables or pass in additional file descriptors via the startupState class.

Parameters
[in]idThe string id of the container.
[in]startupStateA utility object with methods that allow you to tweak the parameters of the container before it is launched.
[in]rootfsPathThe absolute path to the rootfs of the container.
[in]jsonDataThe json data from the spec file.
Returns
true on success, false on failure.

Implemented in PluginBase, PerfettoPlugin, OpenCDMPlugin, MulticastSocketPlugin, and EthanLogPlugin.

◆ postStart()

virtual bool IDobbyPlugin::postStart ( const ContainerId id,
pid_t  pid,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
pure virtual

Hook function called after the container is started and the init process is now running.

This hook is not particularly useful, although it can be used to inform clients that a container has started successifully.

Parameters
[in]idThe id of the container (string)
[in]pidThe pid of the init process in the container.
[in]rootfsPathThe absolute path to the rootfs.
[in]jsonDataThe json data for the hook specified in the container spec file.
Returns
true on success, false on failure.

Implemented in PluginBase.

◆ postStop()

virtual bool IDobbyPlugin::postStop ( const ContainerId id,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
pure virtual

Hook function called after the container has stopped.

Parameters
[in]idThe id of the container (string)
[in]rootfsPathThe absolute path to the rootfs.
[in]jsonDataThe json data for the hook specified in the container spec file.
Returns
true on success, false on failure.

Implemented in PluginBase.

◆ preDestruction()

virtual bool IDobbyPlugin::preDestruction ( const ContainerId id,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
pure virtual

Hook function called just before the rootfs is deleted, this is called even if there was an error starting the container.

This hook is called at a very similar place to postStop, but it will be called even if the container failed to start (but as long as postConstruction was called).

Parameters
[in]idThe string id of the container.
[in]rootfsPathThe absolute path to the rootfs of the container.
[in]jsonDataThe json data from the spec file.
Returns
true on success, false on failure.

Implemented in PluginBase.

◆ preStart()

virtual bool IDobbyPlugin::preStart ( const ContainerId id,
pid_t  pid,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
pure virtual

Hook function called after the container is setup, but before the init process is executed.

The hooks are run after the mounts are setup, but before we switch to the new root, so that the old root is still available in the hooks for any mount manipulations.

Parameters
[in]idThe string id of the container.
[in]pidThe pid owner of the namespace to enter, typically the pid of the process in the container.
[in]nsTypeThe type of the namespace to enter, see above.
[in]funcThe actual function to execute.
Returns
true on success, false on failure.

Implemented in PluginBase, and EthanLogPlugin.


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