diff options
-rw-r--r-- | app/watchdog.cpp | 31 | ||||
-rw-r--r-- | host-ipmid/ipmid-api.h | 1 |
2 files changed, 31 insertions, 1 deletions
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", diff --git a/host-ipmid/ipmid-api.h b/host-ipmid/ipmid-api.h index 5539f9c..5f7bac3 100644 --- a/host-ipmid/ipmid-api.h +++ b/host-ipmid/ipmid-api.h @@ -111,6 +111,7 @@ enum ipmi_return_codes { IPMI_CC_OK = 0x00, IPMI_DCMI_CC_NO_ACTIVE_POWER_LIMIT = 0x80, + IPMI_WDOG_CC_NOT_INIT = 0x80, IPMI_CC_INVALID = 0xC1, IPMI_CC_INVALID_RESERVATION_ID = 0xC5, IPMI_CC_REQ_DATA_LEN_INVALID = 0xC7, |