summaryrefslogtreecommitdiffstats
path: root/host-cmd-manager.hpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-06-27 13:01:25 -0500
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-07-24 20:56:11 +0000
commit15309efc2c1cebadbabdb0ef5f74a38fb8b78cfd (patch)
tree739a585033f28e2da1237b80e1545df4deacf305 /host-cmd-manager.hpp
parent1500a64704cf558a1d08d1cf0db7a4a3d550989a (diff)
downloadphosphor-host-ipmid-15309efc2c1cebadbabdb0ef5f74a38fb8b78cfd.tar.gz
phosphor-host-ipmid-15309efc2c1cebadbabdb0ef5f74a38fb8b78cfd.zip
Clear host command queue on a power on
When the RequestedHostTransition property changes to On, clear any pending commands in the command queue. This is done to avoid race conditions around state transitions as well as other scenarios like the following: 1) Host is already off 2) RequestedHostTransition is set to Off 3) RequestedHostTransition is set to On 4) Host powers on 5) Host immediately powers off because of the pending command sent in 2). Resolves openbmc/openbmc#3207 Tested: Verified the scenario above no longer occurs. Change-Id: I26c8195c305c75b01333d1b10ff4bf16d76b91a6 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'host-cmd-manager.hpp')
-rw-r--r--host-cmd-manager.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/host-cmd-manager.hpp b/host-cmd-manager.hpp
index 06ac5fa..c25706c 100644
--- a/host-cmd-manager.hpp
+++ b/host-cmd-manager.hpp
@@ -3,6 +3,7 @@
#include <tuple>
#include <queue>
#include <sdbusplus/bus.hpp>
+#include <sdbusplus/bus/match.hpp>
#include <timer.hpp>
#include <host-ipmid/ipmid-host-cmd-utils.hpp>
@@ -68,6 +69,31 @@ class Manager
*/
void hostTimeout();
+ /** @brief Clears the command queue
+ *
+ * @detail Clears the command queue and calls all callbacks
+ * specifying the command wasn't successful.
+ */
+ void clearQueue();
+
+ /** @brief Clears the command queue on a power on
+ *
+ * @detail The properties changed handler for the
+ * RequestedHostTransition property. When this property
+ * changes to 'On', this function will purge the command
+ * queue.
+ *
+ * This is done to avoid having commands that were issued
+ * before the host powers on from getting sent to the host,
+ * either due to race conditions around state transitions
+ * or from a user doing something like requesting an already
+ * powered off system to power off again and then immediately
+ * requesting a power on.
+ *
+ * @param[in] msg - the sdbusplus message containing the property
+ */
+ void clearQueueOnPowerOn(sdbusplus::message::message& msg);
+
/** @brief Reference to the dbus handler */
sdbusplus::bus::bus& bus;
@@ -76,6 +102,9 @@ class Manager
/** @brief Timer for commands to host */
phosphor::ipmi::Timer timer;
+
+ /** @brief Match handler for the requested host state */
+ sdbusplus::bus::match_t hostTransitionMatch;
};
} // namespace command
OpenPOWER on IntegriCloud