From 5325f2cba7154825c8c887bc099f01b35c70279f Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 8 Jan 2018 15:17:09 -0800 Subject: watchdog: Implement error on reset of disabled watchdog This enables the host to recover when the BMC resets or the daemon loses state for some reason. A well formed host will resend the SetTimeout command if it encounters this error code. Change-Id: Ib5fd50ac3ad83ef820f0209354aa8f084a563995 Signed-off-by: William A. Kennington III --- app/watchdog.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/watchdog.cpp b/app/watchdog.cpp index 84e8426..7b04faa 100644 --- a/app/watchdog.cpp +++ b/app/watchdog.cpp @@ -124,7 +124,8 @@ ipmi_ret_t ipmi_app_reset_watchdog( int r = 0; char *busname = NULL; - // Current time interval that is set in watchdog. + // Current properties of the watchdog daemon. + bool enabled = false; uint64_t interval = 0; // Status code. @@ -140,6 +141,34 @@ ipmi_ret_t ipmi_app_reset_watchdog( goto finish; } + // Check if our watchdog is running + r = sd_bus_call_method(bus, busname, objname, property_iface, + "Get", &error, &reply, "ss", + iface, "Enabled"); + if(r < 0) { + fprintf(stderr, "Failed to get current Enabled msg: %s\n", + strerror(-r)); + goto finish; + } + + // Now extract the value + r = sd_bus_message_read(reply, "v", "b", &enabled); + if (r < 0) { + fprintf(stderr, "Failed to read current Enabled: %s\n", + strerror(-r)); + goto finish; + } + + // If we are not enable we should indicate that + if (!enabled) { + printf("Watchdog not enabled during reset\n"); + rc = IPMI_WDOG_CC_NOT_INIT; + goto finish; + } + + sd_bus_error_free(&error); + reply = sd_bus_message_unref(reply); + // Get the current interval and set it back. r = sd_bus_call_method(bus, busname, objname, property_iface, "Get", &error, &reply, "ss", -- cgit v1.2.1