From: Oliver Kurth Date: Fri, 29 Sep 2017 19:52:44 +0000 (-0700) Subject: Report version data via guestinfo vars. X-Git-Tag: 10.1.15~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6b96c6f143a47d5764dd6e3530b3792c5091105;p=thirdparty%2Fopen-vm-tools.git Report version data via guestinfo vars. --- diff --git a/open-vm-tools/services/vmtoolsd/mainLoop.c b/open-vm-tools/services/vmtoolsd/mainLoop.c index 98670d4c7..fc3e4df95 100644 --- a/open-vm-tools/services/vmtoolsd/mainLoop.c +++ b/open-vm-tools/services/vmtoolsd/mainLoop.c @@ -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; }