Add length limit for user-defined values
Previously, the only limit for most user-defined values like id or name
was the one enforced by dbus, which was fairly big. In order to save
space used by persistent data, new meson options were added, with length
limit for those fields.
This directly impacts following dbus interfaces:
- TriggerManager.AddTrigger:
- Id
- Name
- Reports
- Thresholds (only name of discrete threshold)
- Trigger.Name
- Trigger.Reports
- Trigger.Thresholds (only name of discrete threshold)
- ReportManager.AddReport(FutureVersion):
- Id
- Name
- MetricParameters (metricId)
- Report.Name
- Report.ReadingParameters (metricId)
For Id fields we support 'prefixes', which also are limited, but those
limit are separate. So if limit for prefix is set to 5 and limit for
id/name is set to 5, following Ids are fine:
- 12345/12345
- 12345
and following are not:
- 123456/1234
- 1/123456
Testing done:
- UTs are passing.
- new limits are reflected when calling mentioned dbus interfaces.
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I29291a1cc56a344d92fb65491c9186fdb90a8529
diff --git a/src/report_manager.hpp b/src/report_manager.hpp
index 88dc3e0..4882419 100644
--- a/src/report_manager.hpp
+++ b/src/report_manager.hpp
@@ -33,6 +33,9 @@
void removeReport(const interfaces::Report* report) override;
+ static void verifyMetricParameters(
+ const std::vector<LabeledMetricParameters>& readingParams);
+
private:
std::unique_ptr<interfaces::ReportFactory> reportFactory;
std::unique_ptr<interfaces::JsonStorage> reportStorage;
@@ -64,14 +67,14 @@
public:
static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS};
- static constexpr size_t maxReportIdLength{
- TELEMETRY_MAX_DBUS_PATH_LENGTH -
- utils::constants::reportDirStr.length()};
static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL};
static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT};
static constexpr const char* reportManagerIfaceName =
"xyz.openbmc_project.Telemetry.ReportManager";
static constexpr const char* reportManagerPath =
"/xyz/openbmc_project/Telemetry/Reports";
- static constexpr const char* reportNameDefault = "Report";
+ static constexpr std::string_view reportNameDefault = "Report";
+
+ static_assert(!reportNameDefault.empty(),
+ "Default report name cannot be empty.");
};