Dobby
3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
|
#include <GpuPlugin.h>
Public Member Functions | |
GpuPlugin (std::shared_ptr< rt_dobby_schema > &containerConfig, const std::shared_ptr< DobbyRdkPluginUtils > &utils, const std::string &rootfsPath) | |
std::string | name () const override |
Should return the name of the plugin. More... | |
unsigned | hookHints () const override |
Should return a bitfield of the hook points implemented by the plugin. More... | |
bool | createRuntime () override |
we use the createRuntime point to create a cgroup and put the containered process into it. More... | |
bool | postStop () override |
We use the postStop point to remove the cgroup directory created in the createRuntime phase. More... | |
std::vector< std::string > | getDependencies () const override |
Should return the names of the plugins this plugin depends on. More... | |
Public Member Functions inherited from RdkPluginBase | |
virtual bool | postInstallation () |
virtual bool | preCreation () |
virtual bool | createContainer () |
virtual bool | postStart () |
virtual bool | postHalt () |
Private Member Functions | |
std::string | getGpuCgroupMountPoint () |
Attempts to get the mount point of the gpu cgroup filesystem. More... | |
bool | setupContainerGpuLimit (const std::string cgroupDirPath, pid_t containerPid, int memoryLimit) |
Creates a gpu cgroup for the container and moves the container into it. More... | |
bool | bindMountGpuCgroup (const std::string &source, const std::string &target) |
Private Attributes | |
const std::string | mName |
std::shared_ptr< rt_dobby_schema > | mContainerConfig |
const std::shared_ptr< DobbyRdkPluginUtils > | mUtils |
Additional Inherited Members | |
Public Types inherited from IDobbyRdkPlugin | |
enum | HintFlags : unsigned { PostInstallationFlag = (1 << 0) , PreCreationFlag = (1 << 1) , CreateRuntimeFlag = (1 << 2) , CreateContainerFlag = (1 << 3) , PostStartFlag = (1 << 5) , PostHaltFlag = (1 << 6) , PostStopFlag = (1 << 7) , Unknown = 0 } |
Bit flags that should be returned by hookHints. More... | |
Dobby GPU plugin.
Sets the gpu memory limits for a given container.
This plugin simply creates a gpu cgroup for the container, sets the limit and then moves the containered process into it.
This is effectively what crun does for all the other limits, but it doesn't know about the custom gpu cgroup as that is an extension to the default cgroups.
|
overridevirtual |
we use the createRuntime point to create a cgroup and put the containered process into it.
The amount of memory to assign is read from the plugin's data section in the bundle config.
The cgroup is given the same name as the container.
Reimplemented from RdkPluginBase.
|
overridevirtual |
Should return the names of the plugins this plugin depends on.
This can be used to determine the order in which the plugins should be processed when running hooks.
Reimplemented from RdkPluginBase.
|
private |
Attempts to get the mount point of the gpu cgroup filesystem.
This scans the mount table looking for the cgroups mount, if this fails it's pretty fatal.
This is typically "/sys/fs/cgroup/gpu".
|
overridevirtual |
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 to ensure we don't waste time trying to run hooks that don't do anything
The value returned should be constant for the lifetime of the class
Implements IDobbyRdkPlugin.
|
inlineoverridevirtual |
Should return the name of the plugin.
Implements IDobbyRdkPlugin.
|
overridevirtual |
We use the postStop point to remove the cgroup directory created in the createRuntime phase.
The directory will have the same name as the container id.
Reimplemented from RdkPluginBase.
|
private |
Creates a gpu cgroup for the container and moves the container into it.
The cgroup is given the same name as the container.
[in] | cgroupDirPath | Path to the gpu cgroup directory. |
[in] | containerPid | The pid of the process in the container. |
[in] | memoryLimit | The memory limit set in the bundle config. |