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

Basic object that provides the default overrides for a plugin. More...

#include <PluginBase.h>

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

Public Member Functions

virtual bool postConstruction (const ContainerId &id, const std::shared_ptr< IDobbyStartState > &startupState, const std::string &rootfsPath, const Json::Value &jsonData) override
 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) override
 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) override
 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) override
 Hook function called after the container has stopped. More...
 
virtual bool preDestruction (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called just before the rootfs is deleted, this is called even if there was an error starting the container. More...
 
- Public Member Functions inherited from IDobbyPlugin
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...
 

Additional Inherited Members

- Public Types inherited from IDobbyPlugin
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...
 

Detailed Description

Basic object that provides the default overrides for a plugin.

This class just saves the plugins from having to implement hook functions that are not needed.

Member Function Documentation

◆ postConstruction()

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

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.

Implements IDobbyPlugin.

Reimplemented in PerfettoPlugin, OpenCDMPlugin, MulticastSocketPlugin, and EthanLogPlugin.

◆ postStart()

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

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.

Implements IDobbyPlugin.

◆ postStop()

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

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.

Implements IDobbyPlugin.

◆ preDestruction()

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

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.

Implements IDobbyPlugin.

◆ preStart()

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

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.

Implements IDobbyPlugin.

Reimplemented in EthanLogPlugin.


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