James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2017 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 17 | #include "dbus-sensor_config.h" |
| 18 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 19 | #include <Utils.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 20 | #include <boost/algorithm/string/predicate.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 21 | #include <boost/container/flat_map.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 22 | #include <sdbusplus/asio/connection.hpp> |
| 23 | #include <sdbusplus/asio/object_server.hpp> |
| 24 | #include <sdbusplus/bus/match.hpp> |
| 25 | |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 26 | #include <filesystem> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 27 | #include <fstream> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 28 | #include <memory> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 29 | #include <regex> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 30 | #include <stdexcept> |
| 31 | #include <string> |
| 32 | #include <utility> |
| 33 | #include <variant> |
| 34 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 35 | |
James Feist | cf3bce6 | 2019-01-08 10:07:19 -0800 | [diff] [blame] | 36 | namespace fs = std::filesystem; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 37 | |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 38 | static bool powerStatusOn = false; |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 39 | static bool biosHasPost = false; |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 40 | static bool manufacturingMode = false; |
James Feist | 58295ad | 2019-05-30 15:01:41 -0700 | [diff] [blame] | 41 | |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 42 | static std::unique_ptr<sdbusplus::bus::match_t> powerMatch = nullptr; |
| 43 | static std::unique_ptr<sdbusplus::bus::match_t> postMatch = nullptr; |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 44 | |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 45 | /** |
| 46 | * return the contents of a file |
| 47 | * @param[in] hwmonFile - the path to the file to read |
| 48 | * @return the contents of the file as a string or nullopt if the file could not |
| 49 | * be opened. |
| 50 | */ |
| 51 | |
| 52 | std::optional<std::string> openAndRead(const std::string& hwmonFile) |
| 53 | { |
| 54 | std::string fileVal; |
| 55 | std::ifstream fileStream(hwmonFile); |
| 56 | if (!fileStream.is_open()) |
| 57 | { |
| 58 | return std::nullopt; |
| 59 | } |
| 60 | std::getline(fileStream, fileVal); |
| 61 | return fileVal; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * given a hwmon temperature base name if valid return the full path else |
| 66 | * nullopt |
| 67 | * @param[in] directory - the hwmon sysfs directory |
| 68 | * @param[in] permitSet - a set of labels or hwmon basenames to permit. If this |
| 69 | * is empty then *everything* is permitted. |
| 70 | * @return a string to the full path of the file to create a temp sensor with or |
| 71 | * nullopt to indicate that no sensor should be created for this basename. |
| 72 | */ |
| 73 | std::optional<std::string> |
| 74 | getFullHwmonFilePath(const std::string& directory, |
| 75 | const std::string& hwmonBaseName, |
| 76 | const std::set<std::string>& permitSet) |
| 77 | { |
| 78 | std::optional<std::string> result; |
| 79 | std::string filename; |
| 80 | if (permitSet.empty()) |
| 81 | { |
| 82 | result = directory + "/" + hwmonBaseName + "_input"; |
| 83 | return result; |
| 84 | } |
| 85 | filename = directory + "/" + hwmonBaseName + "_label"; |
| 86 | auto searchVal = openAndRead(filename); |
| 87 | if (!searchVal) |
| 88 | { |
| 89 | /* if the hwmon temp doesn't have a corresponding label file |
| 90 | * then use the hwmon temperature base name |
| 91 | */ |
| 92 | searchVal = hwmonBaseName; |
| 93 | } |
| 94 | if (permitSet.find(*searchVal) != permitSet.end()) |
| 95 | { |
| 96 | result = directory + "/" + hwmonBaseName + "_input"; |
| 97 | } |
| 98 | return result; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * retrieve a set of basenames and labels to allow sensor creation for. |
| 103 | * @param[in] config - a map representing the configuration for a specific |
| 104 | * device |
| 105 | * @return a set of basenames and labels to allow sensor creation for. An empty |
| 106 | * set indicates that everything is permitted. |
| 107 | */ |
| 108 | std::set<std::string> getPermitSet(const SensorBaseConfigMap& config) |
| 109 | { |
| 110 | auto permitAttribute = config.find("Labels"); |
| 111 | std::set<std::string> permitSet; |
| 112 | if (permitAttribute != config.end()) |
| 113 | { |
| 114 | try |
| 115 | { |
| 116 | auto val = |
| 117 | std::get<std::vector<std::string>>(permitAttribute->second); |
| 118 | |
| 119 | permitSet.insert(std::make_move_iterator(val.begin()), |
| 120 | std::make_move_iterator(val.end())); |
| 121 | } |
| 122 | catch (const std::bad_variant_access& err) |
| 123 | { |
| 124 | std::cerr << err.what() |
| 125 | << ":PermitList does not contain a list, wrong " |
| 126 | "variant type.\n"; |
| 127 | } |
| 128 | } |
| 129 | return permitSet; |
| 130 | } |
| 131 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 132 | bool getSensorConfiguration( |
| 133 | const std::string& type, |
| 134 | const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 135 | ManagedObjectType& resp) |
| 136 | { |
| 137 | return getSensorConfiguration(type, dbusConnection, resp, false); |
| 138 | } |
| 139 | |
| 140 | bool getSensorConfiguration( |
| 141 | const std::string& type, |
| 142 | const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 143 | ManagedObjectType& resp, bool useCache) |
| 144 | { |
| 145 | static ManagedObjectType managedObj; |
| 146 | |
| 147 | if (!useCache) |
| 148 | { |
| 149 | managedObj.clear(); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 150 | sdbusplus::message_t getManagedObjects = |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 151 | dbusConnection->new_method_call( |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 152 | entityManagerName, "/", "org.freedesktop.DBus.ObjectManager", |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 153 | "GetManagedObjects"); |
| 154 | bool err = false; |
| 155 | try |
| 156 | { |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 157 | sdbusplus::message_t reply = |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 158 | dbusConnection->call(getManagedObjects); |
Yoo, Jae Hyun | 0e02205 | 2018-10-15 14:05:37 -0700 | [diff] [blame] | 159 | reply.read(managedObj); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 160 | } |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 161 | catch (const sdbusplus::exception_t& e) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 162 | { |
Jason Ling | 5747fab | 2019-10-02 16:46:23 -0700 | [diff] [blame] | 163 | std::cerr << "While calling GetManagedObjects on service:" |
| 164 | << entityManagerName << " exception name:" << e.name() |
| 165 | << "and description:" << e.description() |
| 166 | << " was thrown\n"; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 167 | err = true; |
| 168 | } |
| 169 | |
| 170 | if (err) |
| 171 | { |
| 172 | std::cerr << "Error communicating to entity manager\n"; |
| 173 | return false; |
| 174 | } |
| 175 | } |
| 176 | for (const auto& pathPair : managedObj) |
| 177 | { |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 178 | bool correctType = false; |
| 179 | for (const auto& entry : pathPair.second) |
| 180 | { |
| 181 | if (boost::starts_with(entry.first, type)) |
| 182 | { |
| 183 | correctType = true; |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | if (correctType) |
| 188 | { |
| 189 | resp.emplace(pathPair); |
| 190 | } |
| 191 | } |
| 192 | return true; |
| 193 | } |
| 194 | |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 195 | bool findFiles(const fs::path& dirPath, std::string_view matchString, |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 196 | std::vector<fs::path>& foundPaths, int symlinkDepth) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 197 | { |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 198 | std::error_code ec; |
| 199 | if (!fs::exists(dirPath, ec)) |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 200 | { |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 201 | return false; |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 202 | } |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 203 | |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 204 | std::vector<std::regex> matchPieces; |
| 205 | |
| 206 | size_t pos = 0; |
| 207 | std::string token; |
| 208 | // Generate the regex expressions list from the match we were given |
| 209 | while ((pos = matchString.find('/')) != std::string::npos) |
| 210 | { |
| 211 | token = matchString.substr(0, pos); |
| 212 | matchPieces.emplace_back(token); |
| 213 | matchString.remove_prefix(pos + 1); |
| 214 | } |
| 215 | matchPieces.emplace_back(std::string{matchString}); |
| 216 | |
| 217 | // Check if the match string contains directories, and skip the match of |
| 218 | // subdirectory if not |
| 219 | if (matchPieces.size() <= 1) |
| 220 | { |
| 221 | std::regex search(std::string{matchString}); |
| 222 | std::smatch match; |
| 223 | for (auto p = fs::recursive_directory_iterator( |
| 224 | dirPath, fs::directory_options::follow_directory_symlink); |
| 225 | p != fs::recursive_directory_iterator(); ++p) |
| 226 | { |
| 227 | std::string path = p->path().string(); |
| 228 | if (!is_directory(*p)) |
| 229 | { |
| 230 | if (std::regex_search(path, match, search)) |
| 231 | { |
| 232 | foundPaths.emplace_back(p->path()); |
| 233 | } |
| 234 | } |
| 235 | if (p.depth() >= symlinkDepth) |
| 236 | { |
| 237 | p.disable_recursion_pending(); |
| 238 | } |
| 239 | } |
| 240 | return true; |
| 241 | } |
| 242 | |
| 243 | // The match string contains directories, verify each level of sub |
| 244 | // directories |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 245 | for (auto p = fs::recursive_directory_iterator( |
| 246 | dirPath, fs::directory_options::follow_directory_symlink); |
| 247 | p != fs::recursive_directory_iterator(); ++p) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 248 | { |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 249 | std::vector<std::regex>::iterator matchPiece = matchPieces.begin(); |
| 250 | fs::path::iterator pathIt = p->path().begin(); |
| 251 | for (const fs::path& dir : dirPath) |
| 252 | { |
| 253 | if (dir.empty()) |
| 254 | { |
| 255 | // When the path ends with '/', it gets am empty path |
| 256 | // skip such case. |
| 257 | break; |
| 258 | } |
| 259 | pathIt++; |
| 260 | } |
| 261 | |
| 262 | while (pathIt != p->path().end()) |
| 263 | { |
| 264 | // Found a path deeper than match. |
| 265 | if (matchPiece == matchPieces.end()) |
| 266 | { |
| 267 | p.disable_recursion_pending(); |
| 268 | break; |
| 269 | } |
| 270 | std::smatch match; |
| 271 | std::string component = pathIt->string(); |
| 272 | std::regex regexPiece(*matchPiece); |
| 273 | if (!std::regex_match(component, match, regexPiece)) |
| 274 | { |
| 275 | // path prefix doesn't match, no need to iterate further |
| 276 | p.disable_recursion_pending(); |
| 277 | break; |
| 278 | } |
| 279 | matchPiece++; |
| 280 | pathIt++; |
| 281 | } |
| 282 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 283 | if (!is_directory(*p)) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 284 | { |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 285 | if (matchPiece == matchPieces.end()) |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 286 | { |
| 287 | foundPaths.emplace_back(p->path()); |
| 288 | } |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 289 | } |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 290 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 291 | if (p.depth() >= symlinkDepth) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 292 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 293 | p.disable_recursion_pending(); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | return true; |
| 297 | } |
| 298 | |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 299 | bool isPowerOn(void) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 300 | { |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 301 | if (!powerMatch) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 302 | { |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 303 | throw std::runtime_error("Power Match Not Created"); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 304 | } |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 305 | return powerStatusOn; |
| 306 | } |
| 307 | |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 308 | bool hasBiosPost(void) |
| 309 | { |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 310 | if (!postMatch) |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 311 | { |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 312 | throw std::runtime_error("Post Match Not Created"); |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 313 | } |
| 314 | return biosHasPost; |
| 315 | } |
| 316 | |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 317 | bool readingStateGood(const PowerState& powerState) |
| 318 | { |
| 319 | if (powerState == PowerState::on && !isPowerOn()) |
| 320 | { |
| 321 | return false; |
| 322 | } |
| 323 | if (powerState == PowerState::biosPost && (!hasBiosPost() || !isPowerOn())) |
| 324 | { |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | return true; |
| 329 | } |
| 330 | |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 331 | static void |
| 332 | getPowerStatus(const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 333 | size_t retries = 2) |
| 334 | { |
| 335 | conn->async_method_call( |
| 336 | [conn, retries](boost::system::error_code ec, |
| 337 | const std::variant<std::string>& state) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 338 | if (ec) |
| 339 | { |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 340 | if (retries != 0U) |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 341 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 342 | auto timer = std::make_shared<boost::asio::steady_timer>( |
| 343 | conn->get_io_context()); |
| 344 | timer->expires_after(std::chrono::seconds(15)); |
| 345 | timer->async_wait( |
| 346 | [timer, conn, retries](boost::system::error_code) { |
| 347 | getPowerStatus(conn, retries - 1); |
| 348 | }); |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 349 | return; |
| 350 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 351 | |
| 352 | // we commonly come up before power control, we'll capture the |
| 353 | // property change later |
| 354 | std::cerr << "error getting power status " << ec.message() << "\n"; |
| 355 | return; |
| 356 | } |
| 357 | powerStatusOn = |
| 358 | boost::ends_with(std::get<std::string>(state), ".Running"); |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 359 | }, |
| 360 | power::busname, power::path, properties::interface, properties::get, |
| 361 | power::interface, power::property); |
| 362 | } |
| 363 | |
| 364 | static void |
| 365 | getPostStatus(const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 366 | size_t retries = 2) |
| 367 | { |
| 368 | conn->async_method_call( |
| 369 | [conn, retries](boost::system::error_code ec, |
| 370 | const std::variant<std::string>& state) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 371 | if (ec) |
| 372 | { |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 373 | if (retries != 0U) |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 374 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 375 | auto timer = std::make_shared<boost::asio::steady_timer>( |
| 376 | conn->get_io_context()); |
| 377 | timer->expires_after(std::chrono::seconds(15)); |
| 378 | timer->async_wait( |
| 379 | [timer, conn, retries](boost::system::error_code) { |
| 380 | getPostStatus(conn, retries - 1); |
| 381 | }); |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 382 | return; |
| 383 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 384 | // we commonly come up before power control, we'll capture the |
| 385 | // property change later |
| 386 | std::cerr << "error getting post status " << ec.message() << "\n"; |
| 387 | return; |
| 388 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 389 | const auto& value = std::get<std::string>(state); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 390 | biosHasPost = (value != "Inactive") && |
| 391 | (value != "xyz.openbmc_project.State.OperatingSystem." |
| 392 | "Status.OSStatus.Inactive"); |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 393 | }, |
| 394 | post::busname, post::path, properties::interface, properties::get, |
| 395 | post::interface, post::property); |
| 396 | } |
| 397 | |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 398 | void setupPowerMatchCallback( |
| 399 | const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 400 | std::function<void(PowerState type, bool state)>&& hostStatusCallback) |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 401 | { |
James Feist | 43d32fe | 2019-09-04 10:35:20 -0700 | [diff] [blame] | 402 | static boost::asio::steady_timer timer(conn->get_io_context()); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 403 | // create a match for powergood changes, first time do a method call to |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 404 | // cache the correct value |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 405 | if (powerMatch) |
| 406 | { |
| 407 | return; |
| 408 | } |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 409 | |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 410 | powerMatch = std::make_unique<sdbusplus::bus::match_t>( |
| 411 | static_cast<sdbusplus::bus_t&>(*conn), |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 412 | "type='signal',interface='" + std::string(properties::interface) + |
| 413 | "',path='" + std::string(power::path) + "',arg0='" + |
| 414 | std::string(power::interface) + "'", |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 415 | [hostStatusCallback](sdbusplus::message_t& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 416 | std::string objectName; |
| 417 | boost::container::flat_map<std::string, std::variant<std::string>> |
| 418 | values; |
| 419 | message.read(objectName, values); |
| 420 | auto findState = values.find(power::property); |
| 421 | if (findState != values.end()) |
| 422 | { |
| 423 | bool on = boost::ends_with(std::get<std::string>(findState->second), |
| 424 | ".Running"); |
| 425 | if (!on) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 426 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 427 | timer.cancel(); |
| 428 | powerStatusOn = false; |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 429 | hostStatusCallback(PowerState::on, powerStatusOn); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 430 | return; |
| 431 | } |
| 432 | // on comes too quickly |
| 433 | timer.expires_after(std::chrono::seconds(10)); |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 434 | timer.async_wait( |
| 435 | [hostStatusCallback](boost::system::error_code ec) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 436 | if (ec == boost::asio::error::operation_aborted) |
James Feist | 43d32fe | 2019-09-04 10:35:20 -0700 | [diff] [blame] | 437 | { |
James Feist | 43d32fe | 2019-09-04 10:35:20 -0700 | [diff] [blame] | 438 | return; |
| 439 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 440 | if (ec) |
| 441 | { |
| 442 | std::cerr << "Timer error " << ec.message() << "\n"; |
| 443 | return; |
| 444 | } |
| 445 | powerStatusOn = true; |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 446 | hostStatusCallback(PowerState::on, powerStatusOn); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 447 | }); |
| 448 | } |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 449 | }); |
| 450 | |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 451 | postMatch = std::make_unique<sdbusplus::bus::match_t>( |
| 452 | static_cast<sdbusplus::bus_t&>(*conn), |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 453 | "type='signal',interface='" + std::string(properties::interface) + |
| 454 | "',path='" + std::string(post::path) + "',arg0='" + |
| 455 | std::string(post::interface) + "'", |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 456 | [hostStatusCallback](sdbusplus::message_t& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 457 | std::string objectName; |
| 458 | boost::container::flat_map<std::string, std::variant<std::string>> |
| 459 | values; |
| 460 | message.read(objectName, values); |
| 461 | auto findState = values.find(post::property); |
| 462 | if (findState != values.end()) |
| 463 | { |
| 464 | auto& value = std::get<std::string>(findState->second); |
| 465 | biosHasPost = (value != "Inactive") && |
| 466 | (value != "xyz.openbmc_project.State.OperatingSystem." |
| 467 | "Status.OSStatus.Inactive"); |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 468 | hostStatusCallback(PowerState::biosPost, biosHasPost); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 469 | } |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 470 | }); |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 471 | |
James Feist | 8aeffd9 | 2020-09-14 12:08:28 -0700 | [diff] [blame] | 472 | getPowerStatus(conn); |
| 473 | getPostStatus(conn); |
James Feist | 3f0e876 | 2018-11-27 11:30:42 -0800 | [diff] [blame] | 474 | } |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 475 | |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 476 | void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn) |
| 477 | { |
| 478 | setupPowerMatchCallback(conn, [](PowerState, bool) {}); |
| 479 | } |
| 480 | |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 481 | // replaces limits if MinReading and MaxReading are found. |
| 482 | void findLimits(std::pair<double, double>& limits, |
| 483 | const SensorBaseConfiguration* data) |
| 484 | { |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 485 | if (data == nullptr) |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 486 | { |
| 487 | return; |
| 488 | } |
| 489 | auto maxFind = data->second.find("MaxReading"); |
| 490 | auto minFind = data->second.find("MinReading"); |
| 491 | |
| 492 | if (minFind != data->second.end()) |
| 493 | { |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 494 | limits.first = std::visit(VariantToDoubleVisitor(), minFind->second); |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 495 | } |
| 496 | if (maxFind != data->second.end()) |
| 497 | { |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 498 | limits.second = std::visit(VariantToDoubleVisitor(), maxFind->second); |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 499 | } |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 500 | } |
James Feist | 82bac4c | 2019-03-11 11:16:53 -0700 | [diff] [blame] | 501 | |
| 502 | void createAssociation( |
| 503 | std::shared_ptr<sdbusplus::asio::dbus_interface>& association, |
| 504 | const std::string& path) |
| 505 | { |
| 506 | if (association) |
| 507 | { |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 508 | fs::path p(path); |
James Feist | d2543f8 | 2019-04-09 11:10:06 -0700 | [diff] [blame] | 509 | |
James Feist | 82bac4c | 2019-03-11 11:16:53 -0700 | [diff] [blame] | 510 | std::vector<Association> associations; |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 511 | associations.emplace_back("chassis", "all_sensors", |
| 512 | p.parent_path().string()); |
James Feist | 2adc95c | 2019-09-30 14:55:28 -0700 | [diff] [blame] | 513 | association->register_property("Associations", associations); |
James Feist | 82bac4c | 2019-03-11 11:16:53 -0700 | [diff] [blame] | 514 | association->initialize(); |
| 515 | } |
James Feist | 43d32fe | 2019-09-04 10:35:20 -0700 | [diff] [blame] | 516 | } |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 517 | |
| 518 | void setInventoryAssociation( |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 519 | const std::shared_ptr<sdbusplus::asio::dbus_interface>& association, |
AppaRao Puli | c82213c | 2020-02-27 01:24:58 +0530 | [diff] [blame] | 520 | const std::string& path, |
| 521 | const std::vector<std::string>& chassisPaths = std::vector<std::string>()) |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 522 | { |
| 523 | if (association) |
| 524 | { |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 525 | fs::path p(path); |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 526 | std::vector<Association> associations; |
AppaRao Puli | c82213c | 2020-02-27 01:24:58 +0530 | [diff] [blame] | 527 | std::string objPath(p.parent_path().string()); |
| 528 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 529 | associations.emplace_back("inventory", "sensors", objPath); |
| 530 | associations.emplace_back("chassis", "all_sensors", objPath); |
AppaRao Puli | c82213c | 2020-02-27 01:24:58 +0530 | [diff] [blame] | 531 | |
| 532 | for (const std::string& chassisPath : chassisPaths) |
| 533 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 534 | associations.emplace_back("chassis", "all_sensors", chassisPath); |
AppaRao Puli | c82213c | 2020-02-27 01:24:58 +0530 | [diff] [blame] | 535 | } |
| 536 | |
James Feist | 2adc95c | 2019-09-30 14:55:28 -0700 | [diff] [blame] | 537 | association->register_property("Associations", associations); |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 538 | association->initialize(); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | void createInventoryAssoc( |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 543 | const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 544 | const std::shared_ptr<sdbusplus::asio::dbus_interface>& association, |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 545 | const std::string& path) |
| 546 | { |
| 547 | if (!association) |
| 548 | { |
| 549 | return; |
| 550 | } |
AppaRao Puli | c82213c | 2020-02-27 01:24:58 +0530 | [diff] [blame] | 551 | |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 552 | conn->async_method_call( |
| 553 | [association, path](const boost::system::error_code ec, |
AppaRao Puli | c82213c | 2020-02-27 01:24:58 +0530 | [diff] [blame] | 554 | const std::vector<std::string>& invSysObjPaths) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 555 | if (ec) |
| 556 | { |
| 557 | // In case of error, set the default associations and |
| 558 | // initialize the association Interface. |
| 559 | setInventoryAssociation(association, path); |
| 560 | return; |
| 561 | } |
| 562 | setInventoryAssociation(association, path, invSysObjPaths); |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 563 | }, |
| 564 | mapper::busName, mapper::path, mapper::interface, "GetSubTreePaths", |
| 565 | "/xyz/openbmc_project/inventory/system", 2, |
| 566 | std::array<std::string, 1>{ |
| 567 | "xyz.openbmc_project.Inventory.Item.System"}); |
| 568 | } |
Zbigniew Kurzynski | 63f3866 | 2020-06-09 13:02:11 +0200 | [diff] [blame] | 569 | |
| 570 | std::optional<double> readFile(const std::string& thresholdFile, |
| 571 | const double& scaleFactor) |
| 572 | { |
| 573 | std::string line; |
| 574 | std::ifstream labelFile(thresholdFile); |
| 575 | if (labelFile.good()) |
| 576 | { |
| 577 | std::getline(labelFile, line); |
| 578 | labelFile.close(); |
| 579 | |
| 580 | try |
| 581 | { |
| 582 | return std::stod(line) / scaleFactor; |
| 583 | } |
| 584 | catch (const std::invalid_argument&) |
| 585 | { |
| 586 | return std::nullopt; |
| 587 | } |
| 588 | } |
| 589 | return std::nullopt; |
| 590 | } |
| 591 | |
| 592 | std::optional<std::tuple<std::string, std::string, std::string>> |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 593 | splitFileName(const fs::path& filePath) |
Zbigniew Kurzynski | 63f3866 | 2020-06-09 13:02:11 +0200 | [diff] [blame] | 594 | { |
| 595 | if (filePath.has_filename()) |
| 596 | { |
| 597 | const auto fileName = filePath.filename().string(); |
Zbigniew Kurzynski | 63f3866 | 2020-06-09 13:02:11 +0200 | [diff] [blame] | 598 | |
Zbigniew Kurzynski | dd64800 | 2020-07-10 16:44:16 +0200 | [diff] [blame] | 599 | size_t numberPos = std::strcspn(fileName.c_str(), "1234567890"); |
| 600 | size_t itemPos = std::strcspn(fileName.c_str(), "_"); |
| 601 | |
| 602 | if (numberPos > 0 && itemPos > numberPos && fileName.size() > itemPos) |
Zbigniew Kurzynski | 63f3866 | 2020-06-09 13:02:11 +0200 | [diff] [blame] | 603 | { |
Zbigniew Kurzynski | dd64800 | 2020-07-10 16:44:16 +0200 | [diff] [blame] | 604 | return std::make_optional( |
| 605 | std::make_tuple(fileName.substr(0, numberPos), |
| 606 | fileName.substr(numberPos, itemPos - numberPos), |
| 607 | fileName.substr(itemPos + 1, fileName.size()))); |
Zbigniew Kurzynski | 63f3866 | 2020-06-09 13:02:11 +0200 | [diff] [blame] | 608 | } |
| 609 | } |
| 610 | return std::nullopt; |
Zbigniew Kurzynski | dd64800 | 2020-07-10 16:44:16 +0200 | [diff] [blame] | 611 | } |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 612 | |
Arun P. Mohanan | 45f844a | 2021-11-03 22:18:09 +0530 | [diff] [blame] | 613 | static void handleSpecialModeChange(const std::string& manufacturingModeStatus) |
| 614 | { |
| 615 | manufacturingMode = false; |
| 616 | if (manufacturingModeStatus == "xyz.openbmc_project.Control.Security." |
| 617 | "SpecialMode.Modes.Manufacturing") |
| 618 | { |
| 619 | manufacturingMode = true; |
| 620 | } |
Ed Tanous | 74cffa8 | 2022-01-25 13:00:28 -0800 | [diff] [blame] | 621 | if (validateUnsecureFeature == 1) |
Arun P. Mohanan | 45f844a | 2021-11-03 22:18:09 +0530 | [diff] [blame] | 622 | { |
| 623 | if (manufacturingModeStatus == "xyz.openbmc_project.Control.Security." |
| 624 | "SpecialMode.Modes.ValidationUnsecure") |
| 625 | { |
| 626 | manufacturingMode = true; |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 631 | void setupManufacturingModeMatch(sdbusplus::asio::connection& conn) |
| 632 | { |
Arun P. Mohanan | 45f844a | 2021-11-03 22:18:09 +0530 | [diff] [blame] | 633 | namespace rules = sdbusplus::bus::match::rules; |
| 634 | static constexpr const char* specialModeInterface = |
| 635 | "xyz.openbmc_project.Security.SpecialMode"; |
| 636 | |
| 637 | const std::string filterSpecialModeIntfAdd = |
| 638 | rules::interfacesAdded() + |
| 639 | rules::argNpath(0, "/xyz/openbmc_project/security/special_mode"); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 640 | static std::unique_ptr<sdbusplus::bus::match_t> specialModeIntfMatch = |
| 641 | std::make_unique<sdbusplus::bus::match_t>(conn, |
| 642 | filterSpecialModeIntfAdd, |
| 643 | [](sdbusplus::message_t& m) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 644 | sdbusplus::message::object_path path; |
| 645 | using PropertyMap = |
| 646 | boost::container::flat_map<std::string, std::variant<std::string>>; |
| 647 | boost::container::flat_map<std::string, PropertyMap> interfaceAdded; |
| 648 | m.read(path, interfaceAdded); |
| 649 | auto intfItr = interfaceAdded.find(specialModeInterface); |
| 650 | if (intfItr == interfaceAdded.end()) |
| 651 | { |
| 652 | return; |
| 653 | } |
| 654 | PropertyMap& propertyList = intfItr->second; |
| 655 | auto itr = propertyList.find("SpecialMode"); |
| 656 | if (itr == propertyList.end()) |
| 657 | { |
| 658 | std::cerr << "error getting SpecialMode property " |
| 659 | << "\n"; |
| 660 | return; |
| 661 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 662 | auto* manufacturingModeStatus = std::get_if<std::string>(&itr->second); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 663 | handleSpecialModeChange(*manufacturingModeStatus); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 664 | }); |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 665 | |
Arun P. Mohanan | 45f844a | 2021-11-03 22:18:09 +0530 | [diff] [blame] | 666 | const std::string filterSpecialModeChange = |
| 667 | rules::type::signal() + rules::member("PropertiesChanged") + |
| 668 | rules::interface("org.freedesktop.DBus.Properties") + |
| 669 | rules::argN(0, specialModeInterface); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 670 | static std::unique_ptr<sdbusplus::bus::match_t> specialModeChangeMatch = |
| 671 | std::make_unique<sdbusplus::bus::match_t>(conn, filterSpecialModeChange, |
| 672 | [](sdbusplus::message_t& m) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 673 | std::string interfaceName; |
| 674 | boost::container::flat_map<std::string, std::variant<std::string>> |
| 675 | propertiesChanged; |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 676 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 677 | m.read(interfaceName, propertiesChanged); |
| 678 | auto itr = propertiesChanged.find("SpecialMode"); |
| 679 | if (itr == propertiesChanged.end()) |
| 680 | { |
| 681 | return; |
| 682 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 683 | auto* manufacturingModeStatus = std::get_if<std::string>(&itr->second); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 684 | handleSpecialModeChange(*manufacturingModeStatus); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 685 | }); |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 686 | |
Arun P. Mohanan | 45f844a | 2021-11-03 22:18:09 +0530 | [diff] [blame] | 687 | conn.async_method_call( |
| 688 | [](const boost::system::error_code ec, |
| 689 | const std::variant<std::string>& getManufactMode) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 690 | if (ec) |
| 691 | { |
| 692 | std::cerr << "error getting SpecialMode status " << ec.message() |
| 693 | << "\n"; |
| 694 | return; |
| 695 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 696 | const auto* manufacturingModeStatus = |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 697 | std::get_if<std::string>(&getManufactMode); |
| 698 | handleSpecialModeChange(*manufacturingModeStatus); |
Arun P. Mohanan | 45f844a | 2021-11-03 22:18:09 +0530 | [diff] [blame] | 699 | }, |
| 700 | "xyz.openbmc_project.SpecialMode", |
| 701 | "/xyz/openbmc_project/security/special_mode", |
| 702 | "org.freedesktop.DBus.Properties", "Get", specialModeInterface, |
| 703 | "SpecialMode"); |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | bool getManufacturingMode() |
| 707 | { |
| 708 | return manufacturingMode; |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 709 | } |
Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame^] | 710 | |
| 711 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> |
| 712 | setupPropertiesChangedMatches( |
| 713 | sdbusplus::asio::connection& bus, std::span<const char* const> types, |
| 714 | const std::function<void(sdbusplus::message_t&)>& handler) |
| 715 | { |
| 716 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches; |
| 717 | for (const char* type : types) |
| 718 | { |
| 719 | auto match = std::make_unique<sdbusplus::bus::match_t>( |
| 720 | static_cast<sdbusplus::bus_t&>(bus), |
| 721 | "type='signal',member='PropertiesChanged',path_namespace='" + |
| 722 | std::string(inventoryPath) + "',arg0namespace='" + type + "'", |
| 723 | handler); |
| 724 | matches.emplace_back(std::move(match)); |
| 725 | } |
| 726 | return matches; |
| 727 | } |