From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:39 +0000 (-0700) Subject: Report version data via guestinfo vars X-Git-Tag: stable-10.2.0~215 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32c82dc60b2963924ef9f407916e17880ae20b04;p=thirdparty%2Fopen-vm-tools.git Report version data via guestinfo vars Set up some guestVars to report Tools version info (version, build number, etc). --- diff --git a/open-vm-tools/services/vmtoolsd/mainLoop.c b/open-vm-tools/services/vmtoolsd/mainLoop.c index 8081d79db..096831c6a 100644 --- a/open-vm-tools/services/vmtoolsd/mainLoop.c +++ b/open-vm-tools/services/vmtoolsd/mainLoop.c @@ -175,6 +175,89 @@ 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."; + + ASSERT(state); + ASSERT(state->ctx.rpc); + + /* + * 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 +286,9 @@ ToolsCoreRunLoop(ToolsServiceState *state) return 1; } + /* Report version info as guest Vars */ + ToolsCoreReportVersionData(state); + if (!ToolsCore_LoadPlugins(state)) { return 1; }