#define CONFNAME_LOGFILE "log.file"
#define CONFNAME_LOGLEVEL "log.level"
#define CONFNAME_DISABLETOOLSVERSION "disable-tools-version"
+#define CONFNAME_USELEGACYVERSION "use-legacy-version"
#define CONFNAME_HIDETOOLSVERSION "hide-tools-version"
#define CONFNAME_DISABLEPMTIMERWARNING "disable-pmtimerwarning"
#define CONFGROUPNAME_VMTOOLS "vmtools"
/*********************************************************
- * Copyright (c) 2008-2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 2008-2025 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program is free software; you can redistribute it and/or modify it
# include "w32Messages.h"
# include "windowsu.h"
#endif
+#include "conf.h"
#include "str.h"
#include "system.h"
#include "vmware/tools/log.h"
}
+/**
+ * Function that resets log header of Tools version, build details
+ * and Guest OS details. The format of the version can change.
+ *
+ */
+
+static void
+VMToolsResetLogHeader(void)
+{
+ guint i;
+
+ for (i = 0; i < gLogHeaderCount; i++) {
+ free(gLogHeaderBuf[i]);
+ gLogHeaderBuf[i] = NULL;
+ }
+ gLogHeaderCount = 0;
+}
+
+
/**
* Function that logs a cached log header of Tools version, build details
* and Guest OS details.
gboolean reset)
{
gboolean allocDict = (cfg == NULL);
+ static gboolean gUseLegacyVersion = FALSE; // Default is off
+ gboolean useLegacyVersion = FALSE;
gchar **list;
gchar **curr;
GPtrArray *oldDomains = NULL;
* Cached log headers will be logged at log rotation and reset.
* No need to re-init the log headers in case of config reload.
*/
+ /*
+ * Check the config values to see if revert to older format.
+ * Default is false and new format will be used.
+ */
+ useLegacyVersion = g_key_file_get_boolean(cfg,
+ CONFGROUPNAME_VMTOOLS,
+ CONFNAME_USELEGACYVERSION,
+ NULL);
+ if (gUseLegacyVersion != useLegacyVersion) {
+ VMToolsResetLogHeader();
+ gUseLegacyVersion = useLegacyVersion;
+ }
+
if (gLogHeaderCount == 0) {
+ const char *versionFormat;
+ const char *buildNumberString;
+
LogHandler *handler = GetLogHandlerByDomain(gLogDomain);
GlibLogger *logger = handler->logger;
logger->logHeader = TRUE;
+ if (useLegacyVersion) {
+ versionFormat = "%s Version: %s (%s)";
+ buildNumberString = BUILD_NUMBER;
+ } else {
+ versionFormat = "%s Version: %s.%s";
+ buildNumberString = BUILD_NUMBER_NUMERIC_STRING;
+ }
gLogHeaderBuf[gLogHeaderCount++] = Str_Asprintf(NULL,
- "%s Version: %s (%s)",
+ versionFormat,
VMWARE_TOOLS_SHORT_NAME,
TOOLS_VERSION_EXT_CURRENT_STR,
- BUILD_NUMBER);
+ buildNumberString);
gosDetails = Hostinfo_GetOSDetailedData();
if (gosDetails != NULL && gLogHeaderCount < LOG_HEADER_MAX_ENTRIES) {
/*********************************************************
- * Copyright (c) 2008-2021,2023-2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 2008-2025 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program is free software; you can redistribute it and/or modify it
}
if (version) {
- g_print("%s %s (%s)\n", _("VMware Tools daemon, version"),
- VMTOOLSD_VERSION_STRING, BUILD_NUMBER);
+ /*
+ * Configure logging system, without resetting the logging
+ * if reporting the version. When reporting the version, the
+ * process will immediately exit.
+ */
+ gboolean useLegacyVersion;
+
+ ToolsCore_ReloadConfig(state, FALSE);
+
+ /*
+ * Check the config values to see if revert to older format.
+ * Default is false and new format will be used.
+ */
+ useLegacyVersion = VMTools_ConfigGetBoolean(state->ctx.config,
+ CONFGROUPNAME_VMTOOLS,
+ CONFNAME_USELEGACYVERSION,
+ FALSE);
+ if (useLegacyVersion) {
+ g_print("%s %s (%s)\n", _("VMware Tools daemon, version"),
+ VMTOOLSD_VERSION_STRING, BUILD_NUMBER);
+ } else {
+ g_print("%s %s.%s\n", _("VMware Tools daemon, version"),
+ VMTOOLSD_VERSION_STRING, BUILD_NUMBER_NUMERIC_STRING);
+ }
exit(0);
}
/*********************************************************
- * Copyright (c) 2008-2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 2008-2025 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program is free software; you can redistribute it and/or modify it
*
* Report version info as guest variables.
*
- * @param[in] state Service state.
+ * @param[in] ctx The application context.
*
******************************************************************************
*/
static void
-ToolsCoreReportVersionData(ToolsServiceState *state)
+ToolsCoreReportVersionData(ToolsAppCtx *ctx)
{
char *value;
const static char cmdPrefix[] = "info-set guestinfo.vmtools.";
+ static gboolean useLegacyVersion = FALSE;
+ static gboolean first = TRUE;
+ const char *cmdDescFmt;
+ const char *cmdToolsVersionStr;
+ gboolean confUseLegacyVersion;
/*
* These values are documented with specific formats. Do not change
* the formats, as client code can depend on them.
*/
+ confUseLegacyVersion =
+ VMTools_ConfigGetBoolean(ctx->config,
+ CONFGROUPNAME_VMTOOLS,
+ CONFNAME_USELEGACYVERSION,
+ FALSE);
+
+ /* Nothing to do if not the first call and state is unchanged. */
+ if (!first && (confUseLegacyVersion == useLegacyVersion)) {
+ return;
+ }
+#define CMD_DESCRIPTION "%sdescription "
+#ifdef OPEN_VM_TOOLS
+#define VMTOOLS_PRODUCT "open-vm-tools"
+#else
+#define VMTOOLS_PRODUCT "VMware Tools"
+#endif
+
+ first = FALSE;
+ useLegacyVersion = confUseLegacyVersion;
+ if (useLegacyVersion) {
+ cmdDescFmt = CMD_DESCRIPTION VMTOOLS_PRODUCT " %s build %s";
+ cmdToolsVersionStr = TOOLS_VERSION_CURRENT_STR;
+ } else {
+ cmdDescFmt = CMD_DESCRIPTION VMTOOLS_PRODUCT " %s.%s";
+ cmdToolsVersionStr = TOOLS_VERSION_EXT_CURRENT_STR;
+ }
/*
* 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
+ value = g_strdup_printf(cmdDescFmt,
cmdPrefix,
- TOOLS_VERSION_CURRENT_STR,
+ cmdToolsVersionStr,
BUILD_NUMBER_NUMERIC_STRING);
- if (!RpcChannel_Send(state->ctx.rpc, value,
+ if (!RpcChannel_Send(ctx->rpc, value,
strlen(value) + 1, NULL, NULL)) {
g_warning("%s: failed to send description", __FUNCTION__);
}
* 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,
+ "%s", cmdPrefix, cmdToolsVersionStr);
+ if (!RpcChannel_Send(ctx->rpc, value,
strlen(value) + 1, NULL, NULL)) {
g_warning("%s: failed to send versionString", __FUNCTION__);
}
*/
value = g_strdup_printf("%sversionNumber "
"%d", cmdPrefix, TOOLS_VERSION_CURRENT);
- if (!RpcChannel_Send(state->ctx.rpc, value,
- strlen(value) + 1, NULL, NULL)) {
+ if (!RpcChannel_Send(ctx->rpc, value,
+ strlen(value) + 1, NULL, NULL)) {
g_warning("%s: failed to send versionNumber", __FUNCTION__);
}
g_free(value);
*/
value = g_strdup_printf("%sbuildNumber "
"%d", cmdPrefix, BUILD_NUMBER_NUMERIC);
- if (!RpcChannel_Send(state->ctx.rpc, value,
+ if (!RpcChannel_Send(ctx->rpc, value,
strlen(value) + 1, NULL, NULL)) {
g_warning("%s: failed to send buildNumber", __FUNCTION__);
}
}
+/*
+ ******************************************************************************
+ *
+ * ToolsCoreConfReloadSignalCb --
+ * The tools.conf reload callback. The signal was triggered from
+ * ToolsCore_ReloadConfig. This function is needed to safely run code
+ * outside of the RPC Channel reset code.
+ *
+ * Reinitialize the Vmx Guest variables.
+ *
+ * @param[in] src The source object.
+ * @param[in] ctx The ToolsAppCtx for passing the config.
+ * @param[in] data Unused.
+ *
+ ******************************************************************************
+ */
+
+static void
+ToolsCoreConfReloadSignalCb(gpointer src, // IN
+ ToolsAppCtx *ctx, // IN
+ gpointer data) // IN
+{
+ g_debug("Reinitialize the guest vars for version data.\n");
+ ToolsCoreReportVersionData(ctx); /* Update version guest vars */
+}
+
+
/*
******************************************************************************
* ToolsCoreRunLoop -- */ /**
/* Report version info as guest Vars */
if (state->ctx.rpc) {
- ToolsCoreReportVersionData(state);
+ ToolsCoreReportVersionData(&state->ctx);
}
#if defined(_WIN32)
NULL);
}
+ if (g_signal_lookup(TOOLS_CORE_SIG_CONF_RELOAD,
+ G_OBJECT_TYPE(state->ctx.serviceObj)) != 0) {
+ g_signal_connect(state->ctx.serviceObj,
+ TOOLS_CORE_SIG_CONF_RELOAD,
+ G_CALLBACK(ToolsCoreConfReloadSignalCb),
+ NULL);
+ }
+
state->configCheckTask = g_timeout_add(CONF_POLL_TIME * 1000,
ToolsCoreConfFileCb,
state);
/*********************************************************
- * Copyright (c) 2008-2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 2008-2025 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program is free software; you can redistribute it and/or modify it
{
ToolsServiceState *state = _state;
static gboolean version_sent = FALSE;
+ static gboolean useLegacyVersion = FALSE;
ASSERT(state != NULL);
ASSERT(chan == state->ctx.rpc);
if (success) {
const gchar *app;
gchar *msg;
+ gboolean confUseLegacyVersion;
app = ToolsCore_GetTcloName(state);
if (app == NULL) {
}
g_free(msg);
- if (!version_sent) {
+ /*
+ * Check the config values to see if revert to older format.
+ * Default is false and new format will be used.
+ */
+ confUseLegacyVersion =
+ VMTools_ConfigGetBoolean(state->ctx.config,
+ CONFGROUPNAME_VMTOOLS,
+ CONFNAME_USELEGACYVERSION,
+ FALSE);
+
+ /* Logging reset */
+ if (!version_sent || confUseLegacyVersion != useLegacyVersion) {
/*
* Log the Tools version to the VMX log file. We don't really care
* if sending the message fails.
*/
- msg = g_strdup_printf("log %s: Version: %s (%s)",
- app, VMTOOLSD_VERSION_STRING, BUILD_NUMBER);
+ g_debug("reset vmtools service: using legacy version=%d\n",
+ confUseLegacyVersion);
+ if (confUseLegacyVersion) {
+ msg = g_strdup_printf("log %s: Version: %s (%s)",
+ app, VMTOOLSD_VERSION_STRING, BUILD_NUMBER);
+ } else {
+ msg = g_strdup_printf("log %s: Version: %s.%s",
+ app, VMTOOLSD_VERSION_STRING, BUILD_NUMBER_NUMERIC_STRING);
+ }
RpcChannel_Send(state->ctx.rpc, msg, strlen(msg) + 1, NULL, NULL);
g_free(msg);
/* send message only once to prevent log spewing: */
+ useLegacyVersion = confUseLegacyVersion;
version_sent = TRUE;
}
/*********************************************************
- * Copyright (c) 2008-2021,2023 VMware, Inc. All rights reserved.
+ * Copyright (c) 2008-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include <locale.h>
#include <glib/gstdio.h>
+#include "conf.h"
#include "toolboxCmdInt.h"
#include "toolboxcmd_version.h"
#include "system.h"
}
if (show_version) {
- g_print("%s (%s)\n", TOOLBOXCMD_VERSION_STRING, BUILD_NUMBER);
+ gboolean useLegacyVersion;
+ /*
+ * Check the config values to see if revert to older format.
+ * Default is false and new format will be used.
+ */
+ useLegacyVersion =
+ VMTools_ConfigGetBoolean(conf,
+ CONFGROUPNAME_VMTOOLS,
+ CONFNAME_USELEGACYVERSION,
+ FALSE);
+ if (useLegacyVersion) {
+ g_print("%s (%s)\n", TOOLBOXCMD_VERSION_STRING, BUILD_NUMBER);
+ } else {
+ g_print("%s.%s\n", TOOLBOXCMD_VERSION_STRING, BUILD_NUMBER_NUMERIC_STRING);
+ }
retval = EXIT_SUCCESS;
} else if (show_help) {
ToolboxCmdHelp(argv[0], "help");