Oliver Kurth [Sat, 9 Dec 2017 02:57:38 +0000 (18:57 -0800)]
CAF MA Performance Issues
CAF MA Performance Issues
Vmware CAF ManagementAgentHost service was polling every 5 secs to check if Guest Network "Tunnel(port 6672)" was enabled to preconfigure & bring up Vmware CAF CommAmqpListener service.
This resulted in more CPU Utilization as opposed to previous release in CAF & caused regression in vmtools 10.2.0.
We are increasing the Poll rate to 5 mins, which fixed the issue & is giving us the same CPU/memory utilizations as in vmtools 10.1.0.
We were checking for the different stages of listener preconfiguration status from the listenerpreConfigure.txt files in the polling time interval, which caused increased IO operations.
To fix that we have stored the value of listener preconfiguration status from the files into a variable locally & using the same at all places instead of file access.
Oliver Kurth [Tue, 5 Dec 2017 00:27:20 +0000 (16:27 -0800)]
GuestInfo: skip check for shrinkable disk when gathering disk info
Some Linux OSes may have a non-existing device mounted to a filesystem,
for example Photon OS has the root file system mounted from
/dev/root, which does not exist. The wiper library does a check
for a shrinkable disk, and this fails. This change skips the check
when gathering data for diskinfo, but leaves it intact for
other disk wiper purposes. Information from read-only flesystems
will also be reported.
Oliver Kurth [Thu, 30 Nov 2017 23:38:03 +0000 (15:38 -0800)]
Make VigorPollImpl FD-based callbacks non-periodic (take 3)
The previous attempt reveals another pre-existing issue. An fd that is
closed by AsyncSocket may be reused right away. The SharedStream for
that fd may still have an outstanding callback that needs to fire
before it would be destroyed. If the destruction happens after the fd
is re-used and the new owner is using boost asio stream, the Release()
call would cancel the async read/write operation for the new owner.
One simple fix is to dup the fd when creating a SharedStream. This
means hostd would need 2 fds for each running VM. The hostd fd limit
is currently 4096 and I was able to power on 1K VMs. If necessary, the
fd limit can be increased (the system limit is 32K).
Previous description:
The original change has an issue on Linux that is not observed in ESX.
When the read and write callbacks fire in parallel, both would release
the reference to the SharedStream, triggering its destructor. Later
when the read callback tries to re-register itself, it would hit a
boost exception. To avoid that, I delayed the reset of
CallbackFD::stream to the end of Invoke so that the SharedStream
object woudl not be destroyed as long as the callback is re-registered.
Original description:
The hard-to-reproduce AsyncSocket leak turns out to be a variation of
PR 1530561. The fix for that bug only plugs the leak when the race is
between a VigorPollImpl callback that fires with an CanceledException
(which can be triggered by another callback registered on the same fd --
this is the boost behavior) and a thread trying to unregister the same
callback (e.g. upon detection of a disconnect). There is still a
potential reference leak when the read and write callbacks run in
parallel, if a disconnection happens between the two asyncsocket
callbacks (the asyncsocket callbacks take the asyncsocket lock, so they
are mostly serialized). The second asyncsocket callback handling the
disconnect error would unregister the first callback while the first
callback would be attempting to re-register itself at the VigorPollImpl
level (to provide the periodic behavior exposed by IVmdbPoll). If the
unregister wins the race, it would return false because the callback
cannot be cancelled (it is running). Then ReRegister would not find
the callback in the hash table, so the callback would not fire again,
which means the reference taken when registering the callback is leaked.
Applying the fix for PR 1530561 in the above scenario would not work
because an AsycnSocket callback may unregister itself and in that case
the reference is appropriately released. Unless we save the thread ID
in Unregister, we would not be able to distinguish when the callback
needs to run in order to release the reference. After considering
various options, I believe trying to support periodic fd-based
callbacks on top of a multi-threaded poll API is troublesome. This
change adds a poll flag for one-shot callbacks and used that in
AsyncSocket with IVmdbPoll. VigorPollImpl only support the one-shot
behavior. In the long term I would like to retire IVmdbPoll and create
a new poll interface. For now I would like to minimize churn while
fixing the memory leak.
The new version of the vmware tools will be installed on older version
of ESX. But these older versions do not come with libvmkmemstats.so
and a dynamic linking error occurs.
This patch changes the code to deal with the case where the lib is not
available. Instead of relying on the linker to dynamically link with
libvmkmemstats.so, g_module_open() is used to open the library, if
available, and gracefully handle any eventual errors.
Before the patch, the whole libguestinfo would stop working and after
the patch only the memory stats are unavailable.
Oliver Kurth [Thu, 30 Nov 2017 23:17:27 +0000 (15:17 -0800)]
VGAuth changes:
- add calling LoadUserProfile()/UnloadUserProfile() in VGAuth
impersonation/unimpersonation code paths
- VMTools side code change to use the new VGAuth SDK.
Oliver Kurth [Thu, 30 Nov 2017 23:17:27 +0000 (15:17 -0800)]
VGAuth changes:
- add calling LoadUserProfile()/UnloadUserProfile() in VGAuth
impersonation/unimpersonation code paths
- VGAuth part of code change plus tools vix plugin make file.
The new version of the vmware tools will be installed on older version
of ESX. But these older versions do not come with libvmkmemstats.so
and a dynamic linking error occurs.
This patch changes the code to deal with the case where the lib is not
available. Instead of relying on the linker to dynamically link with
libvmkmemstats.so, g_module_open() is used to open the library, if
available, and gracefully handle any eventual errors.
Before the patch, the whole libguestinfo would stop working and after
the patch only the memory stats are unavailable.
Oliver Kurth [Wed, 15 Nov 2017 21:32:56 +0000 (13:32 -0800)]
GuestInfo: add primary-nics and low-priority-nics options
Add the options 'primary-nics' and 'low-priority-nics' for GuestInfo.
The options accept a list of comma separated patterns for interface names
which can be considered as 'primary' or 'low priority' network interfaces.
This will cause the NicInfo to be put on top of the list for primary
interfaces, and to the bottom for low priority interfaces.
Example:
primary-nics=eth1
will make sure that the IP address(es) for eth1 will be sorted on
top of the list of IP addresses.
primary-nics=eth*
will make sure that any one of the addresses of all interfaces
matching eth* will be sorted on top of the list of IP addresses,
but won't guarantee which one if there is more than one.
low-priority-nics=eth*
will work analogously, but interfaces will be sorted to the bottom.
In case the limit of the number of interfaces to be reported is reached,
low priority interfaces are the first to be skipped.
Oliver Kurth [Wed, 15 Nov 2017 21:32:55 +0000 (13:32 -0800)]
Add SUSE Server for SAP Applications to hostinfoPosix.c
On SLES-SP1-SAP the "lsb_release -sd" command returns the string
"SUSE Linux Enterprise Server for SAP Applications 12 SP1".
Parsing in HostinfoGetOSShortName() detects the sub-strings "suse"
and "enterprise" but not "server 12". STR_OS_SLES is returned
resulting in displaying of "SUSE Linux Enterprise 8/9" in the
summary screen of the vSphere client. This is wrong.
Instead, search for the sub-string "server for sap applications 12"
and return STR_OS_SLES_12. SLES11-SAP is not affected.
Oliver Kurth [Wed, 15 Nov 2017 21:32:55 +0000 (13:32 -0800)]
[Tools] Fix crash issue when stopping vmtoolsd(vmuser)
When stopping vmtoolsd, the code tries to unload all plugins. The
signal TOOLS_CORE_SIG_CAPABILITIES is emitted before really starting
to unload plugins. If the plugin should try to call RpcChannel_Send
while processing the signal and the RPC channel has been shutdown, an
ASSERT is triggered. The fix is to check whether rpc exists and if
unavailable, avoid sending the TOOLS_CORE_SIG_CAPABILITIES signal.
Oliver Kurth [Wed, 15 Nov 2017 21:32:54 +0000 (13:32 -0800)]
GuestInfo: enable nic/iproute information for Linux without libdnet
Linux glibc (since 2.3) fully supports getting ip addresses using
getifaddrs() for both IPv4 and IPv6. Use of getifaddrs() was already
implemented in nicInfoPosix.c for tools for ESXi. This change
enables that code also for Linux, if libdnet is not used.
The change also enables the iproute information, which does not
depend on libdnet, except by the use of addr_stob(), which can
be replaced easily with the existing function CountNetmaskBits().
Oliver Kurth [Wed, 15 Nov 2017 21:32:54 +0000 (13:32 -0800)]
Make disk free space reporting consistent with Linux 'df' command.
On Linux, statfs syscall reports free space in two fields.
From http://man7.org/linux/man-pages/man2/statfs.2.html:
1. f_bfree => Free blocks in filesystem
2. f_bavail => Free blocks available to unprivileged user
For file systems that maintain reserved space for system
activities f_bfree > f_bavail because f_bfree includes the
reserved space in the file system. The reserved space is
typically 5% for 'ext4' file systems. Newer distros like
RHEL 7.x use 'xfs' by default and report same value for
both the fields.
The Linux 'df' command uses f_bavail in its reporting.
Tools reports, conditionally, f_bfree for root and f_bavail
for non-root. However, since vmtoolsd runs as root, Tools
always reports f_bfree, which is more free space than 'df'
would report (depending on amount of reserved space).
In order to be consistent with Linux 'df' command,
report f_bavail as the disk free space by default. This does
change the behavior a little bit in that Tools will report less
disk free space than before, the difference being the same as
the reserved space on the file system, typically 5%. This
should be OK in general because it makes the space reporting
a bit conservative. If this change in behavior is not desired
for some use cases, the old behavior can be restored by setting
the following newly added configuration in this change:
[guestinfo]
diskinfo-include-reserved=true
The existing callers that are outside the guestInfo plugin
will continue to include reserved space in their space
accounting as before.
Also fixed a few minor stuff/touchups in vmtoolsConfig.c.
Oliver Kurth [Wed, 15 Nov 2017 21:32:54 +0000 (13:32 -0800)]
Fix a segfault when log file isn't set and conf is reloaded.
When vmsvc.handler=file, but vmsvc.data isn't set, vmtoolsd crashed
on reloading the config file. This was caused by using a NULL value
as an argument to a strcmp().
This change fixes this by using g_strcmp0 which handles NULL pointers
gracefully, and setting confData to a default value before calling
g_strcmp0().
This also fixes a case where a change in the log file would be ignored.
Oliver Kurth [Wed, 15 Nov 2017 21:32:53 +0000 (13:32 -0800)]
guestOS: Uniquely run time identify Photon
Currently VMware Photon 2 is identified at run time as a Linux 4.x kernel.
This is correct, but the Photon distro has an LSB compliant identification
file.
Attempt to check the LSB compliant identification file for Photon. If
present, identify the guest as "vmware-photon".
Oliver Kurth [Tue, 24 Oct 2017 21:07:36 +0000 (14:07 -0700)]
GuestInfo: add primary-nics and low-priority-nics options
Add the options 'primary-nics' and 'low-priority-nics' for GuestInfo.
The options accept a list of comma separated patterns for interface names
which can be considered as 'primary' or 'low priority' network interfaces.
This will cause the NicInfo to be put on top of the list for primary
interfaces, and to the bottom for low priority interfaces.
Example:
primary-nics=eth1
will make sure that the IP address(es) for eth1 will be sorted on
top of the list of IP addresses.
primary-nics=eth*
will make sure that any one of the addresses of all interfaces
matching eth* will be sorted on top of the list of IP addresses,
but won't guarantee which one if there is more than one.
low-priority-nics=eth*
will work analogously, but interfaces will be sorted to the bottom.
In case the limit of the number of interfaces to be reported is reached,
low priority interfaces are the first to be skipped.
Oliver Kurth [Tue, 24 Oct 2017 21:07:35 +0000 (14:07 -0700)]
VGAuth changes:
- add calling LoadUserProfile()/UnloadUserProfile() in VGAuth
impersonation/unimpersonation code paths
- VMTools side code change to use the new VGAuth SDK.
Oliver Kurth [Tue, 24 Oct 2017 21:07:35 +0000 (14:07 -0700)]
VGAuth changes:
- add calling LoadUserProfile()/UnloadUserProfile() in VGAuth
impersonation/unimpersonation code paths
- VGAuth part of code change plus tools vix plugin make file.
Oliver Kurth [Tue, 24 Oct 2017 21:07:35 +0000 (14:07 -0700)]
[Tools] Fix crash issue when stopping vmtoolsd(vmuser)
When stopping vmtoolsd, the code tries to unload all plugins. The
signal TOOLS_CORE_SIG_CAPABILITIES is emitted before really starting
to unload plugins. If the plugin should try to call RpcChannel_Send
while processing the signal and the RPC channel has been shutdown, an
ASSERT is triggered. The fix is to check whether rpc exists and if
unavailable, avoid sending the TOOLS_CORE_SIG_CAPABILITIES signal.
Oliver Kurth [Tue, 24 Oct 2017 21:07:33 +0000 (14:07 -0700)]
Add SUSE Server for SAP Applications to hostinfoPosix.c
On SLES-SP1-SAP the "lsb_release -sd" command returns the string
"SUSE Linux Enterprise Server for SAP Applications 12 SP1".
Parsing in HostinfoGetOSShortName() detects the sub-strings "suse"
and "enterprise" but not "server 12". STR_OS_SLES is returned
resulting in displaying of "SUSE Linux Enterprise 8/9" in the
summary screen of the vSphere client. This is wrong.
Instead, search for the sub-string "server for sap applications 12"
and return STR_OS_SLES_12. SLES11-SAP is not affected.
Oliver Kurth [Tue, 24 Oct 2017 21:07:33 +0000 (14:07 -0700)]
lib/file: Enhance File_EnsureDirectoryEx to do more checking
When creating a directory, distinguish whether an EEXIST error is
because the directory already exists or because there is a file with
that path name. Return the appropriate error.
Oliver Kurth [Tue, 24 Oct 2017 21:07:33 +0000 (14:07 -0700)]
lib/file: Reduce the create directory spam
The lib/file primitives (e.g. create file, create directory) may fail -
but they also return errno/GetLastError. The caller should inspect a
failure and decide what to do (or log). The lib/file primitives should
not log. The client should do that. The primitives are the high
performance path and failure isn't necessarily a failure, only the
client can decide.
The lib/file primitives (e.g. create file, create directory) may fail -
but they also return errno/GetLastError. The caller should inspect a
failure and decide what to do (or log). The lib/file primitives should
not log. The client should do that. The primitives are the high
performance path and failure isn't necessarily a failure, only the
client can decide.
Oliver Kurth [Tue, 24 Oct 2017 21:07:33 +0000 (14:07 -0700)]
Misc GuestOS ID fixes.
- Centos8 64bit guest will have linux 4.x. Moved Centos8-64 guest id
from all3xlinux64 to all4xlinux64 guest list.
- oracle8_64 is missing in the list. Added it to all4xlinux64 guest list.
- Photon has linux 4.x. Moved photon from all3xlinux64 to all4xlinux64
guest list.
- Changed the HostinfoOSData() function to return other4xlinux for
the distros where the version cannot be determined.
Oliver Kurth [Mon, 23 Oct 2017 21:21:23 +0000 (14:21 -0700)]
GuestInfo: enable nic/iproute information for Linux without libdnet
Linux glibc (since 2.3) fully supports getting ip addresses using
getifaddrs() for both IPv4 and IPv6. Use of getifaddrs() was already
implemented in nicInfoPosix.c for tools for ESXi. This change
enables that code also for Linux, if libdnet is not used.
The change also enables the iproute information, which does not
depend on libdnet, except by the use of addr_stob(), which can
be replaced easily with the existing function CountNetmaskBits().
Oliver Kurth [Mon, 23 Oct 2017 21:21:22 +0000 (14:21 -0700)]
Make disk free space reporting consistent with Linux 'df' command.
On Linux, statfs syscall reports free space in two fields.
From http://man7.org/linux/man-pages/man2/statfs.2.html:
1. f_bfree => Free blocks in filesystem
2. f_bavail => Free blocks available to unprivileged user
For file systems that maintain reserved space for system
activities f_bfree > f_bavail because f_bfree includes the
reserved space in the file system. The reserved space is
typically 5% for 'ext4' file systems. Newer distros like
RHEL 7.x use 'xfs' by default and report same value for
both the fields.
The Linux 'df' command uses f_bavail in its reporting.
Tools reports, conditionally, f_bfree for root and f_bavail
for non-root. However, since vmtoolsd runs as root, Tools
always reports f_bfree, which is more free space than 'df'
would report (depending on amount of reserved space).
In order to be consistent with Linux 'df' command,
report f_bavail as the disk free space by default. This does
change the behavior a little bit in that Tools will report less
disk free space than before, the difference being the same as
the reserved space on the file system, typically 5%. This
should be OK in general because it makes the space reporting
a bit conservative. If this change in behavior is not desired
for some use cases, the old behavior can be restored by setting
the following newly added configuration in this change:
[guestinfo]
diskinfo-include-reserved=true
The existing callers that are outside the guestInfo plugin
will continue to include reserved space in their space
accounting as before.
Also fixed a few minor stuff/touchups in vmtoolsConfig.c.
Oliver Kurth [Mon, 23 Oct 2017 21:21:22 +0000 (14:21 -0700)]
Add support to tools timeSync to issue w32tm resync in Windows guests.
This change adds support to issue a w32tm resync command from within
VMware tools timeSync in order to reconfigure w32time configuration
parameters. This forces guest time to be resynchronized to external
time server.
Oliver Kurth [Mon, 23 Oct 2017 21:21:22 +0000 (14:21 -0700)]
Add a poll flag for one-shot callbacks in AsyncSocket
The original change had an issue. When the read and write callbacks
fire in parallel, both would release the reference to the SharedStream,
triggering its destructor. Later when the read callback tried to
re-register itself, it would hit a boost exception. To avoid that,
delay the reset of CallbackFD::stream to the end of Invoke so that the
SharedStream object will not be destroyed as long as the callback is
re-registered.
Oliver Kurth [Mon, 23 Oct 2017 21:21:21 +0000 (14:21 -0700)]
Fix a segfault when log file isn't set and conf is reloaded.
When vmsvc.handler=file, but vmsvc.data isn't set, vmtoolsd crashed
on reloading the config file. This was caused by using a NULL value
as an argument to a strcmp().
This change fixes this by using g_strcmp0 which handles NULL pointers
gracefully, and setting confData to a default value before calling
g_strcmp0().
This also fixes a case where a change in the log file would be ignored.
Oliver Kurth [Mon, 23 Oct 2017 21:21:21 +0000 (14:21 -0700)]
Changes to header files vmnet_defs.h and vmxnet3_defs.h needed to
integrate ENS capabilities into existing Uplink capabilities.
The changes are not directly applicable to open-vm-tools.
For the I[Vmdb]Poll support in AsyncTCPSocket, inBlockingRecv has been
used to avoid conflict with AsyncSocketDoOneMsg. There is an issue
with where inBlocking Recv is decremented, which is right after poll,
where the thread would drop the lock. The lock may also be dropped
during AsyncTCPSocketFillRecvBuffer, and for that there is a separate
inDoOneMsg flag. This change unifies the two flags and makes
inBlockingRecv cover both functions that may drop the lock. This fixes
the race that would allow AsyncTCPSocketRecvCallback to run when
AsyncTCPSocketDoOneMsg is in progress. A couple places where we
previously checked inBlockingRecv to report an error now have to also
check inRecvLoop (TRUE during AsyncTCPSocketFillRecvBuffer) -- those
checks cannot be enforced during FillRecvBuffer because the client
callback is allowed to change the callback or cancel it. The lone
usage of inDoOneMsg is switched to inBlockingRecv.
Oliver Kurth [Mon, 23 Oct 2017 21:21:20 +0000 (14:21 -0700)]
guestOS: Uniquely run time identify Photon
Currently VMware Photon 2 is identified at run time as a Linux 4.x kernel.
This is correct, but the Photon distro has an LSB compliant identification
file.
Attempt to check the LSB compliant identification file for Photon. If
present, identify the guest as "vmware-photon".
Oliver Kurth [Mon, 23 Oct 2017 21:21:20 +0000 (14:21 -0700)]
Fix ASSERT of registering the same callback twice
The previous change for Poll introduced a bug in AsyncSocket.
When re-registering the recv callback, it needs to check whether
there is a concurrent blocking recv (which means the send callback
has detected a disconnection and is draining the pipe). The recv
callback should act like a no-op in that case (other than to
release the reference).
Oliver Kurth [Mon, 23 Oct 2017 21:21:19 +0000 (14:21 -0700)]
Hgfs Protocol: clean up the Hgfs protocol operation capabilities
This change cleans up the operation capability and its flags which
currently are not clearly associated with the type to which they refer.
The name doesn't help in that regard either.
The capability and flags are used in the Hgfs session creation by
both the server and client to dictate the protocol operation versions
to be used during the lifetime of that session. The flags denote
which operations are currently used and how they are expected to be
used.
The hosted file locking code tosses a random number generator and
creates an directory name (D name) and member name (M name) that both
use the random number.
If the D name cannot be created we try again until we can create one.
The assumption is other lockers are racing with the code. The random
number generator makes the chance of collisons small and soon we get
a D name.
Once a D name can be created, we check if the M name exists. If it
does, we remove the D name and try again until we get a unique D and
M name. Once the M name is created, the D name is discarded.
If we're unable to remove the D name, we could land up filling the
locking directory with garbage that cannot be cleaned up. Fail if
we're unable to remove the D entry.
Oliver Kurth [Mon, 23 Oct 2017 21:21:19 +0000 (14:21 -0700)]
Disable lib/string wprintf functions for non-Windows builds
The lib/string wprintf functions currently are enabled only
for Windows and Linux builds, but Windows is the only
platform that uses them. Disable them for Linux, too.