John Wolfe [Wed, 19 Aug 2020 17:01:16 +0000 (10:01 -0700)]
Free old ununsed loggers when tools.conf changes.
Existing unused loggers are leaked when there is a change
in logging configuration. Added a check to free the loggers
that are not used after tools.conf is modified.
John Wolfe [Wed, 19 Aug 2020 17:01:16 +0000 (10:01 -0700)]
The SDMP plugin generates a warning message every 5 minutes when there is no
Namespace DB instance created on a VM. Change the log level to
debug to solve the problem.
1. Environment variable 'ALIVE_BASE' is used to construct the path of
the file where vcops version is stored. The variable is not available
when running the script inside serviceDiscovery plugin process, so a
hardcoded path is used.
John Wolfe [Tue, 18 Aug 2020 14:14:12 +0000 (07:14 -0700)]
Remove the guestApp.h header file that is not needed in conf.h
The configuration header file conf.h includes the guestapp header file
guestApp.h, but there are no related references to the guestapp header
file. This change removes the unnecessary header file.
The guestApp.h header file is included in the few source files with
a dependency on it.
John Wolfe [Tue, 18 Aug 2020 14:14:12 +0000 (07:14 -0700)]
[HGFS Server] Add file attributes/symlink check status cache using oplock support
An investigation found that while copying a group of small files from host
to guest using the shared folder, the HGFS_OP_GETATTR_V3 message was handled
in HGFS server 276,140 times over a period of ~35 seconds.
Caching the file attributes in HGFS on the server-side can reduce the time
significantly (from experimental results, 35s => 8s).
It was also discovered that Posix_RealPath is called repeatedly to check
whether a path is a symlink, since HgfsServerGetLocalNameInfo is called when
handling a series of requests.
Integrate a key-value cache to HGFS server to cache the symlink check results
and file attributes, using the file path as the key. This task will be divided
into multiple change:
1. Add oplock support
2. Add a customized LRU cache in HGFS server for file attributes and
symlink check results
- New files:
hgfsCache.h/c: implements a customized LRU cache which is built by
combining two data structures: a doubly linked list and
a hash table.
- The cache will be allocated only when oplock is enabled.
- The cache relies on the file change monitor provided by oplock to ensure
there is no stale data. When adding an entry into the cache, also
register the file change callback to oplock. Upon receiving the file change
callback, invalidate the cache. Once the cache is full, remove the LRU
entry and unregister the file change callback for it.
John Wolfe [Tue, 18 Aug 2020 14:14:11 +0000 (07:14 -0700)]
Define "Unknown Command" Macro to replace hard coded strings in rpc files
This changeset finds all instances of the hardcoded string "Unknown Command"
in a few rpc files and replaces it with a macro defined in a shared header
file.
John Wolfe [Tue, 18 Aug 2020 14:14:11 +0000 (07:14 -0700)]
Fix log recursion issue in DestroyRpcChannel()
Avoid calling g_xxx() logging routines in any function directly or
indirectly invoked from VmxGuestLog(). Change the g_debug() call in
DestroyRpcChannel() to a Debug() call.
John Wolfe [Tue, 18 Aug 2020 14:14:10 +0000 (07:14 -0700)]
Adding vmtools library dependency to deploypkg library
Some functions are not found in shared libraries when linking,
which generates several warnings. Added a library with
the needed functions to the list of dependencies.
John Wolfe [Fri, 7 Aug 2020 19:03:26 +0000 (12:03 -0700)]
Address some Log spew for toolsdeployPkg.log
1. Remove the extra '\n' at the tail of logging messages in imgcust.
2. Update the log printting function, do not add '\n' if the original
log message has already included it.
John Wolfe [Fri, 7 Aug 2020 19:03:24 +0000 (12:03 -0700)]
[HGFS Server] Support oplock inside HGFS server for Windows host
The motivation for this change is to cache file/directory related information
in host side, for example the file/directory attributes. To make the cache
correct, we will use the oplock(Windows)/lease(Linux) to monitor the
file/directory change event. When the file/directory changes, the item in
cache will be invalidated.
In this change, two new functions are defined:
- HgfsOplockMonitorFileChange
This function is used to monitor the change event for a file/directory,
and the callback will be called if file/directory is changed.
- HgfsOplockUnmonitorFileChange
This function is used to cancel the change event monitoring.
This patch only implements the oplock support for Windows host, the support
for Linux will be delivered in another patch.
John Wolfe [Fri, 31 Jul 2020 20:36:34 +0000 (13:36 -0700)]
GOSC event doesn't report at once after customization process timer is reached
When process timer is reached, the command process is killed and function
ProcessRead is called to read all the output till EOF. But EOF can't be
reached immediately. The reason is pre-customization script is launched
by perl script, and killing perl script process doesn't kill the
pre-customization script process.
This code update includes:
1. Do not read stdout/stderr when gosc command process exits abnormally
to avoid the EOF blocking.
2. Add READSTATUS_PENDING_TO_EOF in enum ReadStatus to avoid the confusion
with READSTATUS_PENDING.
3. Close the write ends of pipes (stdout[1]/stderr[1]) for child command
process before it exists.
4. In processPosix.c, the write ends of pipes have been closed in line 180,
181, so the read ends should be closed in line 254, 255.
5. Add explicit note for the beginning and the end of the perl script log.
John Wolfe [Tue, 21 Jul 2020 18:53:01 +0000 (11:53 -0700)]
Fix memory leak issue for "vmtoolsd" binary on receiving SIGINT or SIGUSR1.
Valgrind complains of a memory leak issue on receiving SIGINT or SIGUSR1
signal, because we lost call to RpcIn_Destruct(chan->in) in
RpcChannelTeardown(). It just happens to be released only at service
shutdown or on receiving SIGUSR1 signal; not a major concern.
Cleaning up the code.
Linux arm64 does not implement iopl() and the Hostinfo_ResetProcessState()
is raising a NOT_IMPLEMENTED() because of that. However if there's no iopl(),
there is no reason to drop IO privileges, so we can just skip that code.
This change also restores usage of getloadavg() for non Android arm64
platforms: ESX vmx and tools for Linux arm64.
Oliver Kurth [Fri, 12 Jun 2020 03:43:21 +0000 (20:43 -0700)]
Code cleanup to address a Coverity issue.
Coverity reports a "dereference after NULL check" in
BkdoorChannelStart. However, at the point of dereference
it's known that chan->inStarted is TRUE, which means chan->in
is guaranteed to be non-NULL, so it's not a bug.
Still, given that an input channel, if present, must have been
started before calling BkdoorChannelStart, it's possible to do
some code cleanup that will also get Coverity to stop reporting
the issue. Change what's currently a test into an ASSERT, test
chan->in rather than chan->inStarted, and add comments to make
it clearer what's going on.
Oliver Kurth [Fri, 12 Jun 2020 03:43:20 +0000 (20:43 -0700)]
Correct an issue reported by Coverity.
lib/asyncsocket/asyncsocket.c:
- AsyncSocket_SetKeepAlive() calls AsyncSocket_GetFd() which may return
a negative result. If that should happen, simply return FALSE.
Oliver Kurth [Wed, 10 Jun 2020 19:05:46 +0000 (12:05 -0700)]
open-vm-tools: add distribution specific pam config files
Add distribution specific pam config files for Debian/Ubuntu,
SuSE and Redhat/Fedora/CentOS. Install a generic file by default,
with comments to KB article. The distribution files are intended
to be used by OS vendors in their open-vm-tools packages.
Oliver Kurth [Wed, 10 Jun 2020 19:05:46 +0000 (12:05 -0700)]
Improve Linux guest identification function documentation.
Make it clear that the "short name" of a Linux distro has a default
value and that the default value should not be overwritten unless
VMware does this.
If someone cheats and sends down an unsupported "short name", the
guestMapper will protect the software stack, mapping the unsupported
"short name" to that of the guestOS config found in the VMX file.
We know that is OK since the VM couldn't power on and run the guest
unless it was valid.
All older, supported ESXi have updates that contain the guestMapper.
If the guestMapper is not in place - an older, unpatched release -
the software stack can become confused causing problems and crashes.