Fix BIOS to allow updating attributers via D-Bus
BIOS attribute is changed by pending attributes and the new value
should be shown in D-Bus.
Also BaseBIOSTable should be updated.
Tested:
busctl call xyz.openbmc_project.BIOSConfigManager /xyz/openbmc_project/bios_config/manager org.freedesktop.DBus.Properties Set ssv xyz.openbmc_project.BIOSConfig.Manager PendingAttributes a{s\(sv\)} 1 "pvm_stop_at_standby" "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration" s "Enabled"
busctl get-property xyz.openbmc_project.BIOSConfigManager /xyz/openbmc_project/bios_config/manager xyz.openbmc_project.BIOSConfig.Manager BaseBIOSTable --verbose
```
DICT_ENTRY "s(sbsssvva(sv))" {
STRING "pvm_stop_at_standby";
STRUCT "sbsssvva(sv)" {
STRING "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration";
BOOLEAN false;
STRING "pvm_stop_at_standby";
STRING "pvm_stop_at_standby";
STRING "";
VARIANT "s" {
STRING "Enabled";
};
VARIANT "s" {
STRING "Enabled";
};
ARRAY "(sv)" {
STRUCT "sv" {
STRING "xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf";
VARIANT "s" {
STRING "Disabled";
};
};
STRUCT "sv" {
STRING "xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf";
VARIANT "s" {
STRING "Enabled";
};
};
};
};
};
```
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I74ee9ff843fa9d588f94e4334d015cf55b52aea6
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index b3d827f..c7c408e 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -683,7 +683,7 @@
};
}
-int BIOSConfig::setAttrValue(const void* entry, size_t size,
+int BIOSConfig::setAttrValue(const void* entry, size_t size, bool updateDBus,
bool updateBaseBIOSTable)
{
auto attrValueTable = getBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE);
@@ -735,7 +735,11 @@
{
return PLDM_ERROR;
}
- (*iter)->setAttrValueOnDbus(attrValueEntry, attrEntry, biosStringTable);
+ if (updateDBus)
+ {
+ (*iter)->setAttrValueOnDbus(attrValueEntry, attrEntry,
+ biosStringTable);
+ }
}
catch (const std::exception& e)
{
@@ -838,10 +842,11 @@
storeTable(tableDir / attrValueTableFile, *destTable);
}
- rc = setAttrValue(newValue.data(), newValue.size());
+ rc = setAttrValue(newValue.data(), newValue.size(), false);
if (rc != PLDM_SUCCESS)
{
- std::cerr << "could not setAttrValue on base bios table and dbus \n";
+ std::cerr << "could not setAttrValue on base bios table and dbus, rc = "
+ << rc << "\n";
}
}
@@ -912,7 +917,7 @@
(*iter)->generateAttributeEntry(attributevalue, attrValueEntry);
- setAttrValue(attrValueEntry.data(), attrValueEntry.size(), false);
+ setAttrValue(attrValueEntry.data(), attrValueEntry.size());
}
if (listOfHandles.size())
@@ -925,7 +930,6 @@
return;
}
#endif
- updateBaseBIOSTableProperty();
}
}
diff --git a/libpldmresponder/bios_config.hpp b/libpldmresponder/bios_config.hpp
index 287633c..a6ae3e7 100644
--- a/libpldmresponder/bios_config.hpp
+++ b/libpldmresponder/bios_config.hpp
@@ -80,11 +80,13 @@
/** @brief Set attribute value on dbus and attribute value table
* @param[in] entry - attribute value entry
* @param[in] size - size of the attribute value entry
+ * @param[in] updateDBus - update Attr value D-Bus property
+ * if this is set to true
* @param[in] updateBaseBIOSTable - update BaseBIOSTable D-Bus property
* if this is set to true
* @return pldm_completion_codes
*/
- int setAttrValue(const void* entry, size_t size,
+ int setAttrValue(const void* entry, size_t size, bool updateDBus = true,
bool updateBaseBIOSTable = true);
/** @brief Remove the persistent tables */
diff --git a/libpldmresponder/bios_enum_attribute.cpp b/libpldmresponder/bios_enum_attribute.cpp
index 0808898..7d7cacf 100644
--- a/libpldmresponder/bios_enum_attribute.cpp
+++ b/libpldmresponder/bios_enum_attribute.cpp
@@ -149,21 +149,13 @@
uint8_t BIOSEnumAttribute::getAttrValueIndex(const PropertyValue& propValue)
{
- auto defaultValueIndex = getValueIndex(defaultValue, possibleValues);
-
try
{
- auto iter = valMap.find(propValue);
- if (iter == valMap.end())
- {
- return defaultValueIndex;
- }
- auto currentValue = iter->second;
- return getValueIndex(currentValue, possibleValues);
+ return getValueIndex(std::get<std::string>(propValue), possibleValues);
}
catch (const std::exception& e)
{
- return defaultValueIndex;
+ return getValueIndex(defaultValue, possibleValues);
}
}
@@ -180,7 +172,6 @@
auto currHdls = table::attribute_value::decodeEnumEntry(attrValueEntry);
assert(currHdls.size() == 1);
-
auto valueString = stringTable.findString(pvHdls[currHdls[0]]);
auto it = std::find_if(valMap.begin(), valMap.end(),
@@ -271,14 +262,10 @@
entry->attr_type = 0;
entry->value[0] = 1; // number of current values, default 1
- if (readOnly)
+ if (readOnly || !dBusMap.has_value())
{
entry->value[1] = getValueIndex(defaultValue, possibleValues);
}
- else if (!dBusMap.has_value())
- {
- entry->value[1] = getValueIndex(value, possibleValues);
- }
else
{
entry->value[1] = getAttrValueIndex(value);