1 #include <sdbusplus/bus.hpp> 2 #include <phosphor-logging/elog-errors.hpp> 3 4 #include "xyz/openbmc_project/Common/error.hpp" 5 #include "config.h" 6 #include "dump_manager.hpp" 7 #include "dump_internal.hpp" 8 #include "watch.hpp" 9 #include "elog_watch.hpp" 10 11 int main(int argc, char* argv[]) 12 { 13 using namespace phosphor::logging; 14 using InternalFailure = 15 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 16 17 auto bus = sdbusplus::bus::new_default(); 18 sd_event* event = nullptr; 19 auto rc = sd_event_default(&event); 20 if (rc < 0) 21 { 22 log<level::ERR>("Error occurred during the sd_event_default", 23 entry("rc=%d", rc)); 24 report<InternalFailure>(); 25 return rc; 26 } 27 phosphor::dump::EventPtr eventP{event}; 28 event = nullptr; 29 30 // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager. 31 sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH); 32 bus.request_name(DUMP_BUSNAME); 33 34 try 35 { 36 phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH); 37 //Restore dump d-bus objects. 38 manager.restore(); 39 phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL); 40 phosphor::dump::elog::Watch eWatch(bus, mgr); 41 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); 42 43 auto rc = sd_event_loop(eventP.get()); 44 if (rc < 0) 45 { 46 log<level::ERR>("Error occurred during the sd_event_loop", 47 entry("rc=%d", rc)); 48 elog<InternalFailure>(); 49 } 50 } 51 catch (InternalFailure& e) 52 { 53 commit<InternalFailure>(); 54 return -1; 55 } 56 57 return 0; 58 } 59