]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Report version data via guestinfo vars.
authorOliver Kurth <okurth@vmware.com>
Fri, 29 Sep 2017 19:52:44 +0000 (12:52 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 29 Sep 2017 19:52:44 +0000 (12:52 -0700)
open-vm-tools/services/vmtoolsd/mainLoop.c

index 98670d4c71b1bee3e237bf5a172a0b65d18dce65..fc3e4df959f0d920f4abdced5ed811bad4facf23 100644 (file)
@@ -175,6 +175,86 @@ ToolsCoreIOFreezeCb(gpointer src,
 }
 
 
+/*
+ ******************************************************************************
+ * ToolsCoreReportVersionData --                                         */ /**
+ *
+ * Report version info as guest variables.
+ *
+ * @param[in]  state       Service state.
+ *
+ ******************************************************************************
+ */
+
+static void
+ToolsCoreReportVersionData(ToolsServiceState *state)
+{
+   char *value;
+   const static char cmdPrefix[] = "info-set guestinfo.vmtools.";
+
+   /*
+    * These values are documented with specific formats.  Do not change
+    * the formats, as client code can depend on them.
+    */
+
+
+   /*
+    * Version description as a human-readable string.  This value should
+    * not be parsed, so its format can be modified if necessary.
+    */
+   value = g_strdup_printf("%sdescription "
+#ifdef OPEN_VM_TOOLS
+                           "open-vm-tools %s build %s",
+#else
+                           "VMware Tools %s build %s",
+#endif
+                           cmdPrefix,
+                           TOOLS_VERSION_CURRENT_STR,
+                           BUILD_NUMBER_NUMERIC_STRING);
+   if (!RpcChannel_Send(state->ctx.rpc, value,
+                        strlen(value) + 1, NULL, NULL)) {
+      g_warning("%s: failed to send description", __FUNCTION__);
+   }
+   g_free(value);
+
+   /*
+    * Version number as a code-readable string.  This value can
+    * be parsed, so its format should not be modified.
+    */
+   value = g_strdup_printf("%sversionString "
+                           "%s", cmdPrefix, TOOLS_VERSION_CURRENT_STR);
+   if (!RpcChannel_Send(state->ctx.rpc, value,
+                        strlen(value) + 1, NULL, NULL)) {
+      g_warning("%s: failed to send versionString", __FUNCTION__);
+   }
+   g_free(value);
+
+   /*
+    * Version number as a code-readable integer.  This value can
+    * be parsed, so its format should not be modified.
+    */
+   value = g_strdup_printf("%sversionNumber "
+                           "%d", cmdPrefix, TOOLS_VERSION_CURRENT);
+   if (!RpcChannel_Send(state->ctx.rpc, value,
+                         strlen(value) + 1, NULL, NULL)) {
+      g_warning("%s: failed to send versionNumber", __FUNCTION__);
+   }
+   g_free(value);
+
+   /*
+    * Build number as a code-readable integer.  This value can
+    * be parsed, so its format should not be modified.
+    */
+   value = g_strdup_printf("%sbuildNumber "
+                           "%d", cmdPrefix, BUILD_NUMBER_NUMERIC);
+   if (!RpcChannel_Send(state->ctx.rpc, value,
+                        strlen(value) + 1, NULL, NULL)) {
+      g_warning("%s: failed to send buildNumber", __FUNCTION__);
+   }
+   g_free(value);
+}
+
+
 /*
  ******************************************************************************
  * ToolsCoreRunLoop --                                                  */ /**
@@ -203,6 +283,11 @@ ToolsCoreRunLoop(ToolsServiceState *state)
       return 1;
    }
 
+   /* Report version info as guest Vars */
+   if (state->ctx.rpc) {
+      ToolsCoreReportVersionData(state);
+   }
+
    if (!ToolsCore_LoadPlugins(state)) {
       return 1;
    }