#include "util.h"
#include "vm_atomic.h"
#include "vmcheck.h"
+#include "vmware/guestrpc/tclodefs.h"
#include "vmware/tools/log.h"
#include "vmware/tools/threadPool.h"
#include "vmware/tools/utils.h"
*/
static guint gAppInfoPollInterval = 0;
+/**
+ * Defines the state of the App Info at the host side.
+ */
+static gboolean gAppInfoEnabledInHost = TRUE;
+
/**
* AppInfo gather loop timeout source.
*/
CONFNAME_APPINFO_DISABLED,
APP_INFO_CONF_DEFAULT_DISABLED_VALUE);
- gint pollInterval = 0;
+ gint pollInterval;
- if (!disabled) {
+ if (gAppInfoEnabledInHost && !disabled) {
pollInterval = VMTools_ConfigGetInteger(ctx->config,
CONFGROUPNAME_APPINFO,
CONFNAME_APPINFO_POLLINTERVAL,
__FUNCTION__, pollInterval, APP_INFO_POLL_INTERVAL);
pollInterval = APP_INFO_POLL_INTERVAL;
}
+ } else {
+ pollInterval = 0;
}
if (force || (gAppInfoPollInterval != pollInterval)) {
}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * AppInfoServerSetOption --
+ *
+ * Handle TOOLSOPTION_ENABLE_APPINFO Set_Option callback.
+ *
+ * @param[in] src The source object.
+ * @param[in] ctx The app context.
+ * @param[in] option Option being set.
+ * @param[in] value Option value.
+ * @param[in] plugin Plugin registration data.
+ *
+ * @return TRUE if the specified option is TOOLSOPTION_ENABLE_APPINFO and
+ * the AppInfo Gather poll loop is reconfigured.
+ * FALSE if the specified option is not TOOLSOPTION_ENABLE_APPINFO
+ * or AppInfo Gather poll loop is not reconfigured.
+ *----------------------------------------------------------------------------
+ */
+
+static gboolean
+AppInfoServerSetOption(gpointer src, // IN
+ ToolsAppCtx *ctx, // IN
+ const gchar *option, // IN
+ const gchar *value, // IN
+ gpointer data) // IN
+{
+ gboolean retVal = FALSE;
+
+ if (strcmp(option, TOOLSOPTION_ENABLE_APPINFO) == 0) {
+ g_debug("%s: Tools set option %s=%s.\n",
+ __FUNCTION__, TOOLSOPTION_ENABLE_APPINFO, value);
+
+ if (strcmp(value, "1") == 0 && !gAppInfoEnabledInHost) {
+ gAppInfoEnabledInHost = TRUE;
+ retVal = TRUE;
+ } else if (strcmp(value, "0") == 0 && gAppInfoEnabledInHost) {
+ gAppInfoEnabledInHost = FALSE;
+ retVal = TRUE;
+ }
+
+ if (retVal) {
+ g_info("%s: State of AppInfo is changed to '%s' at host side.\n",
+ __FUNCTION__, gAppInfoEnabledInHost ? "enabled" : "disabled");
+ TweakGatherLoop(ctx, TRUE);
+ }
+ }
+
+ return retVal;
+}
+
+
/*
******************************************************************************
* AppInfoServerReset --
TweakGatherLoopEx(ctx, interval);
} else {
- g_debug("%s: Poll loop disabled. Ignoring.\n", __FUNCTION__);
+ /*
+ * Channel got reset. VM might have vMotioned to an older host
+ * that doesn't send the 'Set_Option enableAppInfo'.
+ * Set gAppInfoEnabledInHost to TRUE and tweak the gather loop.
+ * Else, the application information may never be captured.
+ */
+ if (!gAppInfoEnabledInHost) {
+ gAppInfoEnabledInHost = TRUE;
+ TweakGatherLoop(ctx, TRUE);
+ } else {
+ g_debug("%s: Poll loop disabled. Ignoring.\n", __FUNCTION__);
+ }
}
}
ToolsPluginSignalCb sigs[] = {
{ TOOLS_CORE_SIG_CONF_RELOAD, AppInfoServerConfReload, NULL },
{ TOOLS_CORE_SIG_SHUTDOWN, AppInfoServerShutdown, NULL },
- { TOOLS_CORE_SIG_RESET, AppInfoServerReset, NULL }
+ { TOOLS_CORE_SIG_RESET, AppInfoServerReset, NULL },
+ { TOOLS_CORE_SIG_SET_OPTION, AppInfoServerSetOption, NULL }
};
ToolsAppReg regs[] = {
{ TOOLS_APP_SIGNALS,