Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 1 | #include "hyp_network_manager.hpp" |
| 2 | |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 3 | #include <phosphor-logging/log.hpp> |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 4 | #include <sdeventplus/event.hpp> |
William A. Kennington III | b740196 | 2023-07-21 16:36:11 -0700 | [diff] [blame^] | 5 | #include <stdplus/print.hpp> |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 6 | |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 7 | using phosphor::logging::entry; |
| 8 | using phosphor::logging::level; |
| 9 | using phosphor::logging::log; |
| 10 | |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 11 | constexpr char DEFAULT_HYP_NW_OBJPATH[] = |
| 12 | "/xyz/openbmc_project/network/hypervisor"; |
| 13 | constexpr char HYP_DEFAULT_NETWORK_BUSNAME[] = |
| 14 | "xyz.openbmc_project.Network.Hypervisor"; |
| 15 | |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 16 | namespace phosphor |
| 17 | { |
| 18 | namespace network |
| 19 | { |
| 20 | |
| 21 | int main() |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 22 | { |
| 23 | auto bus = sdbusplus::bus::new_default(); |
| 24 | |
| 25 | // Add sdbusplus ObjectManager |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 26 | sdbusplus::server::manager_t objManager(bus, DEFAULT_HYP_NW_OBJPATH); |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 27 | |
| 28 | // Get default event loop |
| 29 | auto event = sdeventplus::Event::get_default(); |
| 30 | |
| 31 | // Attach the bus to sd_event to service user requests |
| 32 | bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL); |
| 33 | |
| 34 | // Create hypervisor network manager dbus object |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 35 | auto manager = std::make_unique<HypNetworkMgr>(bus, DEFAULT_HYP_NW_OBJPATH); |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 36 | |
Asmitha Karunanithi | a6c0757 | 2022-05-05 03:19:45 -0500 | [diff] [blame] | 37 | // Create the hypervisor eth interface objects |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 38 | manager->createIfObjects(); |
Asmitha Karunanithi | a6c0757 | 2022-05-05 03:19:45 -0500 | [diff] [blame] | 39 | |
Asmitha Karunanithi | eb40f08 | 2021-07-22 06:13:04 -0500 | [diff] [blame] | 40 | // Create the hypervisor system config object |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 41 | manager->createSysConfObj(); |
| 42 | const SystemConfPtr& systemConfigObj = manager->getSystemConf(); |
Asmitha Karunanithi | eb40f08 | 2021-07-22 06:13:04 -0500 | [diff] [blame] | 43 | systemConfigObj->setHostName(); |
| 44 | |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 45 | bus.request_name(HYP_DEFAULT_NETWORK_BUSNAME); |
| 46 | |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 47 | return event.loop(); |
| 48 | } |
| 49 | |
| 50 | } // namespace network |
| 51 | } // namespace phosphor |
| 52 | |
| 53 | int main(int /*argc*/, char** /*argv*/) |
| 54 | { |
| 55 | try |
| 56 | { |
| 57 | return phosphor::network::main(); |
| 58 | } |
| 59 | catch (const std::exception& e) |
| 60 | { |
William A. Kennington III | b740196 | 2023-07-21 16:36:11 -0700 | [diff] [blame^] | 61 | stdplus::print(stderr, "FAILED: {}", e.what()); |
Asmitha Karunanithi | c24de88 | 2021-06-08 11:56:00 -0500 | [diff] [blame] | 62 | fflush(stderr); |
| 63 | return 1; |
| 64 | } |
Asmitha Karunanithi | be2bdec | 2021-05-13 02:54:29 -0500 | [diff] [blame] | 65 | } |