VMware, Inc [Thu, 17 Dec 2009 21:47:07 +0000 (13:47 -0800)]
Factor out reading guest and host time from TimeSyncDoSync.
This change splits out reading guest and host time from the main
time sync loop. At the same time, it converts to using "diff" and
"interruptLag" to "gosError" and "apparentError". The polarity of
these two now match NTP/adjtime: positive values mean that time is
ahead, negative values mean that time is behind. The names match
TimeTracker.
This change shouldn't introduce any behavioral changes. The
change in how errors are represented makes some of the conditions
in the one time sync portion of the loop look a bit suspect, but
I'll address that later.
VMware, Inc [Thu, 17 Dec 2009 21:46:45 +0000 (13:46 -0800)]
Make timeSync use microseconds rather than seconds & microseconds.
A signed 64 bit value storing microseconds can represent up to
292471 years, so keeping a separate "seconds" value isn't
necessary (and complicates calculations).
VMware, Inc [Thu, 17 Dec 2009 21:45:52 +0000 (13:45 -0800)]
Configure core dump limit on POSIX automatically.
In this change:
. if core dumps are enabled in the config file, try to raise the core
rlimit for the process when logging is enabled; this can still fail
if the system is configured to now allow it, but it's better than
not getting core dumps because the default system setting is to set
the limit to 0.
. on POSIX systems, try to chdir to the user's home if trying to create
a core dump, but the current directory is not writable.
. don't enable the Win32 exception filter automatically when loading the
vmtools DLL; instead, do it when configuring logging and requesting
core dumps.
. avoid recursive log calls from CoreDump_CoreDump() on Win32; only Panic()
was incrementing the recursive panic count, it needs to be done in the
actual core dump function.
This change doesn't handle SIGSEGV on POSIX; that will still create a core
dump if the limit is set appropriately, but won't go through the code that
sees if the current directory is writable.
VMware, Inc [Thu, 17 Dec 2009 21:44:59 +0000 (13:44 -0800)]
Plumb SCM control signals through vmtoolsd in a generic way.
Instead of individually plumbing every possible control code the SCM
sends to services through vmtoolsd, provide a generic plumbing mechanism
and let plugins decide what they want to do.
The only remaining issue is that a few control codes are only sent after
some specific registration step (e.g., RegisterDeviceNotification); for
those cases, either we'll need to have vmtoolsd blindly register for all
possible control codes (which is not future proof since MS may add new
ones), or, when possible (such as in the device notification example),
let plugins do the registration themselves.
Change the two existing control messages (SESSION_CHANGE and SHUTDOWN) to
use the new mechanism, and fix all current usage sites.
VMware, Inc [Thu, 17 Dec 2009 21:43:15 +0000 (13:43 -0800)]
Detect nested VM support
Unless vmx.allowNested is set, VMX currently refuses to power on
if it finds the backdoor. With the recent addtion of dynamic
backdoor toggling, we can now test for the presence of that
feature and allow nested VMs to power on when it is found.
VMware, Inc [Thu, 17 Dec 2009 21:41:14 +0000 (13:41 -0800)]
open-vm-tools: check for libproc.so, scrnsaver.h
. some newer distros apparently started to ship procps 3.2.8, so try
to link against libproc.so and, only if that fails, try
libproc-3.2.7.so. For other cases the user will have to manually
intervene.
. check for scrnsaver.h being there since our code includes it (and
add a macro that simplifies doing that check for X11 libraries).
VMware, Inc [Thu, 17 Dec 2009 21:40:43 +0000 (13:40 -0800)]
Fix minor memory leak in guest info plugin.
This only affected the case when the plugin decided not to be loaded
(e.g. when running on a boot camp partition running on the bare metal).
The service will quit soon in that case, but it's still good to have the
code do the right thing.
VMware, Inc [Thu, 17 Dec 2009 21:31:13 +0000 (13:31 -0800)]
This change was reviewed as multiple pieces but is being checked in as one big chunk
to prevent build breaks since parts depend on other pieces.
Add VMCILOG to the guest
The guest and the host crosstalk drivers have different notions of logging macros. Really we should unify them.
To keep this change from getting any larger I have instead added a temporary VMCILOG macro to the guest.
====
Add VMCI_CanScheduleDelayedWork and VMCI_ScheduleDelayedWork to all VMCI platforms
This change is a precursor to supporting VMCI delayed event callbacks. It provides basic
infrastructure to ask that a callback be scheduled and run in a delayed work context.
Right now this is only implemented on linux and vmkernel. Other platforms currently provide
dummy implementations and return VMCI_ScheduleDelayedWork() as FALSE.
====
Add support for delayed linux VMCI events.
This is the intial change to add delayed event callbacks to vmciEvent.c.
In particular this change:
1. Defines a flags field and requires that all callers pass in delayed or none flags when calling
VMCIEvent_RegisterSubscription.
2. Changes the lock rank of the event callbacks to be above queuepairs.
3. Change the VMCIEvent cleanup routine to require all VMCI events to be unregsitered before the module is unloaded.
4. Reference count the individual vmci event subscriptions so they don't go away while callbacks can be firing.
5. Wait for all callbacks to fire before allowing unsubscription to continue.
6. Modify VMCIEvent_Dispatch to allow callbacks to be fired in a delayed work context with no locks held.
====
Pull in vmciEvent.c changes from the host into vmciEvent.c
This change is a setup change to unify vmciEvent.c on the guest and the host module. This change just pulls in
host side vmciEvent.c code into the guest. Followup changes will make this code actually work.
====
Remove HelperQueue VMKERNEL call from vmciEvent.c.
Previous to this change the VMkernel went through the vmci event subscriber array in a helper world because it
wanted to take the subscriber array lock which was lower rank than the queuepair lock. Now that the VMK always uses
the delayed work mechanism ... this is no longer needed.
====
Make vmkernel work with the new vmciEvent code.
This modifies the core vmkernel vmci interface code to use the new vmci event flag field. This lets
vmkernel continue to compile and lets external (to the module) vmkernel clients use vmci if they desire.
====
Merge bora-vmsoft vmciEvent.c into bora vmciEvent.c
Now that the vmciEvent code is in a state where it can work on both the guest and the host, merge the guest
vmciEvent.c code to be 100% the same as the host code. In the future we can consider just using the same file
for the host and guest.
====
Add extra VMCIEvent_Subscribe param to vsock linux build.
This change just modifies the linux vsock code to pass in the new required param for Event subscribe to existing
calls. This should not change anything about how linux vsock actually works.
====
Register for VMCI_EVENT_CTX_ID_UPDATE
This change makes linux vsock register for VMCI_EVENT_CTX_ID_UPDATE and use the new vmciEvent delayed callback code.
Right now stream sockets break if a vm's cid ever changes and vsock is not reloaded (new stream sockets will not
succeed in being connected). This change fixes that by registering for the VMCI_EVENT_CTX_ID_UPDATE call and
reregistering the datagram handler for the control port.
====
Make common vsock code pass in the new argument to VMCIEvent_Subscribe
This change is required to have the common vsock code continue building. There should be no functional changes
here.
====
VMware, Inc [Thu, 17 Dec 2009 21:30:24 +0000 (13:30 -0800)]
Linux HGFS: Fix warnings when building kernel module
Fix the following compiler warnings when buildling vmhgfs module:
bora-vmsoft/hgfs/linux/fsutil.c: In function 'HgfsBuildPath':
bora-vmsoft/hgfs/linux/fsutil.c:1059: warning: pointer targets in assignment differ in signedness
bora-vmsoft/hgfs/linux/tcp.c: In function 'HgfsSocketDataReady':
bora-vmsoft/hgfs/linux/tcp.c:128: warning: pointer targets in passing argument 2 of 'set_bit' differ in signedness
bora-vmsoft/hgfs/linux/tcp.c: In function 'HgfsSocketChannelSend':
bora-vmsoft/hgfs/linux/tcp.c:807: warning: pointer targets in passing argument 2 of 'HgfsSocketSendMsg' differ in signe
VMware, Inc [Thu, 17 Dec 2009 21:30:02 +0000 (13:30 -0800)]
Remove MSI depndency on kernel version.
No need to worry about the suboptimal MSI implementation in older
kernels. Now that we only build for 2.6.16 and higher, get rid of those
MSI dependencies.
VMware, Inc [Thu, 17 Dec 2009 21:29:40 +0000 (13:29 -0800)]
Use kernel pages for SGL's.
SGL pages don't need to reside in the scarce DMA addressable space, we
can instead allocate generic kernel pages for these and use the
map/unmap API's to consistently access these pages.
VMware, Inc [Thu, 17 Dec 2009 21:28:53 +0000 (13:28 -0800)]
Reduce typedef usage.
Userdefined typedef's are considered evil, atleast for Linux drivers.
So use the struct keyword. While at it, also cleaned up some indentation
glitches.
VMware, Inc [Tue, 17 Nov 2009 22:11:10 +0000 (14:11 -0800)]
Clean up the Tools Core "utils" API.
Get rid of a bunch of functions that were either sort of redundant or
not really needed at all. Now an app that needs to use the vmtools.dll
logging just needs to call two functions:
VMTools_LoadConfig() (or load the config data some other way)
VMTools_ConfigLogging()
And those same functions provide all the functionality previously offered
by the other, now defunt, functions.
Change all call sites to use the new functions.
Also, two minor improvements to the library:
. the logging subsystem is not activated by default when a process loads
the library. This makes it opt-in (users have to explicitly call
VMTools_ConfigLogging() to enable the vmtools.dll logging code).
. the log reset code now handles keeping log files opened also for
sub-domains (previously only the default log domain would get that
treatment).
VMware, Inc [Tue, 17 Nov 2009 22:10:19 +0000 (14:10 -0800)]
Minor improvements to vmtoolsd and public interfaces.
. constify ToolsAppCapability::name.
. skip files that don't end with the platform's shared library extension
when loading plugins
. compile with "-subsystem:windows" on Win32; to allow logging to a
console, add new command line flag that attaches to the parent's
console and redirects standard output streams.
VMware, Inc [Tue, 17 Nov 2009 22:08:31 +0000 (14:08 -0800)]
GuestInfo: Fix NicInfo caching. [1/2]
NicInfoV3 introduced considerably more complex XDR types. Comparing
said types is non-trivial, so this change introduces "isEqual" routines
for each of the new types.
The IsEqual code bodies are similar to some of the existing test code,
and the latter will be refactored to use these soon.
I also have a bunch of unit tests coming in a second change.
VMware, Inc [Tue, 17 Nov 2009 22:08:08 +0000 (14:08 -0800)]
Vmblock-FUSE: respond to reads from control file
Because we can't implement the same control mechanism in FUSE-based
vmblock module as in-kernle one (FreeBSD and Solaris use ioctl and
we don't have a device node here) userspace needs to be able to
detect the kind of vmblock being used and adjust accordingly. Change
vmblock-fuse to allow reading from the control file and respond with
a pre-defined string ("I am VMBLOCK-FUSE").
Ths change complements change 816902 that implemented fuse/legacy
selector in DND code.
VMware, Inc [Tue, 17 Nov 2009 22:06:45 +0000 (14:06 -0800)]
GuestDiskInfo - small API cleanup
Provide GuestInfo_InitDiskInfo(), GuestInfo_CopyDiskInfo() and
GuestInfo_FreeDiskInfo() instead of having users muck with the data,
manually freeing it. Copying will not re-allocate memoty if number
of entries is the same. Also make GuestInfo_GetDiskInfo() cleanup
after itself in case of failure.
Reset cached disk info after resume to make sure we send the most
up-to-date information to host.
VMware, Inc [Tue, 17 Nov 2009 22:05:48 +0000 (14:05 -0800)]
XdrUtil: Add optional string, opaque field macros.
During the NicInfoV3 mess, it was a fairly common operation to have to
assign arbitrary data to optional string, opaque, and optional opaque
fields. This change introduces a few macros which make it a little easier
to do just that.
Not sure that I'm happy with them, but they get the job done for initializers
used in test code.
VMware, Inc [Tue, 17 Nov 2009 21:54:30 +0000 (13:54 -0800)]
Posix Hostinfo_GetOSName fixes.
1. NUL-terminate osNameFull.
2. Insert a space between uts.sysname & uts.release (i.e., report
Linux 2.6.18 instead of Linux2.6.18).
3. When setting the "other24linux" or "other26linux" defaults, make the
decision based on uts.release /starting with/ 2.4 or 2.6.
VMware, Inc [Tue, 17 Nov 2009 21:54:15 +0000 (13:54 -0800)]
Tools API: be nice to C++ users.
Automatically wrap function declarations in 'extern "C"'. Also remove
a check for a "magic" macro we were using to protect against misuses
of the rpcChannel library (other things will break if you try to
compile the rpcChannel without that macro; users shouldn't need to worry
about it).
VMware, Inc [Tue, 17 Nov 2009 21:46:11 +0000 (13:46 -0800)]
Re-organize the Tools Core public headers (1/2).
These headers will form the base of the public Tools Core interface, so
they need to be moved to the "fully qualified" location.
This change just moves the headers to the new location. (For the
perforce-minded folks, I am branching / editing the new files, so
history is kept as far as where the contents come from.)
VMware, Inc [Tue, 17 Nov 2009 21:44:40 +0000 (13:44 -0800)]
Fix a few issues with app provider registration in vmtoolsd.
. create a fake provider for the TOOLS_APP_PROVIDER type so that when
registering a provider there is no NULL dereference.
. correctly detect duplicate providers by looking at the list of existing
providers.
. if a provider is not found when registering an app, print a log message
and continue trying other app regs.
. add a provider reg to the test plugin to make sure the above works.
VMware, Inc [Tue, 17 Nov 2009 21:42:47 +0000 (13:42 -0800)]
GuestInfo and friends: Plug some leaks.
When finished with a GLib IO channel, decrement its reference count
via g_io_channel_unref(). Do NOT simply g_free() it. This is the
biggest source of leakaged addressed in this changeset.
Also noticed that we were abandoning XDR structures during V3-to-V2
NicInfo conversion. Fixed.
And, finally, lib/slashProc was leaking **file descriptors**. WTF.
VMware, Inc [Tue, 17 Nov 2009 21:41:37 +0000 (13:41 -0800)]
Remove vmware internal headers from rpcChannel.h.
This header will be part of the Tools Core public headers and we don't
want to expose our internal headers through it. Replace the ASSERTS()
we have in the code with glib checks (that can be switched to asserts
at runtime).
VMware, Inc [Tue, 17 Nov 2009 21:31:43 +0000 (13:31 -0800)]
Remove vmrpcdbg.h's dependency on util.h.
This is (well, will be) a public header and should not depend on our
internal headers. So change the macro that uses util.h into a function
so we hide the dependency from consumers (and fix the few existing uses).
VMware, Inc [Tue, 17 Nov 2009 21:29:38 +0000 (13:29 -0800)]
Use WinReg_GetSZ() to get the Tools install path.
RegOpenKey() tries to open the registry key with too many permissions,
which is not allowed for all users. GetSZ() uses RegOpenKeyEx() with
just the needed permission to read the value, which should work for
more users.
VMware, Inc [Tue, 17 Nov 2009 21:27:24 +0000 (13:27 -0800)]
Remove rpchChannel.h's dependendy on rpcin.h.
rpcChannel.h is part of the "public" tools core API, and shouldn't expose
internal APIs (such as those in rpcin.h). This has the downside of having
to duplicate some definitions from rpcin.h, since we still have code that
uses the rpcin library directly.
This change also standardizes rpcChannel.h's interface to use glib types
and not VMware types. This is the cause of most of the churn in this
change (Bool -> gboolean), and also required the definition of a new type
(RpcInRet) to be used while we still have code that needs to be compatible
both with vmtoolsd and vmware-user; this type can (and should) go away
once vmware-user is deprecated.
VMware, Inc [Tue, 17 Nov 2009 21:26:46 +0000 (13:26 -0800)]
Rename nested paging controls
Instead of ENTER_VMM and EXIT_VMM, let's call these what they are:
RESTRICT_BACKDOOR and OPEN_BACKDOOR. Given the more narrow usage, it
also makes sense to disable the nesting controls when
monitor_control.restrict_backdoor is set.
VMware, Inc [Tue, 17 Nov 2009 21:25:52 +0000 (13:25 -0800)]
Remove guestInfoServer.h, add guestInfoLib.h.
The first one is a leftover from when the tools service was monolithic and
based on static libraries. The second one will hold declarations of functions
from the guestInfo library; later on, some declarations currently in
bora/public/guestInfo.h can be moved there.
VMware, Inc [Tue, 17 Nov 2009 21:25:23 +0000 (13:25 -0800)]
Add unique MODULE_ALIAS to non-PCI linux drivers
To help installer figure out whether there is already a vendor-provided
kernel module (with potentially different name) that should not be
clobbered it was decided that we will use unique module alias string to
identify modules.
vmsync driver will not be upstreamed (newer kernels already have the
same functionality) and so is vmblock and thus are left alone.
vmxnet, vmxnet3, pvscsi and vmci are PCI drivers and don't require
artificial aliases.
VMware, Inc [Tue, 17 Nov 2009 21:24:43 +0000 (13:24 -0800)]
Move time sync-related functions to the time sync plugin.
There's no use in having these functions in a public library, since they're
pretty much internal functions used by the time sync feature.
This change also cleans up a lot of the logging to avoid printing the
function name everywhere (since now the log statements are properly
identified by the timeSync log domain) and to log useful error messages
where they were missing.
VMware, Inc [Tue, 17 Nov 2009 21:19:57 +0000 (13:19 -0800)]
Assign result of CPName_GetComponent to a signed variable.
This is a follow up change. CPName_GetComponent returns -1 to report
an error thus it can't be assigned to a unsigned variable.
In the previous change most of the places where CPName_GetComponent was
assigned to a size_t variable were fixed however couple of places were missed.
VMware, Inc [Thu, 15 Oct 2009 22:09:23 +0000 (15:09 -0700)]
Print default domain info when logging to shared handlers.
This makes it easier to identify log messages printed to, let's say,
OutputDebugString, by also including the name of the application
logging the message (aside from the log domain that generated it).
Bonus: prefer glib functions in a few cases, get rid of ALL_LOG_LEVELS
since glib already provides that.
VMware, Inc [Thu, 15 Oct 2009 22:09:00 +0000 (15:09 -0700)]
Don't abort if log files can't be opened.
glib's documentation lies about custom log handlers being able to handle
G_LOG_FLAG_RECURSION. It always uses its internal handler. So what happens is
that when our logging function calls g_warning() to log that a log file could
not be opened, it causes log recursion, which calls glib's internal handler,
which then aborts the process.
Avoid that by calling the default log handler directly instead of going
through the glib log system in that case.
VMware, Inc [Thu, 15 Oct 2009 22:08:21 +0000 (15:08 -0700)]
I had previously done a sandbox build, that succeeded,
but I made a change for a review, and I didn't run another
sandbox build. I'll back out my change and figure out how to fix
this.
VMware, Inc [Thu, 15 Oct 2009 22:07:44 +0000 (15:07 -0700)]
Add log-only miRegionStr() utility to lib/region
I know lib/region is much-maligned and will go away, but I needed some
debugging besides the Warning()s provided by miPrintRegion(), so I
made this change.
With this change, I added a new VMX86_LOG-only function, miRegionStr(),
which allocates a string describing the contents of a region, and
stores the string inside the region structure.
When the region is changed or destroyed, the string is freed.
I consolidated the region initalization code duplicated in
miRegionCreate and miRegionInit into miRegionInit (I accidentally
modified only miRegionInit initially, and realized it was silly
to have two functions that do the exact same thing, so I figured
I'd save future coders the same trouble.)
VMware, Inc [Thu, 15 Oct 2009 21:31:03 +0000 (14:31 -0700)]
Linux HGFS: avoid unnecessary copying of buffers
Instead of allocating additional memory chunk when sending over
TCP/Vsock channel and using local receiving buffer in TCP/Vsock
receiver thread implement per-transport memory allocation that
would allow allocating all necessary memory up-front. This also
lays ground work for allocating variable-size requests.
Additionally rework receiving thread logic so that we don't have
to wait for receive operation to time our before we can suspend
or shutdown TCP/Vsock channel.
Also move most of the duplicated channel handling logic in
generic transport code and reduce amount of locks (we really
only need channel lock).
VMware, Inc [Thu, 15 Oct 2009 21:30:26 +0000 (14:30 -0700)]
Add Support for auto upgrading tools at windows xp shutdown.
This feature is only enabled if toolsd on the guest alerts the vmx that upgrade at shutdown is supported and if the policy is set to upgradeatpowercycle