Skip to content

Commit

Permalink
Merge pull request #234 from rdkcentral/master
Browse files Browse the repository at this point in the history
Dobby Patch Release v3.6.1
  • Loading branch information
goruklu committed May 9, 2023
2 parents effc781 + a0f4799 commit 7cceddc
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
env:
# For CI, build all optional plugins. Newly developed plugins should be added to this list
optional_plugins: "-DPLUGIN_TESTPLUGIN=ON -DPLUGIN_GPU=ON -DPLUGIN_LOCALTIME=ON -DPLUGIN_RTSCHEDULING=ON -DPLUGIN_HTTPPROXY=ON -DPLUGIN_APPSERVICES=ON -DPLUGIN_IONMEMORY=ON -DPLUGIN_DEVICEMAPPER=ON -DPLUGIN_OOMCRASH=ON"
Expand All @@ -18,12 +18,12 @@ jobs:
name: Build in ${{ matrix.build_type }} Mode (${{ matrix.extra_flags }})
steps:
- name: checkout
uses: actions/checkout@v2.1.0
uses: actions/checkout@v3

- name: install-dependencies
run: |
sudo apt-get update -y -q
sudo apt-get install -q -y automake libtool autotools-dev software-properties-common build-essential cmake libsystemd-dev libctemplate-dev libjsoncpp-dev libjsoncpp1 libdbus-1-dev libnl-3-dev libnl-route-3-dev libsystemd-dev libyajl-dev libcap-dev libboost-dev
sudo apt-get install -q -y automake libtool autotools-dev software-properties-common build-essential cmake libsystemd-dev libctemplate-dev libjsoncpp-dev libdbus-1-dev libnl-3-dev libnl-route-3-dev libsystemd-dev libyajl-dev libcap-dev libboost-dev
- name: build dobby
run: |
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ cmake_minimum_required( VERSION 3.7.0 )
include(GNUInstallDirs)

# Project setup
project( Dobby VERSION "3.6.0" )
project( Dobby VERSION "3.6.1" )


# Set the major and minor version numbers of dobby (also used by plugins)
set( DOBBY_MAJOR_VERSION 3 )
set( DOBBY_MINOR_VERSION 6 )
set( DOBBY_MICRO_VERSION 0 )
set( DOBBY_MICRO_VERSION 1 )

set(INSTALL_CMAKE_DIR lib/cmake/Dobby)

Expand Down
1 change: 1 addition & 0 deletions bundle/lib/include/DobbySpecConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class DobbySpecConfig : public DobbyConfig
const std::shared_ptr<const IDobbySettings::HardwareAccessSettings> mGpuSettings;
const std::shared_ptr<const IDobbySettings::HardwareAccessSettings> mVpuSettings;
const std::vector<std::string> mDefaultPlugins;
const Json::Value mRdkPluginsData;

private:
bool mValid;
Expand Down
7 changes: 4 additions & 3 deletions bundle/lib/source/DobbySpecConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <array>
#include <atomic>
#include <algorithm>
#include <grp.h>
#include <fcntl.h>
#include <limits.h>
Expand Down Expand Up @@ -206,6 +207,7 @@ DobbySpecConfig::DobbySpecConfig(const std::shared_ptr<IDobbyUtils> &utils,
, mGpuSettings(settings->gpuAccessSettings())
, mVpuSettings(settings->vpuAccessSettings())
, mDefaultPlugins(settings->defaultPlugins())
, mRdkPluginsData(settings->rdkPluginsData())
, mDictionary(nullptr)
, mConf(nullptr)
, mSpecVersion(SpecVersion::Unknown)
Expand Down Expand Up @@ -618,11 +620,10 @@ bool DobbySpecConfig::parseSpec(ctemplate::TemplateDictionary* dictionary,
dictionary->ShowSection(ENABLE_RDK_PLUGINS);

// step 6.5 - add any default plugins in the settings file
// TODO:: Allow defining plugin data in the settings file
Json::Value rdkPluginData = Json::objectValue;
Json::Value rdkPluginData = mRdkPluginsData;
for (const auto& pluginName : mDefaultPlugins)
{
mRdkPluginsJson[pluginName]["data"] = rdkPluginData;
mRdkPluginsJson[pluginName]["data"] = rdkPluginData[pluginName];
mRdkPluginsJson[pluginName]["required"] = false;
}

Expand Down
8 changes: 5 additions & 3 deletions bundle/runtime-schemas/defs-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@
"LocalTime": {
"type": "object",
"required": [
"required",
"data"
"required"
],
"properties": {
"required": {
Expand All @@ -456,7 +455,10 @@
"properties": {
"setTZ" : {
"type": "string"
}
},
"path" : {
"type": "string"
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions pluginLauncher/tool/source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ std::shared_ptr<const rt_state_schema> getContainerState()
std::mutex lock;
std::lock_guard<std::mutex> locker(lock);

char buf[1000];
char buf[4096];
bzero(buf, sizeof(buf));

if (read(STDIN_FILENO, buf, sizeof(buf)) < 0)
if (read(STDIN_FILENO, buf, sizeof(buf)-1) < 0)
{
AI_LOG_SYS_ERROR(errno, "failed to read stdin");
return nullptr;
Expand All @@ -204,6 +204,10 @@ std::shared_ptr<const rt_state_schema> getContainerState()

if (state.get() == nullptr || err)
{
if (hookStdin.length() == sizeof(buf)-1)
{
AI_LOG_ERROR("Most probably the read buffer is too small and causes the parse error below!");
}
AI_LOG_ERROR_EXIT("Failed to parse container state, err '%s'", err);
return nullptr;
}
Expand Down
12 changes: 6 additions & 6 deletions rdkPlugins/LocalTime/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Dobby RDK LocalTime Plugin

## Quick Start
Add the following section to your OCI runtime configuration `config.json` file to automatically symlink the real `/etc/localtime` file to the container's rootfs at `/etc/localtime`.
Add the following section to your OCI runtime configuration `config.json` file to automatically symlink the mentioned path to the container's rootfs.

```json
{
"rdkPlugins": {
"localtime": {
"required": true,
"data": {
"path": "<path>",
"setTZ": "<path>"
}
}
Expand All @@ -18,10 +19,9 @@ Add the following section to your OCI runtime configuration `config.json` file t

If you already have other RDK plugins in the bundle, then just add the localtime plugin. Do not create multiple `rdkPlugin` sections.

## Prerequisites

`/etc/localtime` symlink must be available and point to the correct file based on locale.

## Options
### path
Optional parameter, if set, localtime symlink path should be set, else the default path `etc/localtime` is set.

### setTZ
Optional parameter, if set it should contain a path to file holding time stamp. This time stamp will be placed in containers env variable called TZ
Optional parameter, if set it should contain a path to file holding time stamp. This time stamp will be placed in containers env variable called TZ
27 changes: 23 additions & 4 deletions rdkPlugins/LocalTime/source/LocalTimePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,36 @@ bool LocalTimePlugin::postInstallation()
{
AI_LOG_FN_ENTRY();

std::string path;

if (mContainerConfig->rdk_plugins->localtime->data->path)
{
path = mContainerConfig->rdk_plugins->localtime->data->path;
std::size_t found = path.find_last_of("/");
std::string dirPath = path.substr(0, found);

if (mUtils->mkdirRecursive(mRootfsPath + dirPath, 0755) || (errno == EEXIST))
AI_LOG_INFO("Set localtime path %s", path.c_str());
else
AI_LOG_SYS_ERROR(errno, "failed to create dir. %s", path.c_str());
}
else
{
path = "/etc/localtime";
AI_LOG_INFO("Set default path %s", path.c_str());
}

// get the real path to the correct local time zone
char pathBuf[PATH_MAX];
ssize_t len = readlink("/etc/localtime", pathBuf, sizeof(pathBuf));
ssize_t len = readlink(path.c_str(), pathBuf, sizeof(pathBuf));
if (len <= 0)
{
AI_LOG_SYS_ERROR_EXIT(errno, "readlink failed on '/etc/localtime'");
AI_LOG_SYS_ERROR_EXIT(errno, "readlink failed on %s", path.c_str());
return false;
}

const std::string localtimeInHost(pathBuf, len);
const std::string localtimeInContainer = mRootfsPath + "/etc/localtime";
const std::string localtimeInContainer = mRootfsPath + path;

if (localtimeInHost.empty())
{
Expand All @@ -77,7 +96,7 @@ bool LocalTimePlugin::postInstallation()
}
else if (symlink(localtimeInHost.c_str(), localtimeInContainer.c_str()) < 0)
{
AI_LOG_SYS_ERROR_EXIT(errno, "failed to create /etc/localtime symlink");
AI_LOG_SYS_ERROR_EXIT(errno, "failed to create %s symlink", path.c_str());
return false;
}

Expand Down
7 changes: 7 additions & 0 deletions settings/include/IDobbySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include <set>
#include <netinet/in.h>

#if defined(RDK)
# include <json/json.h>
#else
# include <jsoncpp/json.h>
#endif

// -----------------------------------------------------------------------------
/**
* @class IDobbySettings
Expand Down Expand Up @@ -189,6 +195,7 @@ class IDobbySettings
*/
virtual std::vector<std::string> defaultPlugins() const = 0;

virtual Json::Value rdkPluginsData() const = 0;

struct LogRelaySettings
{
Expand Down
4 changes: 4 additions & 0 deletions settings/include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class Settings final : public IDobbySettings
in_addr_t addressRange() const override;
std::vector<std::string> defaultPlugins() const override;

Json::Value rdkPluginsData() const override;

LogRelaySettings logRelaySettings() const override;

void dump(int aiLogLevel = -1) const;
Expand Down Expand Up @@ -122,6 +124,8 @@ class Settings final : public IDobbySettings
std::pair<std::string, in_addr_t> mAddressRange;
std::vector<std::string> mDefaultPlugins;

Json::Value mRdkPluginsData;

LogRelaySettings mLogRelaySettings;
};

Expand Down
23 changes: 22 additions & 1 deletion settings/source/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,18 @@ Settings::Settings(const Json::Value& settings)
for (const Json::Value &pluginName : defaultPluginNames)
{
if (pluginName.isString())
{
mDefaultPlugins.push_back(pluginName.asString());
mRdkPluginsData[pluginName.asString()] = Json::Value::null;
}
else if(pluginName.isObject())
{
for (const auto& value : pluginName.getMemberNames())
{
mDefaultPlugins.push_back(value);
mRdkPluginsData[value] = pluginName[value];
}
}
else
AI_LOG_ERROR("invalid entry in defaultPlugins array in JSON settings file");
}
Expand Down Expand Up @@ -401,6 +412,16 @@ std::vector<std::string> Settings::defaultPlugins() const
return mDefaultPlugins;
}

// -----------------------------------------------------------------------------
/**
* @brief
*
*/
Json::Value Settings::rdkPluginsData() const
{
return mRdkPluginsData;
}

// -----------------------------------------------------------------------------
/**
* @brief
Expand Down Expand Up @@ -973,4 +994,4 @@ std::shared_ptr<IDobbySettings::HardwareAccessSettings> Settings::getHardwareAcc
accessSettings->extraEnvVariables = getEnvVarsFromJson(hw, Json::Path(".extraEnvVariables"));

return accessSettings;
}
}

0 comments on commit 7cceddc

Please sign in to comment.