Oliver Kurth [Fri, 15 Sep 2017 18:23:38 +0000 (11:23 -0700)]
Check for gdk_pixbuf_xlib-2.0 in configure script
gdk_pixbuf_xlib-2.0 is no longer part of gdk-pixbuf2 in newer
distributions (for example Fedora 26), so it's no longer pulled
in as a dependency from the gtk devel packages. Therefore we
need an extra check for it.
Oliver Kurth [Fri, 15 Sep 2017 18:23:37 +0000 (11:23 -0700)]
Add new AsyncSocket API to wait on multiple sockets at once
Currently, there is no way to poll/select on multiple sockets through
the asyncsocket library. VRDMA is encountering a use case for such
functionality, so add such an API to asyncsocket. It is only defined
for AsyncTCPSocket, and is mostly just a wrapper around AsyncTCPSocketPoll.
Oliver Kurth [Fri, 15 Sep 2017 18:23:36 +0000 (11:23 -0700)]
Fix HostinfoGetCmdOutput to return NULL on failure
HostinfoGetCmdOutput unconditionally calls DynBuf_DetachString
along its success path. DynBuf_DetachString never returns NULL,
so that broke callers expecting a NULL return value if the command
had no output (which can happen if HostinfoGetCmdOutput attempts to
run a non-existent executable; note that this does not trigger any
of the failure paths).
Restore the old code that checked if the DynBuf is non-empty
before retrieving its contents.
Bonus:
* Fix incorrect documentation to Posix_Popen.
* Adjust the StdIO_ReadNextLine documentation to clarify its behavior.
Oliver Kurth [Fri, 15 Sep 2017 18:23:36 +0000 (11:23 -0700)]
Changes to common source files; not applicable to open-vm-tools.
services/plugins/dndcp/stringxx/string.cc:
services/plugins/dndcp/stringxx/string.hh:
- Change utf::string::toUpper() and related functions to default the
locale argument to a NULL pointer.
Oliver Kurth [Fri, 15 Sep 2017 18:23:36 +0000 (11:23 -0700)]
Fix i18n symbol violations
Fix some of the illegal symbols that are flagged. Also changed the
wrapper for unsetenv to return an int to match the glibc-2.2.2 and
later version. Tools build for FreeBSD appears to be using an older
libc so it always reports success in that case.
Oliver Kurth [Fri, 15 Sep 2017 18:23:35 +0000 (11:23 -0700)]
New common header file: lib/include/product.h.
Move public product types enum from lib/include/productState.h to product.h
Common header file change; not applicable to open-vm-tools.
Oliver Kurth [Fri, 15 Sep 2017 18:23:33 +0000 (11:23 -0700)]
Remove NOT_TESTED() from EINTR handling in lib/file
When FileIO_Read() & friends receive EINTR, they log NOT_TESTED, and
retry read. It seems innocent - until you provide your own function
to handle logging.
Now imagine that you create bidirectional communication protocol,
and run it over the pipe. And you do logging over this very same
pipe. Application is waiting for message, so it invoked
FileIO_Read(), and is blocked on read(). Now you attach strace
to the process. That will interrupt pending read() with EINTR
and log NOT_TESTED(). This logging performs FileIO_Write() on
this very same pipe, and then performs FileIO_Read() to retrieve
status of logging request.
If it receives status of logging request, all is good. Code
returns from logging, and reexecutes read(), waiting for
request from server.
But if logging function receives anything else (f.e. other side
sends request at same time strace was attached), it gets queued
into internal data structures of the app for processing once
code returns to main application loop.
Problem is that FileIO_Read() will reenter read() without
returning to the caller. And that read() will block forever:
other end already send request that is now pending in the
request list, and so won't send anything until it sees
we processed that pending request. Hang.
There are two possible fixes:
1. Return EINTR from FileIO_Read(), or
2. Do not do any logging from FileIO_Read()
Approach #2 is much easier, as API semantic does not change,
and currently it is broken. So there is no need for NOT_TESTED()
anymore...
Oliver Kurth [Fri, 15 Sep 2017 18:23:33 +0000 (11:23 -0700)]
Make CAF consume the same version of GLIB (and dependencies) used by Tools.
Summary of changes-
1. Linux: Make the following libraries point to their Tools
counterparts by updating the LD_LIBRARY path in CAF makefile:
-libglib-2.0.so.0
-libiconv.so.2
-libpcre.so.1
-libz.so.1
-libffi.so.6
-libgthread-2.0.so.0
-libstdc++.so.6
-libgcc_s.so.1
2. Linux: Add a new environmental variable INSTALL_MODE = tools/standalone
in makefile, setting it to "tools" by default, to handle copying of the
required GLIB (and dependencies) for CAF "standalone" installation.
3. Linux: Update setupCafConfig function to add the INSTALL_MODE property
if not present already to handle build2build upgrade case.
Oliver Kurth [Fri, 15 Sep 2017 18:23:32 +0000 (11:23 -0700)]
Add constants for macOS os major versions.
MacOS versions can get a bit confusing because there are two parallel
versioning schemes. There is the marketing version (e.g. 10.6, 10.7.5, etc.)
which is what everybody uses when discussing the OS but is very hard to get
at via code, and there is the kernel version (e.g. 10.0.0, 11.4.2) which
is what is returned by POSIX syscalls like uname. The confusion sets in
because in comments we tend to use the marketing version, but then the
code actually checks for the kernel version.
This change adds constants for the marketing version for comparisons with
HostInfo_OSVersion(0) (the major version), which makes checking for
10.6 vs 10.7 vs 10.8 etc. much more readable.
Oliver Kurth [Fri, 15 Sep 2017 18:23:32 +0000 (11:23 -0700)]
Fix building without ICU
Building vgauth failed when building without ICU (with the
--without-icu option). This was caused by not using cxx
link options which are needed by xml-security, but only
enabled when using ICU.
Also fix the warning "invalid suffix on literal;".
Oliver Kurth [Fri, 15 Sep 2017 18:23:32 +0000 (11:23 -0700)]
Fix tools build
For open-vm-tools there is code that strips off the
"VMware Confidential" part of the msgfmt.c header. When
the copyright years were updated in msgfmt.c, it broke
the pattern matcher.
Oliver Kurth [Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)]
Replace Atomic_MFence with architecture-independent barrier primitives
Atomic_MFence was used to implement a full memory barrier on x86
architectures. In an effort to clean up duplicate code, this change
removes Atomic_MFence and replaces all previous uses with the most
conservative architecture-independent barrier primitive
(LDST_LDST_MEM_BARRIER). Since LDST_LDST_MEM_BARRIER is also a full
memory barrier, this change does not affect any existing ordering
semantics.
Oliver Kurth [Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)]
Fix timesync state to be uncalibrated when adjustment is large (>60ms).
VMtools has timesync plugin to adjust guest time to match host time. Timesync
relies on a state machine (Uncalibrated, calibrating and PLL states) to
adjust the amount of guest time to match host time. If the guest and host
time differ by more than 60ms, state machine should reset to uncalibrated
state. There is a bug currently that would leave the state in PLL mode even
if the guest and host times differ by more than 60ms since absolute value of
adjustment is not considered. This causes the time sync to happen slower than
expected.
Oliver Kurth [Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)]
Specify the proper size while sending deploypkg.update.state RPC message.
Due to a recent change, the VMX handler for 'deployPkg.update.state' RPC
ignores the message if the specified argument size doesn't match with
the string size.
In the current code, in a certain error code path, deploypkg plugin
specifies one extra byte in the size for 'deploypkg.update.size' RPC
message. This results in an error at the VMX layer.
Fixed the code to specify the proper string length while sending the RPC.
Oliver Kurth [Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)]
Implement ST_LD_MEM_BARRIER on x86 with a locked xor
Microbenchmarks on modern Intel architectures show that a memory barrier
implemented with locked xor operation performs about 30% better when
compared to a barrier implemented with mfence, while providing the same
memory ordering guarantees. This patch changes the implementation of
ST_LD_MEM_BARRIER on x86 architectures to use the faster, locked xor
operation. Additionally, support for Microsoft's compiler is added.
Oliver Kurth [Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)]
atomic asm snippets: Replace "memory" clobber with "Q" constraint
In our atomic asm snippets, using the "Q" constraint,
(https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html tells gcc
which exact memory is modified i.e. the bytes covered by the atomic variable),
is better than using the "memory" clobber (tells gcc that all memory is
modified, effectively a compiler memory barrier which prevents compiler
optimizations).
Oliver Kurth [Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)]
vm_{atomic,uninterruptible}.h: Flip the polarity of the 32-bit function names
Initially, we only had 32-bit atomic functions, so their names did not have a "32" suffix.
Then, we added 64-bit functions. So,
1) We used a "64" suffix for them.
2) We provided additional names with a "32" suffix for the 32-bit functions, for consistency.
The hope was that, over time, references to unsuffixed names would disappear.
This change sends a stronger signal to developpers that the suffixed names
are the ones to use, and that the unsuffixed names are the undesirable legacy
ones to avoid.
This change brings a few dissidents back in line with the rest of the code.
Also deleted Uninterruptible_FetchAndAdd64():
o It was unused.
o It provided the same functionality as Uninterruptible_ReadAdd64(), with a worse name and implementation.
Oliver Kurth [Fri, 15 Sep 2017 18:23:30 +0000 (11:23 -0700)]
Fixed invalid class pointer access if VSS provider not installed
Some customers may disable VSS support by not installing VMware snapshot
provider, which may lead to the VSS provider not being able to be
initialized, which in turn could lead to a invalid class pointer access
during complete initialization.
This change checks provider initialization status before initialize
completer to fix the issue.
Oliver Kurth [Fri, 15 Sep 2017 18:23:30 +0000 (11:23 -0700)]
Tools Hgfs Transport Logging: Migrate the to common tools conf logging
Migrate the tools implementations of the HGFS policy, server manager
and transport channels to use the common tools conf logging with the
"hgfsd" domain setting.
This allows the HGFS server core and the server managerand transport
components to be independently logged.
Changes are:
- Move the logging definitions into the server manager lib common header
- Add some log statements into the server manager public APIs
- Redefine the policy manager (share handling) logging to the general tools
logging.
Oliver Kurth [Fri, 15 Sep 2017 18:23:30 +0000 (11:23 -0700)]
vm_atomic.h: Build Atomic_uint128 upon uint128 instead of __int128
Atomic_{8,16,32,64} are built upon uint{8,16,32,64}.
Atomic_uint128 is built upon __int128, which is inconsistent.
This change builds it upon uint128 instead.
Oliver Kurth [Fri, 15 Sep 2017 18:23:30 +0000 (11:23 -0700)]
vm_atomic.h: Implement Atomic_Bool operations on top of Atomic_uint8 operations
The atomic code was inconsistent:
o On one hand we had Atomic_uint{16,32,64,128} basic types, on top of
which we auto-generated more elaborate types such as Atomic_Ptr and
Atomic_Int.
o On the other hand we had no Atomic_uint8, we had Atomic_Bool implemented
as a basic type, and we had CMPXCHG1B (based on uint8, defined for
vmkernel and vmm only, with an x86-specific name) that was implemented
similarly to Atomic_ReadIfEqualWriteBool (based on Atomic_Bool, defined
for everybody, with an architecture-neutral name).
This change brings a little bit of consistency:
o It defines Atomic_uint8 as a basic type.
o It auto-generates Atomic_Bool on top of it.
o It deletes CMPXCHG1B.
Also added a void * argument to AtomicUndefined(), which is used to
"consume" function parameters to prevent some compilers from warning
about unused parameters.
Oliver Kurth [Fri, 15 Sep 2017 18:23:29 +0000 (11:23 -0700)]
vm_atomic.h: Implement Atomic_Bool operations on top of Atomic_uint8 operations
The atomic code was inconsistent:
o On one hand we had Atomic_uint{16,32,64,128} basic types, on top of
which we auto-generated more elaborate types such as Atomic_Ptr and
Atomic_Int.
o On the other hand we had no Atomic_uint8, we had Atomic_Bool implemented
as a basic type, and we had CMPXCHG1B (based on uint8, defined for
vmkernel and vmm only, with an x86-specific name) that was implemented
similarly to Atomic_ReadIfEqualWriteBool (based on Atomic_Bool, defined
for everybody, with an architecture-neutral name).
This change brings a little bit of consistency:
o It defines Atomic_uint8 as a basic type.
o It auto-generates Atomic_Bool on top of it.
o It deletes CMPXCHG1B.
Also added a void * argument to AtomicUndefined(), which is used to
"consume" function parameters to prevent some compilers from warning
about unused parameters.
Oliver Kurth [Fri, 15 Sep 2017 18:23:29 +0000 (11:23 -0700)]
Hgfs VMCI Transport: Part I fix the shared memory interface to not assert
THe HGFS VMCI transport uses the shared memory access functions to extract
HGFS protocol packets for the HGFS server processing and for returning results.
This interface recently changed to add thread tracking for these operations with
the addition of register and unregister functions.
The HGFS transport interface was missed on the initial change and hence now triggers
an assert as the register function call has not been made.
This is the first part of a change which addresses the assertion failure by adding the
register and unregister calls for the HGFS VMCI transport interface which uses this
shared memory.
The calls are part of a set of callbacks provided by the supported transports to the
HGFS server code for the VMX and tools. Since the backdoor transport does not make
use of the shared memory and access calls it just sets the function callbacks to NULL.
This is done for both the VMX backdoor channel and tools backdoor channel for packets
routed into the HGFS server.
This change does the following:
- Adds the register and unregister callbacks to the channel callback table.
- Modified the VMX VMCI channel to add the register and unregister callbacks and initialize
the callback table with these new functions which are then passed to the HGFS server.
- Modified the VMX and tools backdoor channels to NULL out the function pointers for the
register and unregister callback functions.
- Add the Hgfs server directory notification callbacks for register and unregister which are
termporarily protected by ifdef statements as they are not yet called from the directory
notification component. These simply callback to the channel register and unregister functions
to do the real work if present for the channel in use. (Only VMCI will use this.)
Oliver Kurth [Fri, 15 Sep 2017 18:23:29 +0000 (11:23 -0700)]
Hgfs Server: Clean up logging macros and enable Hgfs Server tools logging
The HGFS server logging macros are scattered throughout and repeated
in each source file. This makes it difficult to modify between the
VMX implementation and the tools. The tools side suffers currently and
is thus hard to debug.
This is the first in a couple of small changes to clean up the logging.
First the cleanup by moving the server logging statements for LOG to a centralized
private header file for the server code and not repeated in every source file.
Second, move the HgfsServer LOG from hgfs to its own HgfsServer setting.
New VMX file setting is:
Loglevel.hgfsServer = "10"
The current existing setting of "hgfs" will capture logging for the VMX
such as the HGFS manager, policy and transport interfaces (VMCI/Backdoor).
Third, the HgfsServer LOG statements for the tools builds (which go into
both instances of the vmtoolsd sevice/daemon) and the upgrader application
are now mapped to g_debug and Debug function calls respectively.
This now allows the tools configuration logging to set the following which will capture all
the Hgfs server logging:
hgfsServer.level = "debug"
Follow up changes will be made to check the tools backdoor transport interface log setting
which currently uses something like:
hgfsd.level = "debug"