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