26 #include "ContainerId.h"
28 #include <IIpcService.h>
37 #include <condition_variable>
58 Dobby(
const std::string& dbusAddress,
59 const std::shared_ptr<AI_IPC::IIpcService>& ipcService,
60 const std::shared_ptr<const IDobbySettings>& settings);
70 enum LogTarget :
unsigned { Console = 0x1, SysLog = 0x2, EthanLog = 0x4, Journald = 0x8 };
71 static void setupLogging(
unsigned targets = LogTarget::Console);
75 const std::string& aiPublicBusAddress);
78 #define DOBBY_DBUS_METHOD(x) \
79 void x(std::shared_ptr<AI_IPC::IAsyncReplySender> reply)
81 DOBBY_DBUS_METHOD(ping);
82 DOBBY_DBUS_METHOD(shutdown);
83 DOBBY_DBUS_METHOD(setLogMethod);
84 DOBBY_DBUS_METHOD(setLogLevel);
85 DOBBY_DBUS_METHOD(setAIDbusAddress);
87 DOBBY_DBUS_METHOD(startFromSpec);
88 DOBBY_DBUS_METHOD(startFromBundle);
89 DOBBY_DBUS_METHOD(stop);
90 DOBBY_DBUS_METHOD(pause);
91 DOBBY_DBUS_METHOD(resume);
92 DOBBY_DBUS_METHOD(hibernate);
93 DOBBY_DBUS_METHOD(wakeup);
94 DOBBY_DBUS_METHOD(addMount);
95 DOBBY_DBUS_METHOD(removeMount);
96 DOBBY_DBUS_METHOD(exec);
97 DOBBY_DBUS_METHOD(list);
98 DOBBY_DBUS_METHOD(getState);
99 DOBBY_DBUS_METHOD(getInfo);
101 #if defined(LEGACY_COMPONENTS) && (AI_BUILD_TYPE == AI_DEBUG)
102 DOBBY_DBUS_METHOD(createBundle);
103 DOBBY_DBUS_METHOD(getSpec);
106 #if (AI_BUILD_TYPE == AI_DEBUG)
107 DOBBY_DBUS_METHOD(getOCIConfig);
110 #if defined(AI_ENABLE_TRACING)
111 DOBBY_DBUS_METHOD(startInProcessTracing);
112 DOBBY_DBUS_METHOD(stopInProcessTracing);
115 #undef DOBBY_DBUS_METHOD
122 bool onWatchdogTimer();
136 std::shared_ptr<DobbyEnv> mEnvironment;
137 std::shared_ptr<DobbyUtils> mUtilities;
138 std::shared_ptr<DobbyIPCUtils> mIPCUtilities;
139 std::shared_ptr<DobbyManager> mManager;
140 std::unique_ptr<DobbyWorkQueue> mWorkQueue;
143 const std::shared_ptr<AI_IPC::IIpcService> mIpcService;
144 const std::string mService;
145 const std::string mObjectPath;
146 std::list<std::string> mHandlers;
149 std::atomic<bool> mShutdown;
151 int mWatchdogTimerId;
156 static volatile sig_atomic_t mSigTerm;
160 static void logPrinter(
int level,
const char *file,
const char *func,
161 int line,
const char *message);
163 int line,
const char *message);
165 static void logJournaldPrinter(
int level,
const char *file,
const char *func,
166 int line,
const char *message);
A wrapper around a std::string, used to add some type definition to to an id and also to sanity check...
Definition: ContainerId.h:41
Basic class used to store the stb environment.
Definition: DobbyEnv.h:46
Utility methods for IPC in Dobby.
Definition: DobbyIPCUtils.h:44
Definition: DobbyLogger.h:41
The main object which starts / stops / manages the containers.
Definition: DobbyManager.h:77
Utility methods for hooks and the general containiser daemon.
Definition: DobbyUtils.h:43
Definition: DobbyWorkQueue.h:37
The root Dobby object, runs the dbus loop.
Definition: Dobby.h:56
static std::atomic< unsigned > mLogTargets
The target for logging, can be dynamically changed via dbus.
Definition: Dobby.h:169
static void setupLogging(unsigned targets=LogTarget::Console)
Static method must be called early in the startup before object is instantiated.
Definition: Dobby.cpp:479
void onContainerStopped(int32_t cd, const ContainerId &id, int status)
Called by the DobbyManager code when a container has stopped.
Definition: Dobby.cpp:2090
static void configSignals()
Utility function that MUST be called at startup from the main thread before any other threads are spa...
Definition: Dobby.cpp:213
static void sigTermHandler(int sigNum)
Signal handler for SIGTERM.
Definition: Dobby.cpp:181
static void logPrinter(int level, const char *file, const char *func, int line, const char *message)
Logging callback, called every time a log message needs to be emitted.
Definition: Dobby.cpp:414
void runWorkQueue() const
Runs the Dobby work queue to handle API calls.
Definition: Dobby.cpp:531
static int mEthanLogPipeFd
Definition: Dobby.h:170
void setDefaultAIDbusAddresses(const std::string &aiPrivateBusAddress, const std::string &aiPublicBusAddress)
Debugging function for manually setting the AI dbus addresses.
Definition: Dobby.cpp:605
void onContainerAwoken(int32_t cd, const ContainerId &id)
Called by the DobbyManager code when a container returns back from hibernated.
Definition: Dobby.cpp:2157
void initIpcMethods()
Installs handlers for all the dbus/ipc methods.
Definition: Dobby.cpp:623
void onContainerStarted(int32_t cd, const ContainerId &id)
Called by the DobbyManager code when a container has started.
Definition: Dobby.cpp:2057
static void nullSigChildHandler(int sigNum, siginfo_t *info, void *context)
Signal handler that does nothing.
Definition: Dobby.cpp:196
void onContainerHibernated(int32_t cd, const ContainerId &id)
Called by the DobbyManager code when a container gets hibernated.
Definition: Dobby.cpp:2131
static void logConsolePrinter(int level, const char *file, const char *func, int line, const char *message)
Writes logging output to the console.
Definition: Dobby.cpp:272
void run() const
Issues a 'ready' signal over dbus and then blocks until either a shutdown request is received or SIGT...
Definition: Dobby.cpp:559
Interface provided to the library at startup, contains the configuration options for Dobby.
Definition: IDobbySettings.h:50