]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Update the tools side code to send VMX the health status event.
authorOliver Kurth <okurth@vmware.com>
Fri, 2 Nov 2018 22:28:25 +0000 (15:28 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 2 Nov 2018 22:28:25 +0000 (15:28 -0700)
open-vm-tools/services/vmtoolsd/mainLoop.c
open-vm-tools/services/vmtoolsd/toolsHangDetector.c
open-vm-tools/services/vmtoolsd/toolsHangDetector.h

index bf6dde84a0a42d866fc4c28048794d7f5c36ff0a..7e0d337a88e436d4e6fe5cee6dd543a379eb068b 100644 (file)
@@ -355,6 +355,8 @@ ToolsCoreResetSignalCb(gpointer src,          // IN
 {
    g_info("Reinitialize the Vmx Guest Logger with a new RPC channel.\n");
    VMTools_SetupVmxGuestLog(TRUE, ctx->config, NULL); /* New RPC channel */
+   g_info("Clear out the tools hang detector RPC cache state\n");
+   ToolsCoreHangDetector_RpcReset();
 }
 
 
index 62386750d289fa130b8eda5b9b244a3b68b69d24..25fb8cd29c5455da2a48947d4d0301230f6e1709 100644 (file)
@@ -28,7 +28,8 @@
 #include "vmware/tools/log.h"
 #include "vmware/tools/threadPool.h"
 #include "toolsHangDetector.h"
-
+#include "vmware/guestrpc/tclodefs.h"
+#include "vmware/tools/guestrpc.h"
 
 #define SLEEP_INTERVAL 1         /* approximately 1 second */
 #define CHECKIN_INTERVAL 1       /* approximately 1 second */
@@ -55,6 +56,7 @@ typedef struct HangDetectorState {
     * a resource contention.
     */
    gint64 timeSeq[COUNTER_RESET_VALUE+1];
+   gboolean vmxRejectedHealthUpdate;
 } HangDetectorState;
 
 static HangDetectorState gDetectorState;
@@ -80,6 +82,7 @@ DetectorInit(void)
 
    state->terminate = FALSE;
    state->mode = NORMAL;
+   state->vmxRejectedHealthUpdate = FALSE;
    g_atomic_int_set(&state->atomic, COUNTER_RESET_VALUE);
 }
 
@@ -149,7 +152,36 @@ DetectorTerminate(ToolsAppCtx *ctx,
 static void
 UpdateVmx(const char *event)
 {
-   /* TBD */
+   HangDetectorState *state = &gDetectorState;
+   RpcChannel *chan;
+   gchar *msg;
+
+   if (state->vmxRejectedHealthUpdate) {
+      return;
+   }
+
+   chan = BackdoorChannel_New();
+   if (NULL == chan) {
+      g_warning("Failed to create a RPCI channel to send tools health event.\n");
+      return;
+   }
+
+   if (!RpcChannel_Start(chan)) {
+      g_warning("Failed to start a RPCI channel to send tools health event.\n");
+      RpcChannel_Destroy(chan);
+      return;
+   }
+
+   msg = g_strdup_printf("%s %s", UPDATE_TOOLS_HEALTH_CMD, event);
+   ASSERT(NULL != msg);
+
+   if(!RpcChannel_Send(chan, msg, strlen(msg), NULL, NULL)) {
+      g_warning("Failed to send RPCI message: %s\n", msg);
+      state->vmxRejectedHealthUpdate = TRUE;
+   }
+
+   g_free(msg);
+   RpcChannel_Destroy(chan);
 }
 
 
@@ -224,11 +256,11 @@ UpdateStateToHung(void)
    if (elapsed > SLEEP_INTERVAL * COUNTER_RESET_VALUE * STARVE_THRESHOLD) {
       g_info("tools service was slow for the last %.2f seconds.", elapsed);
 
-      UpdateVmx("slow");
+      UpdateVmx(TOOLS_HEALTH_GUEST_SLOW_KEY);
    } else {
       g_info("tools service hung.");
 
-      UpdateVmx("hang");
+      UpdateVmx(TOOLS_HEALTH_HUNG_KEY);
    }
 }
 
@@ -251,7 +283,7 @@ UpdateStateToNormal(void)
 
    g_info("tools service recovered from a hang.");
 
-   UpdateVmx("recover");
+   UpdateVmx(TOOLS_HEALTH_NORMAL_KEY);
 }
 
 
@@ -477,3 +509,24 @@ exit:
 
    return ret;
 }
+
+
+/*
+ ******************************************************************************
+ * ToolsCoreHangDetector_RpcReset --                                     */ /**
+ *
+ * Rpc Reset Handler for the tools hang detector module.
+ * Just reset the vmxRejectedHealthUpdate boolean flag in case
+ * the VM is migrated to a newer version of host that now supports the
+ * health update.
+ *
+ ******************************************************************************
+ */
+
+void
+ToolsCoreHangDetector_RpcReset(void)
+{
+   HangDetectorState *state = &gDetectorState;
+
+   state->vmxRejectedHealthUpdate = FALSE;
+}
index 89150d210b2c25280690b7051c044c0ece036805..21c2ae782384359875b9e5b1321e918640774d47 100644 (file)
@@ -26,5 +26,6 @@
  */
 
 gboolean ToolsCoreHangDetector_Start(ToolsAppCtx *ctx);
+void ToolsCoreHangDetector_RpcReset(void);
 
 #endif /* _TOOLS_HANG_DETECTOR_H_ */