clear temp reset file on host running

See the following for more information on this file:
https://github.com/openbmc/phosphor-state-manager#bmc-reset-with-host-andor-chassis-on

Currently this file is cleared via two service files in the power
down path. Upon further review, it's best to just clear this once
it has served its purpose which is to allow the host object to
get back into the Running state after the BMC has been reset when the
host is still running.

The simplification allows us to avoid the different corner cases of warm
reboots and memory preserving reboots and how those interact with BMC
reboots with the host up.

Once this change is in, we can remove the deletion of this file from
the service files (op-stop-instructions and op-wait-power-off).

Tested:
- This was tested in combination with the next commit. See it for
  testing details.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Ic1c275b8b06a87906eacfe7827bdb210e55d301a
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 82a24f3..ffb37b1 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -3,6 +3,7 @@
 #include "host_state_manager.hpp"
 
 #include <fmt/format.h>
+#include <stdio.h>
 #include <systemd/sd-bus.h>
 
 #include <cereal/archives/json.hpp>
@@ -17,6 +18,7 @@
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
 
+#include <filesystem>
 #include <fstream>
 #include <iostream>
 #include <map>
@@ -292,6 +294,20 @@
     {
         log<level::INFO>("Received signal that host is running");
         this->currentHostState(server::Host::HostState::Running);
+
+        // Remove temporary file which is utilized for scenarios where the
+        // BMC is rebooted while the host is still up.
+        // This file is used to indicate to host related systemd services
+        // that the host is already running and they should skip running.
+        // Once the host state is back to running we can clear this file.
+        auto size = std::snprintf(nullptr, 0, HOST_RUNNING_FILE, 0);
+        size++; // null
+        std::unique_ptr<char[]> hostFile(new char[size]);
+        std::snprintf(hostFile.get(), size, HOST_RUNNING_FILE, 0);
+        if (std::filesystem::exists(hostFile.get()))
+        {
+            std::filesystem::remove(hostFile.get());
+        }
     }
     else if ((newStateUnit == HOST_STATE_QUIESCE_TGT) &&
              (newStateResult == "done") &&