functions: Catch sdbusplus exception
On systems that do not have Entity Manager implemented such as Tacoma,
the 'openpower-update-manager process-host-firmware' call core dumps
with:
obmc-flash-bios[407]: terminate called after throwing an instance of 'sdbusplus::exception::SdBusError'
obmc-flash-bios[407]: what(): sd_bus_call: org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable
Catch the exception and return the match to allow the interfaces added
signal run the callback if/when the entity manager interfaces appear.
Tested: App does not core dump anymore on tacoma.
Change-Id: Ie90b214c7bdd109dbc970a8de580988738809d16
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/functions.cpp b/functions.cpp
index 40af65a..cad510a 100644
--- a/functions.cpp
+++ b/functions.cpp
@@ -6,6 +6,7 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
+#include <sdbusplus/exception.hpp>
#include <sdbusplus/message.hpp>
#include <sdeventplus/event.hpp>
@@ -385,13 +386,22 @@
auto getManagedObjects = bus.new_method_call(
"xyz.openbmc_project.EntityManager", "/",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
- auto reply = bus.call(getManagedObjects);
std::map<std::string,
std::map<std::string, std::variant<std::vector<std::string>>>>
interfacesAndProperties;
std::map<sdbusplus::message::object_path, decltype(interfacesAndProperties)>
objects;
- reply.read(objects);
+ try
+ {
+ auto reply = bus.call(getManagedObjects);
+ reply.read(objects);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ // Error querying the EntityManager interface. Return the match to have
+ // the callback run if/when the interface appears in D-Bus.
+ return interfacesAddedMatch;
+ }
// bind the extension map, host firmware directory, and error callback to
// the maybeMakeLinks function.