Skip to content

Commit a5254e8

Browse files
committed
oem-ibm: Handle the json parse exception correctly
This commit handles the CoD license json parsing exception by correctly catching it and returns the error to the caller. Also made the change to avoid the removal of license json file whenever shared by the host. Tested: Done the sanity testing to verify that json file was kept without removal. Signed-off-by: Jayashankar Padath <[email protected]>
1 parent b4100da commit a5254e8

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

libpldmresponder/bios_config.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,20 @@ void BIOSConfig::initBIOSAttributes(const std::string& systemType,
128128

129129
buildTables();
130130

131+
info("Register listenPendingAttributes");
132+
listenPendingAttributes();
133+
131134
if (pendingAttributes.size())
132135
{
133136
try
134137
{
135-
info("Setting Pending Attributes");
138+
for (const auto& pair : pendingAttributes)
139+
{
140+
info("Pending Attribute is {A}", "A", pair.first);
141+
}
142+
143+
info("Setting Pending Attributes {NUMBER}", "NUMBER",
144+
(int)pendingAttributes.size());
136145
auto method = bus.new_method_call(service.c_str(), biosObjPath,
137146
dbusProperties, "Set");
138147
method.append(biosInterface, "PendingAttributes",
@@ -145,8 +154,6 @@ void BIOSConfig::initBIOSAttributes(const std::string& systemType,
145154
"ERROR", e);
146155
}
147156
}
148-
info("Register listenPendingAttributes");
149-
listenPendingAttributes();
150157
if (registerService)
151158
{
152159
requestPLDMServiceName();
@@ -581,6 +588,7 @@ void BIOSConfig::updateBaseBIOSTableProperty()
581588
// the base bios table is initialised.
582589
if ((attrName == "fw_boot_side") && fs::exists(bootSideDirPath))
583590
{
591+
info("Updating Basebiostable for fw_boot_side");
584592
BiosAttributeList biosAttrList;
585593
std::string nextBootSide =
586594
std::get<std::string>(std::get<5>(biostabObj));

oem/ibm/libpldmresponder/file_io_type_lic.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ int LicenseHandler::updateBinFileAndLicObjs(const fs::path& newLicJsonFilePath)
3333
int rc = PLDM_SUCCESS;
3434
fs::path newLicFilePath(fs::path(licFilePath) / newLicenseFile);
3535
std::ifstream jsonFileNew(newLicJsonFilePath);
36+
Json dataNew;
3637

37-
auto dataNew = Json::parse(jsonFileNew, nullptr, false);
38-
if (dataNew.is_discarded())
38+
try
39+
{
40+
dataNew = Json::parse(jsonFileNew);
41+
}
42+
catch (const Json::parse_error& e)
3943
{
4044
error("Failed to parse the new license json file '{NEW_LIC_JSON}'",
4145
"NEW_LIC_JSON", newLicJsonFilePath);
42-
throw InternalFailure();
46+
return PLDM_ERROR_INVALID_DATA;
4347
}
4448

4549
// Store the json data in a file with binary format

oem/ibm/libpldmresponder/oem_ibm_handler.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,10 @@ void pldm::responder::oem_ibm_platform::Handler::_processSystemReboot(
13671367
"RequestedPowerTransition", "string"};
13681368
try
13691369
{
1370-
info("InbandCodeUpdate: ChassifOff the host");
1370+
info(
1371+
"InbandCodeUpdate: ChassisOff the host. Current Boot Side {C}, Next boot Side {N}",
1372+
"C", getBiosAttrValue("fw_boot_side_current"), "N",
1373+
getBiosAttrValue("fw_boot_side"));
13711374
dBusIntf->setDbusProperty(dbusMapping, value);
13721375
}
13731376
catch (const std::exception& e)

oem/ibm/libpldmresponder/utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,12 @@ int createOrUpdateLicenseObjs()
407407

408408
if (fs::exists(newLicFilePath))
409409
{
410-
fs::remove_all(newLicFilePath);
410+
// fs::remove_all(newLicFilePath);
411411
}
412412

413413
if (fs::exists(newLicJsonFilePath))
414414
{
415-
fs::remove_all(newLicJsonFilePath);
415+
// fs::remove_all(newLicJsonFilePath);
416416
}
417417
}
418418

0 commit comments

Comments
 (0)