update_service: fix fwUpdateErrorMatcher cannot working
Because the phosphor logging commit ef952af2 stop emitting the
propChanged signal before ifacesAdded signal raising, the
fwUpdateErrorMatcher cannot get any software error after image update.
Update fwUpdateErrorMatcher to get ifacesAdded dbus signal to handle
software error.
Tested:
Post bad manifest image and get "Invalid manifest" error response
Signed-off-by: Brian Ma <chma0@nuvoton.com>
Change-Id: I066e0cec0ddf7569dd73b2601f838c697bac24da
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index fde878e..5f56e35 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -316,70 +316,83 @@
fwUpdateErrorMatcher = std::make_unique<sdbusplus::bus::match::match>(
*crow::connections::systemBus,
- "type='signal',member='PropertiesChanged',path_namespace='/xyz/"
- "openbmc_project/logging/entry',"
- "arg0='xyz.openbmc_project.Logging.Entry'",
+ "interface='org.freedesktop.DBus.ObjectManager',type='signal',"
+ "member='InterfacesAdded',"
+ "path='/xyz/openbmc_project/logging'",
[asyncResp, url](sdbusplus::message::message& m) {
- BMCWEB_LOG_DEBUG << "Error Match fired";
- boost::container::flat_map<std::string,
- dbus::utility::DbusVariantType>
- values;
- std::string objName;
- m.read(objName, values);
- auto find = values.find("Message");
- if (find == values.end())
+ std::vector<
+ std::pair<std::string, dbus::utility::DBusPropertiesMap>>
+ interfacesProperties;
+ sdbusplus::message::object_path objPath;
+ m.read(objPath, interfacesProperties);
+ BMCWEB_LOG_DEBUG << "obj path = " << objPath.str;
+ for (const std::pair<std::string, dbus::utility::DBusPropertiesMap>&
+ interface : interfacesProperties)
{
- return;
- }
- std::string* type = std::get_if<std::string>(&(find->second));
- if (type == nullptr)
- {
- return; // if this was our message, timeout will cover it
- }
- if (!boost::starts_with(*type, "xyz.openbmc_project.Software"))
- {
- return;
- }
- if (*type ==
- "xyz.openbmc_project.Software.Image.Error.UnTarFailure")
- {
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid archive");
- }
- else if (
- *type ==
- "xyz.openbmc_project.Software.Image.Error.ManifestFileFailure")
- {
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid manifest");
- }
- else if (*type ==
- "xyz.openbmc_project.Software.Image.Error.ImageFailure")
- {
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid image format");
- }
- else if (*type ==
- "xyz.openbmc_project.Software.Version.Error.AlreadyExists")
- {
+ if (interface.first == "xyz.openbmc_project.Logging.Entry")
+ {
+ BMCWEB_LOG_DEBUG << "Error Match fired";
+ const dbus::utility::DBusPropertiesMap& values =
+ interface.second;
+ auto find = values.find("Message");
+ if (find == values.end())
+ {
+ return;
+ }
+ const std::string* type =
+ std::get_if<std::string>(&(find->second));
+ if (type == nullptr)
+ {
+ // if this was our message, timeout will cover it
+ return;
+ }
+ fwAvailableTimer = nullptr;
+ if (*type ==
+ "xyz.openbmc_project.Software.Image.Error.UnTarFailure")
+ {
+ redfish::messages::invalidUpload(asyncResp->res, url,
+ "Invalid archive");
+ }
+ else if (*type ==
+ "xyz.openbmc_project.Software.Image.Error."
+ "ManifestFileFailure")
+ {
+ redfish::messages::invalidUpload(asyncResp->res, url,
+ "Invalid manifest");
+ }
+ else if (
+ *type ==
+ "xyz.openbmc_project.Software.Image.Error.ImageFailure")
+ {
+ redfish::messages::invalidUpload(
+ asyncResp->res, url, "Invalid image format");
+ }
+ else if (
+ *type ==
+ "xyz.openbmc_project.Software.Version.Error.AlreadyExists")
+ {
+ redfish::messages::invalidUpload(
+ asyncResp->res, url,
+ "Image version already exists");
- redfish::messages::invalidUpload(
- asyncResp->res, url, "Image version already exists");
-
- redfish::messages::resourceAlreadyExists(
- asyncResp->res, "UpdateService.v1_5_0.UpdateService",
- "Version", "uploaded version");
+ redfish::messages::resourceAlreadyExists(
+ asyncResp->res,
+ "UpdateService.v1_5_0.UpdateService", "Version",
+ "uploaded version");
+ }
+ else if (
+ *type ==
+ "xyz.openbmc_project.Software.Image.Error.BusyFailure")
+ {
+ redfish::messages::resourceExhaustion(asyncResp->res,
+ url);
+ }
+ else
+ {
+ redfish::messages::internalError(asyncResp->res);
+ }
+ }
}
- else if (*type ==
- "xyz.openbmc_project.Software.Image.Error.BusyFailure")
- {
- redfish::messages::resourceExhaustion(asyncResp->res, url);
- }
- else
- {
- redfish::messages::internalError(asyncResp->res);
- }
- fwAvailableTimer = nullptr;
});
}